Tokenizer/PHP: fix tokenization of the default keyword #3351
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.
Generic/MultipleStatementAlignment: add extra tests
.. safeguarding the tokenizer fix which should prevent the issue as reported in #3326.
Tests: add extra tests for the default keyword tokenization
Tokenizer/PHP: fix tokenization of the default keyword
As per: #3326 (comment)
The commit fixes this by:
T_STRING
contexts out to a class property.Tokenizer\PHP
class where keyword tokens are (potentially) being re-tokenized toT_STRING
, including in theT_DEFAULT
tokenization code which was added to address the PHP 8.0match
expressions.Note: the issue was not introduced by the
match
related code, however, that code being there does make it relatively easy now to fix this particular case.While this doesn't address #3336 yet, it is a step towards addressing it and will sort out one of the most common causes for bugs.
Fixes #3326
Closes #3340 as superseded