Conversation
This was referenced Apr 15, 2025
a78b0dd to
c3fc316
Compare
547a345 to
93ce29b
Compare
Base automatically changed from
phpcs-4.0/feature/sq-1612-stdout-vs-stderr
to
4.x
April 17, 2025 13:09
While some specific situations related to the array keyword were already tested, this adds a more comprehensive set of tests, though I have no doubt a lot more edge cases should probably be added. Even so, this is a good start.
_I didn't dare to make this change while JS/CSS were still supported, but this should be a safe change now._ For all PHP parenthesis owners, the open parenthesis MUST be the next non-empty token. There is only one exception to this rule and that is the `T_FUNCTION` keyword where a `T_STRING` function name and potentially a `&` for return by reference are also allowed between. If the parenthesis owner is not the next valid token, the token should not be marked as a parenthesis owner, not get the other parenthesis keys. Now, while for valid code the above should always be true. For invalid code and a few edge cases, such as anonymous classes without parentheses, it is currently possible for the tokenizer to walk too far and identify a completely unrelated arbitrary open parenthesis as the parenthesis belonging to a parenthesis owner. The change in this commit should prevent that.
72df320 to
da0d224
Compare
Member
Author
|
Rebased without changes after the merge of #1010, which also gets rid of the merge conflict. |
rodrigoprimo
approved these changes
Apr 17, 2025
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Tokenizer::createTokenMap(): add tests for parentheses keys
While some specific situations related to the array keyword were already tested, this adds a more comprehensive set of tests, though I have no doubt a lot more edge cases should probably be added. Even so, this is a good start.
Tokenizer::createTokenMap(): stabilize code for parenthesis owners
I didn't dare to make this change while JS/CSS were still supported, but this should be a safe change now.
For all PHP parenthesis owners, the open parenthesis MUST be the next non-empty token.
There is only one exception to this rule and that is the
T_FUNCTIONkeyword where aT_STRINGfunction name and potentially a&for return by reference are also allowed between.If the parenthesis owner is not the next valid token, the token should not be marked as a parenthesis owner, not get the other parenthesis keys.
Now, while for valid code the above should always be true. For invalid code and a few edge cases, such as anonymous classes without parentheses, it is currently possible for the tokenizer to walk too far and identify a completely unrelated arbitrary open parenthesis as the parenthesis belonging to a parenthesis owner.
The change in this commit should prevent that.
Suggested changelog entry
parenthesis_*keys.