PHP 7.4/8.0: new ChangedConcatOperatorPrecedence sniff by jrfnl · Pull Request #805 · PHPCompatibility/PHPCompatibility
jrfnl
mentioned this pull request
40 tasks
... to determine whether a `+` or `-` is an operator or a unary, i.e. `-1`. This method will :fingers_crossed: also be introduced into PHPCS itself in version 3.5.0. Upstream, the method has been pulled with unit tests. As the intention is for this method to primarily be hosted within PHPCS, it seemed redundant to duplicate those here. Refs: * squizlabs/PHP_CodeSniffer#2456 * squizlabs/PHP_CodeSniffer@3167110
As of PHP 8.0, the operator precedence of concatenation will be lowered, with deprecation notices being thrown as of PHP 7.4 for unparenthesized expressions containing an '.' before a '+' or '-'. Refs: * https://wiki.php.net/rfc/concatenation_precedence * php/php-src@3b23694 (PHP 7.4 deprecation) * php/php-src@61ee869 (PHP 8.0 precedence change) Notes: - I've not been able to come up with a valid unit test which would involve `&` as a reference, but I suspect this should be accounted for all the same, so the sniff does account for it. **NOTE**: the name of the sniff does not comply with the "normal" naming pattern, but I'm not sure what would be a more appropriate name `ForbiddenConcatBeforePlusMinusWithoutParenthesis` seems a bit overly long, just as `RemovedConcatPrecedenceSameAsPlusMinus`. Ideas welcome.
wimg approved these changes Jun 16, 2019
wimg
deleted the
php-7.4/concatenation-precedence
branch
This file contains hidden or 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