This repository was archived by the owner on Jan 30, 2020. It is now read-only.
Improve handling of digits in CamelCaseToSeparator filter#45
Open
edigu wants to merge 1 commit intozendframework:masterfrom
Open
Improve handling of digits in CamelCaseToSeparator filter#45edigu wants to merge 1 commit intozendframework:masterfrom
edigu wants to merge 1 commit intozendframework:masterfrom
Conversation
Member
|
I'm pushing this to 3.0 (which will happen this year, as we will be releasing new major versions of all components that set PHP 7.1 as the minimum supported version). While I agree it is the correct behavior, I worry that if users are expecting the current behavior currently, this would break their applications. Pushing it to a new major version allows them to upgrade at their own pace. |
Member
|
This repository has been closed and moved to laminas/laminas-filter; a new issue has been opened at laminas/laminas-filter#9. |
Member
|
This repository has been moved to laminas/laminas-filter. If you feel that this patch is still relevant, please re-open against that repository, and reference this issue. To re-open, we suggest the following workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR aims to add the behaviour asked in #33
Since the reason behind using the CamelCaseSeparator is tokenizing strings when case is changed, usual expectation is beginning a new token when hitting a number or digit.
I will try to summarize both current and changed behaviour on numbers with some examples:
The issue #33 is about the
CamelCaseToDashFilterbut since it derived fromCamelCaseToSeparatorlikeCamelCaseToUnderscore, this change will affect both childs ofCamelCaseToSeparator. For this reason, I also added more tests toCamelCaseToDashTest.After digging dozen of approaches including other platforms such as Java and C# I came up with this final patterns with positive lookbehind and lookaheads. (Achieving same effect with a single regex seems like impossible, at least I give up)
I'm also aware of changing an existing test is not a good practice. Since the expected behaviour is changed for digits, I forced into touching the
CamelCaseToUnderscoreTest:Altering the
CamelCaseToUnderscoreTestseems like mandatory if the desired behaviour will be changed.All tests are still green.