Re: [RFC] [PHP 6] Uniform Variable Syntax
| From: | Rowan Collins | Date: | Tue, 10 Jun 2014 11:38:11 +0000 |
| Subject: | Re: [RFC] [PHP 6] Uniform Variable Syntax | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-74814@lists.php.net to get a copy of this message | ||
Rowan Collins wrote (on 09/06/2014):
The advantage of the proposed behaviour is that it can be easily explained to *new* users of the language, as it's internally consistent, which appears not to be true of the old - an example in the RFC being |Foo::$bar[1][2][3] vs ||Foo::$bar[1][2][3]()|A simpler example of the current logic's inconsistencies: $foo = 'foo'; $bar->$foo = array(); $bar->$foo[0] = 42; // $bar now has an array on ->foo, and an integer on ->f http://3v4l.org/pImS3 Not only does this not feel consistent in itself, it's different if you do the same thing with an object: $foo = 'foo'; $bar->$foo = new stdClass; $bar->$foo->x = 42; // $bar now has a single property ->foo, which is an object with property ->x http://3v4l.org/DUaJj Other than "it's always worked this way", I can't think of a good justification for this difference. -- Rowan Collins [IMSoP]