PHP 7.4/8.0: new RemovedTernaryAssociativity sniff by jrfnl · Pull Request #810 · PHPCompatibility/PHPCompatibility
added 2 commits
June 2, 2019 20:21... to determine whether a ternary is a short ternary, i.e. without the middle. This method will :fingers_crossed: also be introduced into PHPCS itself in version 3.5.0. Upstream, the method will be 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
jrfnl
mentioned this pull request
40 tasks
PHP 7.4 deprecates nesting of ternaries without explicit use of parentheses. PHP 8.0 will remove the (left-)associativity of ternaries completely. This will become a compile-time error. Refs: * https://wiki.php.net/rfc/ternary_associativity * php/php-src@09ea55c (PHP 7.4 deprecation) * https://gist.github.com/nikic/b6214f87b0e4a7c6fe26919ac849194f Includes unit tests. To test this sniff, I have run it over some 200.000 files. While I can't say for sure whether there were any missed problem cases (false negatives), all the issues detected by the sniff were actual cases of nested ternaries which would become problematic in PHP 7.4/8.0. Related to 808
wimg approved these changes Jun 3, 2019
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