]> granicus.if.org Git - php/commitdiff
fix compilation warnings, rename batch_use to group_use
authorMárcio Almada <marcio3w@gmail.com>
Sat, 7 Mar 2015 20:59:20 +0000 (17:59 -0300)
committerMárcio Almada <marcio3w@gmail.com>
Sun, 8 Mar 2015 15:50:57 +0000 (12:50 -0300)
Zend/tests/ns_088.phpt
Zend/tests/ns_089.phpt
Zend/tests/ns_090.phpt
Zend/tests/ns_091.phpt
Zend/tests/ns_092.phpt
Zend/tests/ns_093.phpt
Zend/tests/ns_094.phpt [new file with mode: 0644]
Zend/zend_ast.h
Zend/zend_compile.c
Zend/zend_language_parser.y

index 484fae38dfc2fffa649e3b626dce45ae84ed2de6..7af8dcc8d3d252460721cefbe7740d06be521b78 100644 (file)
@@ -1,5 +1,5 @@
 --TEST--
-Nested batch use statements syntax error
+Nested group use statements syntax error
 --FILE--
 <?php
 namespace Fiz\Biz\Buz {
index 81c4c02db94b72cd829a747e851411aa0658e1b1..c752eafb3436ae790d0b74ec6103aada5fbc3134 100644 (file)
@@ -1,5 +1,5 @@
 --TEST--
-Batch use statements
+Group use statements
 --FILE--
 <?php
 namespace Foo\Bar\Baz {
index 73c859544cd5103e12821380d6884022f0d25441..608d3fcf8e811e822dda7d4a968244947770e2e4 100644 (file)
@@ -1,5 +1,5 @@
 --TEST--
-Batch use statements declared inline
+Group use statements declared inline
 --FILE--
 <?php
 namespace Foo\Bar\Baz {
index 8d93dd789efefeb378e10ecd858814569c790c48..b7eadeb10d0225623aba27c2caa762b2e94df528 100644 (file)
@@ -1,5 +1,5 @@
 --TEST--
-Batch use statements with compound namespaces
+Group use statements with compound namespaces
 --FILE--
 <?php
 namespace Foo\Bar {
index c69ada91e235dbc3acb24a2a7f3569abe773f404..a5d1bcb6e99b53139d89c83a60ef53a21935c24d 100644 (file)
@@ -1,5 +1,5 @@
 --TEST--
-Typed batch use statements
+Typed group use statements
 --FILE--
 <?php
 namespace Foo\Bar {
index cc82bd48855e622bf7c7ea71f0953be1f0e336f6..e0b3e6a1d17f48bc4ad21a88c577ad0609b1eb3a 100644 (file)
@@ -1,5 +1,5 @@
 --TEST--
-Batch use declarations and whitespace nuances
+Group use declarations and whitespace nuances
 --FILE--
 <?php
 
diff --git a/Zend/tests/ns_094.phpt b/Zend/tests/ns_094.phpt
new file mode 100644 (file)
index 0000000..792b2eb
--- /dev/null
@@ -0,0 +1,16 @@
+--TEST--
+Type group use declarations should not allow override on inner itens
+--FILE--
+<?php
+
+// should not throw syntax errors
+
+use const Foo\Bar\{
+    A,
+    const B,
+    function C
+};
+
+--EXPECTF--
+
+Parse error: syntax error, unexpected 'const' (T_CONST), expecting identifier (T_STRING) or \\ (T_NS_SEPARATOR) in %s on line 7
index 854576df0c706d67a57e1731e9ba4c1cbc1e0695..8cd06419bee5c5595847d8050712b245baa16e05 100644 (file)
@@ -132,7 +132,7 @@ enum _zend_ast_kind {
        ZEND_AST_NAMESPACE,
        ZEND_AST_USE_ELEM,
        ZEND_AST_TRAIT_ALIAS,
-       ZEND_AST_BATCH_USE,
+       ZEND_AST_GROUP_USE,
 
        /* 3 child nodes */
        ZEND_AST_METHOD_CALL = 3 << ZEND_AST_NUM_CHILDREN_SHIFT,
index c32e7cb1938c0f37224ebbdc4a1e1f281ae16985..4e35fbfea3272fd4e6a63f9162f9afcd744d5fe4 100644 (file)
@@ -4935,26 +4935,6 @@ static void zend_check_already_in_use(uint32_t type, zend_string *old_name, zend
 }
 /* }}} */
 
-void zend_compile_batch_use(zend_ast *ast) /* {{{ */
-{
-       zend_string *ns = zend_ast_get_str(ast->child[0]);
-       zend_ast_list *list = zend_ast_get_list(ast->child[1]);
-       uint32_t i;
-
-       for (i = 0; i < list->children; i++) {
-               zend_ast *use = list->child[i];
-               zval *name_zval = zend_ast_get_zval(use->child[0]);
-               zend_string *name = Z_STR_P(name_zval);
-               zend_string *compound_ns = zend_concat_names(ns->val, ns->len, name->val, name->len);
-               zend_string_release(name);
-               ZVAL_STR(name_zval, compound_ns);
-               zend_ast_list *inline_use = zend_ast_create_list(1, ZEND_AST_USE, use);
-               inline_use->attr = ast->attr ? ast->attr : use->attr;
-               zend_compile_use(inline_use);
-       }
-}
-/* }}} */
-
 void zend_compile_use(zend_ast *ast) /* {{{ */
 {
        zend_ast_list *list = zend_ast_get_list(ast);
@@ -5064,6 +5044,27 @@ void zend_compile_use(zend_ast *ast) /* {{{ */
 }
 /* }}} */
 
+void zend_compile_group_use(zend_ast *ast) /* {{{ */
+{
+       zend_string *ns = zend_ast_get_str(ast->child[0]);
+       zend_ast_list *list = zend_ast_get_list(ast->child[1]);
+       uint32_t i;
+
+       for (i = 0; i < list->children; i++) {
+               zend_ast *use = list->child[i];
+               zval *name_zval = zend_ast_get_zval(use->child[0]);
+               zend_string *name = Z_STR_P(name_zval);
+               zend_string *compound_ns = zend_concat_names(ns->val, ns->len, name->val, name->len);
+               zend_string_release(name);
+               ZVAL_STR(name_zval, compound_ns);
+               zend_ast *inline_use = zend_ast_create_list(1, ZEND_AST_USE, use);
+               inline_use->attr = ast->attr ? ast->attr : use->attr;
+               zend_compile_use(inline_use);
+       }
+}
+/* }}} */
+
+
 void zend_compile_const_decl(zend_ast *ast) /* {{{ */
 {
        zend_ast_list *list = zend_ast_get_list(ast);
@@ -6459,8 +6460,8 @@ void zend_compile_stmt(zend_ast *ast) /* {{{ */
                case ZEND_AST_CLASS:
                        zend_compile_class_decl(ast);
                        break;
-               case ZEND_AST_BATCH_USE:
-                       zend_compile_batch_use(ast);
+               case ZEND_AST_GROUP_USE:
+                       zend_compile_group_use(ast);
                        break;
                case ZEND_AST_USE:
                        zend_compile_use(ast);
index a9a93b86a696e8aa5c6459b648d2d6a18a3c7e89..69544ecf04d489282afbb5b84419d7c42851f150 100644 (file)
@@ -229,8 +229,8 @@ static YYSIZE_T zend_yytnamerr(char*, const char*);
 %type <ast> top_statement namespace_name name statement function_declaration_statement
 %type <ast> class_declaration_statement trait_declaration_statement
 %type <ast> interface_declaration_statement interface_extends_list
-%type <ast> batch_use_declarations inline_use_declarations inline_use_declaration
-%type <ast> mixed_batch_use_declarations use_declaration const_decl inner_statement
+%type <ast> group_use_declaration inline_use_declarations inline_use_declaration
+%type <ast> mixed_group_use_declaration use_declaration const_decl inner_statement
 %type <ast> expr optional_expr while_statement for_statement foreach_variable
 %type <ast> foreach_statement declare_statement finally_statement unset_variable variable
 %type <ast> extends_from parameter optional_type argument expr_without_variable global_var
@@ -253,7 +253,7 @@ static YYSIZE_T zend_yytnamerr(char*, const char*);
 
 %type <num> returns_ref function is_reference is_variadic variable_modifiers
 %type <num> method_modifiers trait_modifiers non_empty_member_modifiers member_modifier
-%type <num> class_modifiers class_modifier
+%type <num> class_modifiers class_modifier use_type
 
 %type <str> backup_doc_comment
 
@@ -298,23 +298,29 @@ top_statement:
        |       T_NAMESPACE { RESET_DOC_COMMENT(); }
                '{' top_statement_list '}'
                        { $$ = zend_ast_create(ZEND_AST_NAMESPACE, NULL, $4); }
-       |       T_USE mixed_batch_use_declarations ';'          { $$ = $2; }
-       |       T_USE T_FUNCTION batch_use_declarations ';'     { $$ = $3; $3->attr = T_FUNCTION; }
-       |       T_USE T_CONST batch_use_declarations ';'        { $$ = $3; $3->attr = T_CONST; }
+       |       T_USE mixed_group_use_declaration ';'           { $$ = $2; }
+       |       T_USE T_FUNCTION group_use_declaration ';'      { $$ = $3; $$->attr = T_FUNCTION; }
+       |       T_USE T_CONST group_use_declaration ';'         { $$ = $3; $$->attr = T_CONST; }
        |       T_USE use_declarations ';'                                      { $$ = $2; $$->attr = T_CLASS; }
        |       T_USE T_FUNCTION use_declarations ';'           { $$ = $3; $$->attr = T_FUNCTION; }
        |       T_USE T_CONST use_declarations ';'                      { $$ = $3; $$->attr = T_CONST; }
        |       T_CONST const_list ';'                                          { $$ = $2; }
 ;
 
-batch_use_declarations:
+use_type:
+               /* empty */             { $$ = T_CLASS; }
+       |       T_FUNCTION              { $$ = T_FUNCTION; }
+       |       T_CONST                 { $$ = T_CONST; }
+;
+
+group_use_declaration:
        namespace_name T_NS_SEPARATOR '{' use_declarations '}'
-               {$$ = zend_ast_create(ZEND_AST_BATCH_USE, $1, $4); }
+               {$$ = zend_ast_create(ZEND_AST_GROUP_USE, $1, $4); }
 ;
 
-mixed_batch_use_declarations:
+mixed_group_use_declaration:
        namespace_name T_NS_SEPARATOR '{' inline_use_declarations '}'
-               {$$ = zend_ast_create(ZEND_AST_BATCH_USE, $1, $4);}
+               {$$ = zend_ast_create(ZEND_AST_GROUP_USE, $1, $4);}
 ;
 
 inline_use_declarations:
@@ -325,12 +331,7 @@ inline_use_declarations:
 ;
 
 inline_use_declaration:
-               use_declaration
-                       { $$ = $1; $$->attr = T_CLASS; }
-       |       T_FUNCTION use_declaration
-                       { $$ = $2; $$->attr = T_FUNCTION; }
-       |       T_CONST use_declaration
-                       { $$ = $2; $$->attr = T_CONST; }
+       use_type use_declaration { $$ = $2; $$->attr = $1; }
 ;
 
 use_declarations: