rfc:uniform_variable_syntax

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
rfc:uniform_variable_syntax [2014/06/09 13:00] nikicrfc:uniform_variable_syntax [2014/07/30 00:03] – Whatever we'd both like it to have been, this is for 7, not 6 ;) ajf
Line 2: Line 2:
   * Date: 2014-05-31   * Date: 2014-05-31
   * Author: Nikita Popov <nikic@php.net>   * Author: Nikita Popov <nikic@php.net>
-  * Status: Draft +  * Status: Accepted (for PHP 7) 
-  * Proposed forPHP 6+  * Discussionhttp://markmail.org/message/mr4ihbubfbdxygci
  
 ===== Introduction ===== ===== Introduction =====
Line 52: Line 52:
                         // old meaning            // new meaning                         // old meaning            // new meaning
 $$foo['bar']['baz'    ${$foo['bar']['baz']}     ($$foo)['bar']['baz'] $$foo['bar']['baz'    ${$foo['bar']['baz']}     ($$foo)['bar']['baz']
-Foo::$bar['baz']()      Foo::{$bar['baz']}()      (Foo::$bar)['baz']()+$foo->$bar['baz'      $foo->{$bar['baz']}       ($foo->$bar)['baz']
 $foo->$bar['baz']()     $foo->{$bar['baz']}()     ($foo->$bar)['baz']() $foo->$bar['baz']()     $foo->{$bar['baz']}()     ($foo->$bar)['baz']()
 +Foo::$bar['baz']()      Foo::{$bar['baz']}()      (Foo::$bar)['baz']()
 </code> </code>
  
Line 157: Line 158:
  
 Because of the implementational hurdles described in the previous section, we do not support all combinations of Because of the implementational hurdles described in the previous section, we do not support all combinations of
-dereferencing operations to an arbitrary death. While PHP 5.4 fixed the most glaring issue (support for+dereferencing operations to an arbitrary depth. While PHP 5.4 fixed the most glaring issue (support for
 ''%%$foo->bar()['baz']%%''), other problems still exist. ''%%$foo->bar()['baz']%%''), other problems still exist.
  
Line 195: Line 196:
 ''%%$bar%%'', even though it is not necessary and never used. This is once again related to the way static member access ''%%$bar%%'', even though it is not necessary and never used. This is once again related to the way static member access
 needs to be implemented to support our weird indirect reference semantics. needs to be implemented to support our weird indirect reference semantics.
- 
-=== TODO === 
  
 ===== Proposal ===== ===== Proposal =====
Line 271: Line 270:
  
 <code> <code>
-$$foo['bar']['baz'  interpreted as ($$foo)['bar']['baz'+$$foo['bar']['baz'  interpreted as   ($$foo)['bar']['baz'
-Foo::$bar['baz']()    interpreted as (Foo::$bar)['baz']() +$foo->$bar['baz'    interpreted as   ($foo->$bar)['baz'
-$foo->$bar['baz']()   interpreted as ($foo->$bar)['baz']()+$foo->$bar['baz']()   interpreted as   ($foo->$bar)['baz']() 
 +Foo::$bar['baz']()    interpreted as   (Foo::$bar)['baz']()
 </code> </code>
  
Line 279: Line 279:
 However it is always possible to recreate the old behavior by explicitly using braces: However it is always possible to recreate the old behavior by explicitly using braces:
  
-<code>+<code php>
 ${$foo['bar']['baz']} ${$foo['bar']['baz']}
 Foo::{$bar['baz']}() Foo::{$bar['baz']}()
Line 344: Line 344:
 breaks. breaks.
  
-The former is a change in the behavior of currently existing syntax: Expressions like ''%%$foo->$bar['baz']()%%'' will +The former is a change in the behavior of currently existing syntax. Examples: 
-nowbe interpreted as ''%%($foo->$bar['baz'])()%%'' rather than ''%%$foo->{$bar['baz']}()%%''.+ 
 +<code php> 
 +                        // old meaning            // new meaning 
 +$$foo['bar']['baz'    ${$foo['bar']['baz']}     ($$foo)['bar']['baz'
 +$foo->$bar['baz'      $foo->{$bar['baz']}       ($foo->$bar)['baz'] 
 +$foo->$bar['baz']()     $foo->{$bar['baz']}(    ($foo->$bar)['baz']() 
 +Foo::$bar['baz']()      Foo::{$bar['baz']}()      (Foo::$bar)['baz']() 
 +</code>
  
 An analysis of the Zend Framework and Symfony projects (including standard dependencies) showed that only a single An analysis of the Zend Framework and Symfony projects (including standard dependencies) showed that only a single
Line 377: Line 384:
 The main changes are limited to the language parser and compiler. Furthermore some opcode handlers had to be modified The main changes are limited to the language parser and compiler. Furthermore some opcode handlers had to be modified
 to support ''CONST'' and ''TMP'' operands. to support ''CONST'' and ''TMP'' operands.
 +
 +===== Vote =====
 +
 +As this is a language change, a 2/3 majority is required for acceptance. The vote started on 2014-07-07 and ended on 2014-07-14.
 +
 +<doodle title="Implement Uniform Variable Syntax in PHP 6?" auth="nikic" voteType="single" closed="true">
 +   * Yes
 +   * No
 +</doodle>
 +
rfc/uniform_variable_syntax.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1