]> granicus.if.org Git - php/commitdiff
allow aggregating use statements
authorStanislav Malyshev <stas@php.net>
Sun, 8 Jun 2008 09:38:47 +0000 (09:38 +0000)
committerStanislav Malyshev <stas@php.net>
Sun, 8 Jun 2008 09:38:47 +0000 (09:38 +0000)
Zend/tests/ns_065.inc [new file with mode: 0755]
Zend/tests/ns_065.phpt [new file with mode: 0755]
Zend/zend_language_parser.y

diff --git a/Zend/tests/ns_065.inc b/Zend/tests/ns_065.inc
new file mode 100755 (executable)
index 0000000..a625a4a
--- /dev/null
@@ -0,0 +1,9 @@
+<?php
+namespace X::Y;
+function foo() {
+       echo __FUNCTION__."\n";
+}
+namespace X::Z;
+function foo() {
+       echo __FUNCTION__."\n";
+}
diff --git a/Zend/tests/ns_065.phpt b/Zend/tests/ns_065.phpt
new file mode 100755 (executable)
index 0000000..8d7e7fb
--- /dev/null
@@ -0,0 +1,13 @@
+--TEST--
+065: Multiple names in use statement
+--FILE--
+<?php
+use X::Y as test, X::Z as test2;
+
+require "ns_065.inc";
+
+test::foo();
+test2::foo();
+--EXPECT--
+X::Y::foo
+X::Z::foo
index fbe941937cbd9ee6e10edad4efe3f9df0fe10625..1fc365cfb7cdde94c59a43a5b83d0a15af09cc25 100644 (file)
@@ -172,13 +172,21 @@ top_statement:
        |       class_declaration_statement             { zend_do_early_binding(TSRMLS_C); }
        |       T_HALT_COMPILER '(' ')' ';'             { zend_do_halt_compiler_register(TSRMLS_C); YYACCEPT; }
        |       T_NAMESPACE namespace_name ';'  { zend_do_namespace(&$2 TSRMLS_CC); }
-       |       T_USE namespace_name ';'                { zend_do_use(&$2, NULL, 0 TSRMLS_CC); }
-       |       T_USE namespace_name T_AS T_STRING ';'  { zend_do_use(&$2, &$4, 0 TSRMLS_CC); }
-       |       T_USE T_PAAMAYIM_NEKUDOTAYIM T_STRING ';'               { zend_do_use(&$3, NULL, 1 TSRMLS_CC); }
-       |       T_USE T_PAAMAYIM_NEKUDOTAYIM T_STRING T_AS T_STRING ';'         { zend_do_use(&$3, &$5, 1 TSRMLS_CC); }
+       |       T_USE use_declarations ';'
        |       constant_declaration ';'
 ;
 
+use_declarations:
+               use_declarations ',' use_declaration
+       |       use_declaration
+
+use_declaration:
+               namespace_name                  { zend_do_use(&$1, NULL, 0 TSRMLS_CC); }
+       |       namespace_name T_AS T_STRING    { zend_do_use(&$1, &$3, 0 TSRMLS_CC); }
+       |       T_PAAMAYIM_NEKUDOTAYIM T_STRING { zend_do_use(&$2, NULL, 1 TSRMLS_CC); }
+       |       T_PAAMAYIM_NEKUDOTAYIM T_STRING T_AS T_STRING { zend_do_use(&$2, &$4, 1 TSRMLS_CC); }
+
+
 constant_declaration:
                constant_declaration ',' T_STRING '=' static_scalar     { zend_do_declare_constant(&$3, &$5 TSRMLS_CC); }
        |       T_CONST T_STRING '=' static_scalar { zend_do_declare_constant(&$2, &$4 TSRMLS_CC); }