✨ PHP 8.2 | New PHPCompatibility.TextStrings.RemovedDollarBraceStringEmbeds
sniff
#1424
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.
PHP 8.2 will be deprecating two out of the four ways to embed variables and expressions in text strings (heredocs and double quoted strings).
This commit introduces a new sniff to detect this deprecation.
Analyzing code for this deprecation was affected by a bug in the PHPCS Tokenizer discovered while writing this sniff. As of PHPCSUtils 1.0.0-alpha4, the utility methods in PHPCSUtils include a work-around for this bug and are stable for our purposes.
Also note that while the included unit tests should absolutely be sufficient for our purposes, the PHPCSUtils methods used to retrieve embedded variables and expressions are tested in-depth (> 1000 tests for that functionality alone), so we should be good ;-)
Last note: the tests are split in two files as any code after a PHP 7.3 heredoc/nowdoc will not tokenize correctly on PHP < 7.3. Splitting the tests into two files works as a work-around for that.
Includes unit tests.
Includes sniff documentation.
Refs:
${
squizlabs/PHP_CodeSniffer#3604Related to #1348