com php-src: fixes a syntactical inconsistency with group use and leading `\`: Zend/tests/ns_094.phpt Zend/tests/ns_09 5.phpt
Zend/zend_language_parser.y

From: Date: Tue, 18 Aug 2015 22:23:58 +0000
Subject: com php-src: fixes a syntactical inconsistency with group use and leading `\`: Zend/tests/ns_094.phpt Zend/tests/ns_09 5.phpt
Zend/zend_language_parser.y
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-88673@lists.php.net to get a copy of this message
Commit: 7568d5cb897e918a8d420faa8f964076c00276ec Author: Márcio Almada <marcio3w@gmail.com> Tue, 18 Aug 2015 19:16:06 -0300 Parents: 32462a807632922f3f9b1e4c84505901c41a1d7b Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=7568d5cb897e918a8d420faa8f964076c00276ec Log: fixes a syntactical inconsistency with group use and leading \ discussion: http://news.php.net/php.internals/87774 Changed paths: M Zend/tests/ns_094.phpt A Zend/tests/ns_095.phpt M Zend/zend_language_parser.y Diff: diff --git a/Zend/tests/ns_094.phpt b/Zend/tests/ns_094.phpt index 792b2eb..ef9ca75 100644 --- a/Zend/tests/ns_094.phpt +++ b/Zend/tests/ns_094.phpt @@ -3,7 +3,7 @@ Type group use declarations should not allow override on inner itens --FILE-- <?php -// should not throw syntax errors +// should throw syntax errors use const Foo\Bar\{ A, diff --git a/Zend/tests/ns_095.phpt b/Zend/tests/ns_095.phpt new file mode 100644 index 0000000..9c44964 --- /dev/null +++ b/Zend/tests/ns_095.phpt @@ -0,0 +1,51 @@ +--TEST-- +Absolute namespaces should be allowed +--FILE-- +<?php + +namespace Foo\Bar { + class ClassA{} + class ClassB{} + class ClassC{} + + function fn_a(){ return __FUNCTION__; } + function fn_b(){ return __FUNCTION__; } + function fn_c(){ return __FUNCTION__; } + + const CONST_A = 1; + const CONST_B = 2; + const CONST_C = 3; +} + +namespace Baz { + + use \Foo\Bar\{ClassA, ClassB, ClassC}; + use function \Foo\Bar\{fn_a, fn_b, fn_c}; + use const \Foo\Bar\{CONST_A, CONST_B, CONST_C}; + + var_dump(ClassA::class); + var_dump(ClassB::class); + var_dump(ClassC::class); + var_dump(fn_a()); + var_dump(fn_b()); + var_dump(fn_c()); + var_dump(CONST_A); + var_dump(CONST_B); + var_dump(CONST_C); + + echo "\nDone\n"; +} +?> +--EXPECTF-- + +string(14) "Foo\Bar\ClassA" +string(14) "Foo\Bar\ClassB" +string(14) "Foo\Bar\ClassC" +string(12) "Foo\Bar\fn_a" +string(12) "Foo\Bar\fn_b" +string(12) "Foo\Bar\fn_c" +int(1) +int(2) +int(3) + +Done diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y index 39d8977..8d09650 100644 --- a/Zend/zend_language_parser.y +++ b/Zend/zend_language_parser.y @@ -335,13 +335,17 @@ use_type: ; group_use_declaration: - namespace_name T_NS_SEPARATOR '{' use_declarations '}' - {$$ = zend_ast_create(ZEND_AST_GROUP_USE, $1, $4); } + namespace_name T_NS_SEPARATOR '{' use_declarations '}' + { $$ = zend_ast_create(ZEND_AST_GROUP_USE, $1, $4); } + | T_NS_SEPARATOR namespace_name T_NS_SEPARATOR '{' use_declarations '}' + { $$ = zend_ast_create(ZEND_AST_GROUP_USE, $2, $5); } ; mixed_group_use_declaration: - namespace_name T_NS_SEPARATOR '{' inline_use_declarations '}' - {$$ = zend_ast_create(ZEND_AST_GROUP_USE, $1, $4);} + namespace_name T_NS_SEPARATOR '{' inline_use_declarations '}' + { $$ = zend_ast_create(ZEND_AST_GROUP_USE, $1, $4);} + | T_NS_SEPARATOR namespace_name T_NS_SEPARATOR '{' inline_use_declarations '}' + { $$ = zend_ast_create(ZEND_AST_GROUP_USE, $2, $5); } ; inline_use_declarations:

« previous php.cvs (#88673) next »