Re: [RFC] [PHP 6] Uniform Variable Syntax
| From: | Nikita Popov | Date: | Mon, 09 Jun 2014 14:12:45 +0000 |
| Subject: | Re: [RFC] [PHP 6] Uniform Variable Syntax | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-74799@lists.php.net to get a copy of this message | ||
On Mon, Jun 9, 2014 at 3:45 PM, Andrea Faulds <ajf@ajf.me> wrote:
>
> On 9 Jun 2014, at 14:33, Nikita Popov <nikita.ppv@gmail.com> wrote:
>
> > I have created a proposal for a more consistent and complete variable
> > syntax for PHP 6:
> >
> > https://wiki.php.net/rfc/uniform_variable_syntax
> >
> > The RFC is targeted at PHP 6 because it breaks compatibility for some
> > rarely used variable-variable constructs.
>
> I love this proposal! The behaviour of $$ is non-intuitive at present and
> has bitten me more than once, and the weird behaviour of :: has also caused
> me problems. In particular, my miniature web framework didn’t work properly
> due to this line:
>
> self::$views[$path]();
>
> It’s easy to fix ($x = self::$views[$path]; $x();) but the fact that
> didn’t work has bothered me immensely for two years. It seems to me like
> the RFC would fix this. Would it? If so, you are my hero.
>
Yes, it would ;)
> On a somewhat more serious note, do we have any idea of how much code this
> would break? Is the current behaviour widely relied-upon?
>
Quoting
https://wiki.php.net/rfc/uniform_variable_syntax#backward_incompatible_changes
:
> An analysis of the Zend Framework and Symfony projects
> (including standard dependencies) showed that only a single
> occurrence of $loader[0]::$loader[1]($className) in the Doctrine
> class loader will be affected by this change.
So I think that this will not break much code. It is also easy to detect
and fix. (I am using this script to find potential problems:
https://gist.github.com/nikic/ffd019ef78b72934c7cc)
Nikita