Hi internals,
I've opened voting on the RFC to deprecate & remove left associative
ternary without explicit parentheses. The vote ends 2019-05-07:
https://wiki.php.net/rfc/ternary_associativity
The RFC stays as originally proposed: The associativity of the ternary
will not be changed to right-associative in PHP 8, only the
left-associative use without disambiguating parentheses becomes an error.
Regards,
Nikita
To better judge the BC impact here, I've analyzed the top 1000 composer
packages for this pattern. The results are here:
https://gist.github.com/nikic/b6214f87b0e4a7c6fe26919ac849194f
The tl;dr is that nested ternaries were used a total of 12 times across all
files. 9 of these uses are bugs: A right-associative meaning was intended,
but PHP will interpret left-associatively. 3 uses of the form $a ? $b : $c
?: $d are potentially okay, because the difference between the two
interpretations is small and it's not obvious to me which one is actually
intended.
Nikita