rfc:dynamic_class_constant_fetch

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
rfc:dynamic_class_constant_fetch [2022/11/04 14:13] – Fix syntax error ilutovrfc:dynamic_class_constant_fetch [2023/02/02 17:17] (current) – Move to implemented ilutov
Line 3: Line 3:
   * Date: 2022-11-04   * Date: 2022-11-04
   * Author: Ilija Tovilo, tovilo.ilija@gmail.com   * Author: Ilija Tovilo, tovilo.ilija@gmail.com
-  * Status: Draft+  * Status: Implemented
   * Target Version: PHP 8.3   * Target Version: PHP 8.3
   * Implementation: https://github.com/php/php-src/pull/9793   * Implementation: https://github.com/php/php-src/pull/9793
Line 53: Line 53:
 ==== {} expression type ==== ==== {} expression type ====
  
-The result of the expression in the braces <php>{}</php> must be of type <php>string</php>. If it is not, an +The result of the expression in the braces <php>{}</php> must be of type <php>string</php>. If it is not, a 
-<php>Error</php> is thrown.+<php>TypeError</php> is thrown.
  
 <code php> <code php>
 echo Foo::{[]}; echo Foo::{[]};
-// ErrorIllegal offset type+// TypeErrorCannot use value of type array as class constant name
 </code> </code>
  
Line 123: Line 123:
  
 // Can't be demonstrated because there is no __getStatic // Can't be demonstrated because there is no __getStatic
-// Foo::${test('foo')}::${test('bar')};+Foo::${test('foo')}::${test('bar')};
 // foo // foo
 // Static property foo // Static property foo
Line 130: Line 130:
 </code> </code>
  
-Property and array accesses evaluate all expressions in the chain before performing any of the actual operations. For +Property and array accesses evaluate all expressions in the chain before performing any of the actual operations. The reason for this is rather [[https://www.npopov.com/2017/04/14/PHP-7-Virtual-machine.html#writes-and-memory-safety|technical]]. Basically, no userland code must run between property or array accesses to avoid reallocation and thus potentially invalidating pointers. This problem does not apply to class constants. Thus, the simpler and more intuitive in-order approach is chosen. Evaluation order for class constants is also unlikely to matter since chaining them is of dubious usefulness.
-constants, order is less relevant because it's very rare for them to be chained. Thus, the simpler approach is chosen+
-which is evaluating them in order.+
  
 <code php> <code php>
-// Foo::{test('foo')}::{test('bar')};+Foo::{test('foo')}::{test('bar')};
 // foo // foo
 // Class constant foo // Class constant foo
Line 170: Line 168:
 ===== Vote ===== ===== Vote =====
  
-Voting starts ??? and ends ???+Voting starts 2022-12-22 and ends 2023-01-05
  
 As this is a language change, a 2/3 majority is required. As this is a language change, a 2/3 majority is required.
rfc/dynamic_class_constant_fetch.1667571221.txt.gz · Last modified: 2022/11/04 14:13 by ilutov