Ternary associativity
| From: | Nikita Popov | Date: | Thu, 23 Jul 2020 12:26:29 +0000 |
| Subject: | Ternary associativity | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-111149@lists.php.net to get a copy of this message | ||
Hi internals,
PHP currently has an incorrect right-associative ternary operator. In
https://wiki.php.net/rfc/ternary_associativity
the use of nested ternaries
was deprecated, and was supposed to become an error in PHP 8.0.
Concurrently with that proposal
https://wiki.php.net/rfc/concatenation_precedence
made a very similar
change to the concatenation operator precedence. The difference here is
that this throws a deprecation notice in PHP 7.4 (same), but changes the
behavior in PHP 8.0 (rather than making it an error).
This is a pretty nonsensical outcome, in that the same type of change is
implemented in two different ways. I think it would be good to handle the
ternary change the same way as the concatenation change, i.e. make
ternaries use the correct left-associative behavior in PHP 8.0, rather than
throwing an error.
Any thoughts on that?
Regards,
Nikita