Skip to content
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

TextStrings::getCompleteTextString(): add BC for incorrectly tokenized double quoted strings #317

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Jun 2, 2022

While creating a sniff for PHPCompatibility to detect the PHP 8.2 deprecation of two of the four syntaxes to embed variables/expressions within text strings, I realized that for select examples of the "type 4" syntax - "Variable variables (“${expr}”, equivalent to (string) ${expr})" -, PHPCS did not, and probably never did, tokenize those correctly in PHPCS itself.

A fix for this has been pulled to PHPCS in PR squizlabs/PHP_CodeSniffer#3604.

This commit ensures that the TextStrings::getCompleteTextString() method handles double quoted strings affected by this tokenizer bug correctly in all supported PHPCS versions.

Includes dedicated tests specifically for the handling of embedded variables/expressions in double quoted strings.

Refs:

…d double quoted strings

While creating a sniff for PHPCompatibility to detect the PHP 8.2 deprecation of two of the four syntaxes to embed variables/expressions within text strings, I realized that for select examples of the "type 4" syntax - "Variable variables (`“${expr}”`, equivalent to (string) `${expr})`" -, PHPCS did not, and probably never did, tokenize those correctly in PHPCS itself.

A fix for this has been pulled to PHPCS in PR squizlabs/PHP_CodeSniffer 3604.

This commit ensures that the `TextStrings::getCompleteTextString()` method handles double quoted strings affected by this tokenizer bug correctly in all supported PHPCS versions.

Includes dedicated tests specifically for the handling of embedded variables/expressions in double quoted strings.
@jrfnl jrfnl added this to the 1.0.0-alpha4 milestone Jun 2, 2022
@jrfnl jrfnl merged commit 76c8115 into develop Jun 2, 2022
@jrfnl jrfnl deleted the textstrings/getcompletestring-bugfix-for-interpolated-variables branch June 2, 2022 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant