-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tokenizer/PHP: more context sensitive keyword fixes #3797
Merged
gsherwood
merged 1 commit into
squizlabs:master
from
jrfnl:feature/tokenizer-php-more-context-sensitive-keyword-issues
May 4, 2023
Merged
Tokenizer/PHP: more context sensitive keyword fixes #3797
gsherwood
merged 1 commit into
squizlabs:master
from
jrfnl:feature/tokenizer-php-more-context-sensitive-keyword-issues
May 4, 2023
Conversation
This file contains 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
This was referenced Apr 13, 2023
jrfnl
added a commit
to PHPCompatibility/PHPCompatibility
that referenced
this pull request
Apr 18, 2023
Turns out PHPCS does not tokenize the `parent` keyword correctly as `T_STRING` when used as a function name in a function declaration which returns by reference, nor when that function name is subsequently called. A fix has been pulled for this upstream: squizlabs/PHP_CodeSniffer#3797 In the mean time, this commit fixes the issue for this sniff in a PHPCS cross-version compatible manner. Includes unit tests. Fixes 1489
PHPCS re-tokenizes the `self`, `parent`, `true`, `false` and `null` keywords to a PHPCS native token. This re-tokenization did not take the following situations into account: * Those keywords being used as function names when the function is declared to return by reference. * Those keywords being used as a function call. Additionally, the PHP native `T_STATIC` token would not be (re-)tokenized to `T_STRING` when used as a function call, though it was tokenized correctly when used as a method call.. While using the `static` keyword for a global function declaration is illegal in PHP, the tokenization in PHPCS should still be consistent. This commit fixes those issues. Includes additional unit tests.
jrfnl
force-pushed
the
feature/tokenizer-php-more-context-sensitive-keyword-issues
branch
from
April 19, 2023 05:25
a4d02dd
to
cb764c7
Compare
Note: I've updated the commit to contain yet more unit tests. |
jrfnl
deleted the
feature/tokenizer-php-more-context-sensitive-keyword-issues
branch
May 4, 2023 06:31
FYI: this fix is included in today's PHP_CodeSniffer 3.8.0 release. As per #3932, development on PHP_CodeSniffer will continue in the PHPCSStandards/PHP_CodeSniffer repository. If you want to stay informed, you may want to start "watching" that repo (or watching releases from that repo). |
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.
PHPCS re-tokenizes the
self
,parent
,true
,false
andnull
keywords to a PHPCS native token.This re-tokenization did not take the following situations into account:
Additionally, the PHP native
T_STATIC
token would not be (re-)tokenized toT_STRING
when used as a function call, though it was tokenized correctly when used as a method call. While using thestatic
keyword for a global function declaration is illegal in PHP, the tokenization in PHPCS should still be consistent.This commit fixes those issues.
Includes additional unit tests.
These issues were discovered while investigating issue PHPCompatibility/PHPCompatibility#1489