com php-src: Accept static member fetch in new variable (BC): Zend/tests/varSyntax/globalNonSimpleVariableError.phpt
Zend/tests/varSyntax/newVariable.phpt Zend/zend_language_pa rser.y

From: Date: Fri, 06 Jun 2014 15:05:14 +0000
Subject: com php-src: Accept static member fetch in new variable (BC): Zend/tests/varSyntax/globalNonSimpleVariableError.phpt
Zend/tests/varSyntax/newVariable.phpt Zend/zend_language_pa rser.y
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-81054@lists.php.net to get a copy of this message
Commit: c8aa51f82590d8353640a0470ed49f7a1a21fcaa Author: Nikita Popov <nikic@php.net> Fri, 6 Jun 2014 17:05:14 +0200 Parents: e4e42df4e6fc99bc05d243978146fb0b6e5b4085 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=c8aa51f82590d8353640a0470ed49f7a1a21fcaa Log: Accept static member fetch in new variable (BC) Changed paths: A Zend/tests/varSyntax/globalNonSimpleVariableError.phpt A Zend/tests/varSyntax/newVariable.phpt M Zend/zend_language_parser.y Diff: diff --git a/Zend/tests/varSyntax/globalNonSimpleVariableError.phpt b/Zend/tests/varSyntax/globalNonSimpleVariableError.phpt new file mode 100644 index 0000000..ed04921 --- /dev/null +++ b/Zend/tests/varSyntax/globalNonSimpleVariableError.phpt @@ -0,0 +1,10 @@ +--TEST-- +Global keyword only accepts simple variables +--FILE-- +<?php + +global $$foo->bar; + +?> +--EXPECTF-- +Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR), expecting ',' or ';' in %s on line %d diff --git a/Zend/tests/varSyntax/newVariable.phpt b/Zend/tests/varSyntax/newVariable.phpt new file mode 100644 index 0000000..360f99a --- /dev/null +++ b/Zend/tests/varSyntax/newVariable.phpt @@ -0,0 +1,39 @@ +--TEST-- +Variable as class name for new expression +--FILE-- +<?php + +$className = 'stdClass'; +$array = ['className' => 'stdClass']; +$obj = (object) ['className' => 'stdClass']; + +class Test { + public static $className = 'stdClass'; +} +$test = 'Test'; +$weird = [0 => (object) ['foo' => 'Test']]; + +var_dump(new $className); +var_dump(new $array['className']); +var_dump(new $array{'className'}); +var_dump(new $obj->className); +var_dump(new Test::$className); +var_dump(new $test::$className); +var_dump(new $weird[0]->foo::$className); + +?> +--EXPECTF-- +object(stdClass)#%d (0) { +} +object(stdClass)#%d (0) { +} +object(stdClass)#%d (0) { +} +object(stdClass)#%d (0) { +} +object(stdClass)#%d (0) { +} +object(stdClass)#%d (0) { +} +object(stdClass)#%d (0) { +} diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y index e28949d..013e3dd 100644 --- a/Zend/zend_language_parser.y +++ b/Zend/zend_language_parser.y @@ -883,13 +883,8 @@ fully_qualified_class_name: class_name_reference: - class_name { zend_do_fetch_class(&$$, &$1 TSRMLS_CC); } - | dynamic_class_name_reference { zend_do_end_variable_parse(&$1, BP_VAR_R, 0 TSRMLS_CC); zend_do_fetch_class(&$$, &$1 TSRMLS_CC); } -; - - -dynamic_class_name_reference: - new_variable { $$ = $1; } + class_name { zend_do_fetch_class(&$$, &$1 TSRMLS_CC); } + | new_variable { zend_do_end_variable_parse(&$1, BP_VAR_R, 0 TSRMLS_CC); zend_do_fetch_class(&$$, &$1 TSRMLS_CC); } ; exit_expr: @@ -1115,6 +1110,11 @@ new_variable: | new_variable '{' expr '}' { fetch_string_offset(&$$, &$1, &$3 TSRMLS_CC); } | new_variable T_OBJECT_OPERATOR member_name { zend_do_fetch_property(&$$, &$1, &$3 TSRMLS_CC); } + | class_name T_PAAMAYIM_NEKUDOTAYIM simple_variable + { zend_do_fetch_static_member(&$$, &$1, &$3 TSRMLS_CC); } + | new_variable T_PAAMAYIM_NEKUDOTAYIM simple_variable + { zend_do_end_variable_parse(&$1, BP_VAR_R, 0 TSRMLS_CC); + zend_do_fetch_static_member(&$$, &$1, &$3 TSRMLS_CC); } ; dim_offset:

« previous php.cvs (#81054) next »