Re: $obj->attr::method() is not allowed

From: Date: Mon, 03 Sep 2012 15:18:52 +0000
Subject: Re: $obj->attr::method() is not allowed
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-62747@lists.php.net to get a copy of this message
On 03/09/12 15:51, Ivan Enderlin @ Hoa wrote:
I would like to know why? Is it a compiler related issue or just an omission? Would it be interesting to fix it? There are plenty of examples of this. One from my code:
Can't do this:
    self::$views[$path]();
But I *can* do this:
    $x = self::$views[$path]; $x();
This is because PHP has a very unusual (and IMO bad) system of type-checking at parse-time, by only allowing some specific (although quite varied) types of variable access, and combinations of these. If nikic's idea to rewrite the parser to use an AST is done, I imagine this could be fixed. We could also add extra rules, but I think fixing the general issue is more important, since it's like plugging two holes in a barrel full of water that's just had a machine gun fired at it. -- Andrew Faulds http://ajf.me/

« previous php.internals (#62747) next »