[VOTE] Deprecate left-associative ternary

  105345
April 23, 2019 08:43 nikita.ppv@gmail.com (Nikita Popov)
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
  105389
April 24, 2019 16:27 nikita.ppv@gmail.com (Nikita Popov)
On Tue, Apr 23, 2019 at 10:43 AM Nikita Popov ppv@gmail.com> wrote:

> 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
  105390
April 24, 2019 16:30 pmjones88@gmail.com (Paul Jones)
Hi all,


> On Apr 24, 2019, at 11:27, Nikita Popov ppv@gmail.com> wrote: > > 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
I *love* research like this. Really nicely done. Can you share how you accomplished it? -- Paul M. Jones pmjones@pmjones.io http://paul-m-jones.com Modernizing Legacy Applications in PHP https://leanpub.com/mlaphp Solving the N+1 Problem in PHP https://leanpub.com/sn1php
  105605
May 7, 2019 09:36 nikita.ppv@gmail.com (Nikita Popov)
On Tue, Apr 23, 2019 at 10:43 AM Nikita Popov ppv@gmail.com> wrote:

> 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 >
This RFC has been accepted with 35 votes in favor and 10 against. Nikita