You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tokenizer/PHP: change tokenization of long PHP open tags
... to no longer include whitespace (single space/new line).
This ensures the tokenization of all PHP open tags - long open tags `<?php`, short open tags `<?` and short open echo tags `<?=` - is consistent and should simplify handling of open tag tokens in sniffs and lower the cognitive load of sniff developers.
As per the detailed proposal in ticket 593.
Includes extensive unit tests, both ensuring the correct tokenization, as well as safeguarding consistency across the different open tags.
Includes the following additional updates to maintain the pre-existing behaviour:
* `AbstractPatternSniff`
The `AbstractPatternSniff` tokenizes an arbitrary code pattern to determine the token pattern to sniff for. This tokenization now to takes the change in the PHP open tag tokenization into account.
* `Generic/EmptyPHPStatement` - replace now redundant special condition for PHP open tags + update "fixed" file for improved output + add extra test.
* `PSR12/OpenTag` - allow for the changed tokenization.
The updated code also means that the fixer will no longer leave stray whitespace behind after a PHP open tag.
* `Squiz/CommentedOutCode` - allow for the changed tokenization.
* `Squiz/EmbeddedPhp` - code simplification.
* `FindStartOfStatementTest` - fixed token offset expectation as there is now an extra whitespace token.
* `ReplaceTabsInTokenMiscTest` - updated target finding
Fixes 593
0 commit comments