]> granicus.if.org Git - php/commitdiff
Fix bug #66015 by reverting "Removed operations on constant arrays."
authorBob Weinand <bobwei9@hotmail.com>
Fri, 11 Apr 2014 08:06:17 +0000 (10:06 +0200)
committerBob Weinand <bobwei9@hotmail.com>
Fri, 11 Apr 2014 08:08:44 +0000 (10:08 +0200)
21 files changed:
Zend/tests/bug66015.phpt [new file with mode: 0644]
Zend/tests/errmsg_040.phpt
Zend/tests/ns_059.phpt
Zend/zend.h
Zend/zend_API.c
Zend/zend_ast.c
Zend/zend_ast.h
Zend/zend_compile.c
Zend/zend_compile.h
Zend/zend_execute_API.c
Zend/zend_language_parser.y
Zend/zend_variables.c
Zend/zend_vm_def.h
ext/com_dotnet/com_variant.c
ext/opcache/ZendAccelerator.c
ext/opcache/zend_accelerator_util_funcs.c
ext/opcache/zend_persist.c
ext/opcache/zend_persist_calc.c
ext/pgsql/pgsql.c
ext/soap/php_encoding.c
ext/xmlrpc/xmlrpc-epi-php.c

diff --git a/Zend/tests/bug66015.phpt b/Zend/tests/bug66015.phpt
new file mode 100644 (file)
index 0000000..f1cbd37
--- /dev/null
@@ -0,0 +1,32 @@
+--TEST--
+Bug #66015 (wrong array indexing in class's static property)
+--FILE--
+<?php
+class Test
+{
+   const FIRST = 1;
+   const SECOND = 2;
+   const THIRD = 3;
+
+   protected static $array = [
+       self::FIRST => 'first',
+       'second',
+       'third'
+   ];
+
+   public function __construct()
+   {
+       var_export(self::$array);
+   }
+}
+
+$test = new Test();
+?>
+===DONE===
+--EXPECTF--
+array (
+  1 => 'first',
+  2 => 'second',
+  3 => 'third',
+)
+===DONE===
index f3d0afcf0a32e331e6d0f3dab9038b75d1cb016f..2b192d0b83f2ea326b06390e941f426627196a03 100644 (file)
@@ -1,5 +1,7 @@
 --TEST--
 errmsg: arrays are not allowed in class constants
+--XFAIL--
+Actually it's hard to test where the array comes from (property, constant, ...)
 --FILE--
 <?php
 
index ea66037b433a9d49bc11318d9d59c599dff3873e..b9fcfee5c02e262099c23aaa3cefbb6c357df9ef 100644 (file)
@@ -1,5 +1,7 @@
 --TEST--
 059: Constant arrays
+--XFAIL--
+Actually it's hard to test where the array comes from (property, constant, ...)
 --FILE--
 <?php
 const C = array();
index 82e81370e86f6caa6d3ba3bf72328a3f435a625b..9e79833cd729a06d558edc9a57ceb81a2a6c6cb3 100644 (file)
@@ -589,14 +589,11 @@ typedef int (*zend_write_func_t)(const char *str, uint str_length);
 #define IS_STRING      6
 #define IS_RESOURCE    7
 #define IS_CONSTANT    8
-#define IS_CONSTANT_ARRAY      9
-#define IS_CONSTANT_AST                10
-#define IS_CALLABLE    11
+#define IS_CONSTANT_AST        9
+#define IS_CALLABLE    10
 
-/* Ugly hack to support constants as static array indices */
 #define IS_CONSTANT_TYPE_MASK          0x00f
 #define IS_CONSTANT_UNQUALIFIED                0x010
-#define IS_CONSTANT_INDEX                      0x080
 #define IS_LEXICAL_VAR                         0x020
 #define IS_LEXICAL_REF                         0x040
 #define IS_CONSTANT_IN_NAMESPACE       0x100
index ed13c6a7d6031bee871ac4608f7e3714efbbdda1..106799cd8210ace3e728a5870b689408794d7310 100644 (file)
@@ -3463,7 +3463,6 @@ ZEND_API int zend_declare_property_ex(zend_class_entry *ce, const char *name, in
        if (ce->type & ZEND_INTERNAL_CLASS) {
                switch(Z_TYPE_P(property)) {
                        case IS_ARRAY:
-                       case IS_CONSTANT_ARRAY:
                        case IS_OBJECT:
                        case IS_RESOURCE:
                                zend_error(E_CORE_ERROR, "Internal zval's can't be arrays, objects or resources");
index 9a0808db9d8390a6af4a4a0bb7ebac3178ed9947..8a3df98c1055602202f75cd9d3408c666d62174b 100644 (file)
@@ -63,6 +63,27 @@ ZEND_API zend_ast* zend_ast_create_ternary(uint kind, zend_ast *op0, zend_ast *o
        return ast;
 }
 
+ZEND_API zend_ast* zend_ast_create_dynamic(uint kind)
+{
+       zend_ast *ast = emalloc(sizeof(zend_ast) + sizeof(zend_ast*) * 3); /* use 4 children as deafult */
+       ast->kind = kind;
+       ast->children = 0;
+       return ast;
+}
+
+ZEND_API void zend_ast_dynamic_add(zend_ast **ast, zend_ast *op)
+{
+       if ((*ast)->children >= 4 && (*ast)->children == ((*ast)->children & -(*ast)->children)) {
+               *ast = erealloc(*ast, sizeof(zend_ast) + sizeof(zend_ast*) * ((*ast)->children * 2 + 1));
+       }
+       (&(*ast)->u.child)[(*ast)->children++] = op;
+}
+
+ZEND_API void zend_ast_dynamic_shrink(zend_ast **ast)
+{
+       *ast = erealloc(*ast, sizeof(zend_ast) + sizeof(zend_ast*) * ((*ast)->children - 1));
+}
+
 ZEND_API int zend_ast_is_ct_constant(zend_ast *ast)
 {
        int i;
@@ -284,6 +305,23 @@ ZEND_API void zend_ast_evaluate(zval *result, zend_ast *ast, zend_class_entry *s
                        sub_function(result, &op1, &op2 TSRMLS_CC);
                        zval_dtor(&op2);
                        break;
+               case ZEND_INIT_ARRAY:
+                       INIT_PZVAL(result);
+                       array_init(result);
+                       {
+                               int i;
+                               zend_bool has_key;
+                               for (i = 0; i < ast->children; i+=2) {
+                                       zval *expr;
+                                       MAKE_STD_ZVAL(expr);
+                                       if ((has_key = !!(&ast->u.child)[i])) {
+                                               zend_ast_evaluate(&op1, (&ast->u.child)[i], scope TSRMLS_CC);
+                                       }
+                                       zend_ast_evaluate(expr, (&ast->u.child)[i+1], scope TSRMLS_CC);
+                                       zend_do_add_static_array_element(result, has_key?&op1:NULL, expr);
+                               }
+                       }
+                       break;
                default:
                        zend_error(E_ERROR, "Unsupported constant expression");
        }
@@ -297,26 +335,15 @@ ZEND_API zend_ast *zend_ast_copy(zend_ast *ast)
                zend_ast *copy = zend_ast_create_constant(ast->u.val);
                zval_copy_ctor(copy->u.val);
                return copy;
-       } else {
-               switch (ast->children) {
-                       case 1:
-                               return zend_ast_create_unary(
-                                       ast->kind,
-                                       zend_ast_copy((&ast->u.child)[0]));
-                       case 2:
-                               return zend_ast_create_binary(
-                                       ast->kind,
-                                       zend_ast_copy((&ast->u.child)[0]),
-                                       zend_ast_copy((&ast->u.child)[1]));
-                       case 3:
-                               return zend_ast_create_ternary(
-                                       ast->kind,
-                                       zend_ast_copy((&ast->u.child)[0]),
-                                       zend_ast_copy((&ast->u.child)[1]),
-                                       zend_ast_copy((&ast->u.child)[2]));
+       } else if (ast->children) {
+               zend_ast *new = emalloc(sizeof(zend_ast) + sizeof(zend_ast*) * (ast->children - 1));
+               int i;
+               new->kind = ast->kind;
+               for (i = 0; i < ast->children; i++) {
+                       (&new->u.child)[i] = zend_ast_copy((&ast->u.child)[i]);
                }
        }
-       return NULL;
+       return zend_ast_create_dynamic(ast->kind);
 }
 
 ZEND_API void zend_ast_destroy(zend_ast *ast)
index 927e99cff87959c02c12c655f04ca5d0849fdc87..f8df15c95b730dbc1888c9f375aa54e8742b8825 100644 (file)
@@ -50,6 +50,9 @@ ZEND_API zend_ast *zend_ast_create_constant(zval *zv);
 ZEND_API zend_ast *zend_ast_create_unary(uint kind, zend_ast *op0);
 ZEND_API zend_ast *zend_ast_create_binary(uint kind, zend_ast *op0, zend_ast *op1);
 ZEND_API zend_ast *zend_ast_create_ternary(uint kind, zend_ast *op0, zend_ast *op1, zend_ast *op2);
+ZEND_API zend_ast* zend_ast_create_dynamic(uint kind);
+ZEND_API void zend_ast_dynamic_add(zend_ast **ast, zend_ast *op);
+ZEND_API void zend_ast_dynamic_shrink(zend_ast **ast);
 
 ZEND_API int zend_ast_is_ct_constant(zend_ast *ast);
 
index 1bcd430840b8a0416fbe1039d655c4d06b3479eb..099120ae83719ef2b177b0f04368ffb71d80754a 100644 (file)
@@ -1933,7 +1933,7 @@ void zend_do_receive_param(zend_uchar op, znode *varname, const znode *initializ
                                if (op == ZEND_RECV_INIT) {
                                        if (Z_TYPE(initialization->u.constant) == IS_NULL || (Z_TYPE(initialization->u.constant) == IS_CONSTANT && !strcasecmp(Z_STRVAL(initialization->u.constant), "NULL")) || Z_TYPE(initialization->u.constant) == IS_CONSTANT_AST) {
                                                cur_arg_info->allow_null = 1;
-                                       } else if (Z_TYPE(initialization->u.constant) != IS_ARRAY && Z_TYPE(initialization->u.constant) != IS_CONSTANT_ARRAY) {
+                                       } else if (Z_TYPE(initialization->u.constant) != IS_ARRAY) {
                                                zend_error_noreturn(E_COMPILE_ERROR, "Default value for parameters with array type hint can only be an array or NULL");
                                        }
                                }
@@ -5442,10 +5442,6 @@ void zend_do_declare_class_constant(znode *var_name, const znode *value TSRMLS_D
        const char *cname = NULL;
        zend_ulong hash;
 
-       if(Z_TYPE(value->u.constant) == IS_CONSTANT_ARRAY) {
-               zend_error_noreturn(E_COMPILE_ERROR, "Arrays are not allowed in class constants");
-               return;
-       }
        if ((CG(active_class_entry)->ce_flags & ZEND_ACC_TRAIT) == ZEND_ACC_TRAIT) {
                zend_error_noreturn(E_COMPILE_ERROR, "Traits cannot have constants");
                return;
@@ -5887,57 +5883,30 @@ void zend_do_add_array_element(znode *result, const znode *expr, const znode *of
 }
 /* }}} */
 
-void zend_do_add_static_array_element(znode *result, znode *offset, const znode *expr) /* {{{ */
+void zend_do_add_static_array_element(zval *result, zval *offset, const zval *expr) /* {{{ */
 {
-       zval *element;
-
-       ALLOC_ZVAL(element);
-       *element = expr->u.constant;
        if (offset) {
-               switch (Z_TYPE(offset->u.constant) & IS_CONSTANT_TYPE_MASK) {
-                       case IS_CONSTANT:
-                               /* Ugly hack to denote that this value has a constant index */
-                               Z_TYPE_P(element) |= IS_CONSTANT_INDEX;
-                               Z_STRVAL(offset->u.constant) = erealloc(Z_STRVAL(offset->u.constant), Z_STRLEN(offset->u.constant)+3);
-                               Z_STRVAL(offset->u.constant)[Z_STRLEN(offset->u.constant)+1] = Z_TYPE(offset->u.constant);
-                               Z_STRVAL(offset->u.constant)[Z_STRLEN(offset->u.constant)+2] = 0;
-                               zend_symtable_update(Z_ARRVAL(result->u.constant), Z_STRVAL(offset->u.constant), Z_STRLEN(offset->u.constant)+3, &element, sizeof(zval *), NULL);
-                               zval_dtor(&offset->u.constant);
-                               break;
-                       case IS_CONSTANT_AST: {
-                               /* Another ugly hack to store the data about the AST in the array */
-                               char* key;
-                               int len = sizeof(zend_ast *);
-                               Z_TYPE_P(element) |= IS_CONSTANT_INDEX;
-
-                               key = emalloc(len + 2);
-                               *(zend_ast **)key = Z_AST(offset->u.constant);
-                               key[len] = Z_TYPE(offset->u.constant);
-                               key[len + 1] = 0;
-                               zend_symtable_update(Z_ARRVAL(result->u.constant), key, len + 2, &element, sizeof(zval *), NULL);
-                               efree(key);
-                               break;
-                       }
+               switch (Z_TYPE_P(offset)) {
                        case IS_STRING:
-                               zend_symtable_update(Z_ARRVAL(result->u.constant), Z_STRVAL(offset->u.constant), Z_STRLEN(offset->u.constant)+1, &element, sizeof(zval *), NULL);
-                               zval_dtor(&offset->u.constant);
+                               zend_symtable_update(Z_ARRVAL_P(result), Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, &expr, sizeof(zval *), NULL);
+                               zval_dtor(offset);
                                break;
                        case IS_NULL:
-                               zend_symtable_update(Z_ARRVAL(result->u.constant), "", 1, &element, sizeof(zval *), NULL);
+                               zend_symtable_update(Z_ARRVAL_P(result), "", 1, &expr, sizeof(zval *), NULL);
                                break;
                        case IS_LONG:
                        case IS_BOOL:
-                               zend_hash_index_update(Z_ARRVAL(result->u.constant), Z_LVAL(offset->u.constant), &element, sizeof(zval *), NULL);
+                               zend_hash_index_update(Z_ARRVAL_P(result), Z_LVAL_P(offset), &expr, sizeof(zval *), NULL);
                                break;
                        case IS_DOUBLE:
-                               zend_hash_index_update(Z_ARRVAL(result->u.constant), zend_dval_to_lval(Z_DVAL(offset->u.constant)), &element, sizeof(zval *), NULL);
+                               zend_hash_index_update(Z_ARRVAL_P(result), zend_dval_to_lval(Z_DVAL_P(offset)), &expr, sizeof(zval *), NULL);
                                break;
-                       case IS_CONSTANT_ARRAY:
+                       case IS_ARRAY:
                                zend_error(E_ERROR, "Illegal offset type");
                                break;
                }
        } else {
-               zend_hash_next_index_insert(Z_ARRVAL(result->u.constant), &element, sizeof(zval *), NULL);
+               zend_hash_next_index_insert(Z_ARRVAL_P(result), &expr, sizeof(zval *), NULL);
        }
 }
 /* }}} */
@@ -7318,10 +7287,6 @@ void zend_do_declare_constant(znode *name, znode *value TSRMLS_DC) /* {{{ */
        zend_op *opline;
        zval **ns_name;
 
-       if(Z_TYPE(value->u.constant) == IS_CONSTANT_ARRAY) {
-               zend_error_noreturn(E_COMPILE_ERROR, "Arrays are not allowed as constants");
-       }
-
        if (zend_get_ct_const(&name->u.constant, 0 TSRMLS_CC)) {
                zend_error_noreturn(E_COMPILE_ERROR, "Cannot redeclare constant '%s'", Z_STRVAL(name->u.constant));
        }
index 5362058fa266f7c429ef2cef1a8863291cc466cd..99d3704b764ccb51d0b3070d0c2f5a16a7bd72d0 100644 (file)
@@ -598,7 +598,7 @@ void zend_do_shell_exec(znode *result, const znode *cmd TSRMLS_DC);
 
 void zend_do_init_array(znode *result, const znode *expr, const znode *offset, zend_bool is_ref TSRMLS_DC);
 void zend_do_add_array_element(znode *result, const znode *expr, const znode *offset, zend_bool is_ref TSRMLS_DC);
-void zend_do_add_static_array_element(znode *result, znode *offset, const znode *expr);
+void zend_do_add_static_array_element(zval *result, zval *offset, const zval *expr);
 void zend_do_list_init(TSRMLS_D);
 void zend_do_list_end(znode *result, znode *expr TSRMLS_DC);
 void zend_do_add_list_element(const znode *element TSRMLS_DC);
index 5d5153dc13cec63dbe678490cb6ac7f550395da2..692ec83cc39aa124db077e2cfff49725e7269e3e 100644 (file)
@@ -451,24 +451,11 @@ ZEND_API int zend_is_true(zval *op) /* {{{ */
 
 #include "../TSRM/tsrm_strtok_r.h"
 
-#define IS_VISITED_CONSTANT                    IS_CONSTANT_INDEX
+#define IS_VISITED_CONSTANT                    0x80
 #define IS_CONSTANT_VISITED(p)         (Z_TYPE_P(p) & IS_VISITED_CONSTANT)
 #define Z_REAL_TYPE_P(p)                       (Z_TYPE_P(p) & ~IS_VISITED_CONSTANT)
 #define MARK_CONSTANT_VISITED(p)       Z_TYPE_P(p) |= IS_VISITED_CONSTANT
 
-static void zval_deep_copy(zval **p)
-{
-       zval *value;
-
-       ALLOC_ZVAL(value);
-       *value = **p;
-       Z_TYPE_P(value) &= ~IS_CONSTANT_INDEX;
-       zval_copy_ctor(value);
-       Z_TYPE_P(value) = Z_TYPE_PP(p);
-       INIT_PZVAL(value);
-       *p = value;
-}
-
 ZEND_API int zval_update_constant_ex(zval **pp, void *arg, zend_class_entry *scope TSRMLS_DC) /* {{{ */
 {
        zval *p = *pp;
@@ -559,110 +546,6 @@ ZEND_API int zval_update_constant_ex(zval **pp, void *arg, zend_class_entry *sco
 
                Z_SET_REFCOUNT_P(p, refcount);
                Z_SET_ISREF_TO_P(p, is_ref);
-       } else if (Z_TYPE_P(p) == IS_CONSTANT_ARRAY) {
-               zval **element, *new_val;
-               char *str_index;
-               uint str_index_len;
-               ulong num_index;
-               int ret;
-
-               SEPARATE_ZVAL_IF_NOT_REF(pp);
-               p = *pp;
-               Z_TYPE_P(p) = IS_ARRAY;
-
-               if (!inline_change) {
-                       zval *tmp;
-                       HashTable *tmp_ht = NULL;
-
-                       ALLOC_HASHTABLE(tmp_ht);
-                       zend_hash_init(tmp_ht, zend_hash_num_elements(Z_ARRVAL_P(p)), NULL, ZVAL_PTR_DTOR, 0);
-                       zend_hash_copy(tmp_ht, Z_ARRVAL_P(p), (copy_ctor_func_t) zval_deep_copy, (void *) &tmp, sizeof(zval *));
-                       Z_ARRVAL_P(p) = tmp_ht;
-               }
-
-               /* First go over the array and see if there are any constant indices */
-               zend_hash_internal_pointer_reset(Z_ARRVAL_P(p));
-               while (zend_hash_get_current_data(Z_ARRVAL_P(p), (void **) &element) == SUCCESS) {
-                       if (!(Z_TYPE_PP(element) & IS_CONSTANT_INDEX)) {
-                               zend_hash_move_forward(Z_ARRVAL_P(p));
-                               continue;
-                       }
-                       Z_TYPE_PP(element) &= ~IS_CONSTANT_INDEX;
-                       if (zend_hash_get_current_key_ex(Z_ARRVAL_P(p), &str_index, &str_index_len, &num_index, 0, NULL) != HASH_KEY_IS_STRING) {
-                               zend_hash_move_forward(Z_ARRVAL_P(p));
-                               continue;
-                       }
-                       if (str_index[str_index_len - 2] == IS_CONSTANT_AST) {
-                               zend_ast_evaluate(&const_value, *(zend_ast **)str_index, scope TSRMLS_CC);
-                               zend_ast_destroy(*(zend_ast **)str_index);
-                       } else if (!zend_get_constant_ex(str_index, str_index_len - 3, &const_value, scope, str_index[str_index_len - 2] TSRMLS_CC)) {
-                               char *actual;
-                               const char *save = str_index;
-                               if ((colon = (char*)zend_memrchr(str_index, ':', str_index_len - 3))) {
-                                       zend_error(E_ERROR, "Undefined class constant '%s'", str_index);
-                                       str_index_len -= ((colon - str_index) + 1);
-                                       str_index = colon;
-                               } else {
-                                       if (str_index[str_index_len - 2] & IS_CONSTANT_UNQUALIFIED) {
-                                               if ((actual = (char *)zend_memrchr(str_index, '\\', str_index_len - 3))) {
-                                                       actual++;
-                                                       str_index_len -= (actual - str_index);
-                                                       str_index = actual;
-                                               }
-                                       }
-                                       if (str_index[0] == '\\') {
-                                               ++str_index;
-                                               --str_index_len;
-                                       }
-                                       if (save[0] == '\\') {
-                                               ++save;
-                                       }
-                                       if ((str_index[str_index_len - 2] & IS_CONSTANT_UNQUALIFIED) == 0) {
-                                               zend_error(E_ERROR, "Undefined constant '%s'", save);
-                                       }
-                                       zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'",     str_index, str_index);
-                               }
-                               ZVAL_STRINGL(&const_value, str_index, str_index_len-3, 1);
-                       }
-
-                       if (Z_REFCOUNT_PP(element) > 1) {
-                               ALLOC_ZVAL(new_val);
-                               *new_val = **element;
-                               zval_copy_ctor(new_val);
-                               Z_SET_REFCOUNT_P(new_val, 1);
-                               Z_UNSET_ISREF_P(new_val);
-
-                               /* preserve this bit for inheritance */
-                               Z_TYPE_PP(element) |= IS_CONSTANT_INDEX;
-                               zval_ptr_dtor(element);
-                               *element = new_val;
-                       }
-
-                       switch (Z_TYPE(const_value)) {
-                               case IS_STRING:
-                                       ret = zend_symtable_update_current_key(Z_ARRVAL_P(p), Z_STRVAL(const_value), Z_STRLEN(const_value) + 1, HASH_UPDATE_KEY_IF_BEFORE);
-                                       break;
-                               case IS_BOOL:
-                               case IS_LONG:
-                                       ret = zend_hash_update_current_key_ex(Z_ARRVAL_P(p), HASH_KEY_IS_LONG, NULL, 0, Z_LVAL(const_value), HASH_UPDATE_KEY_IF_BEFORE, NULL);
-                                       break;
-                               case IS_DOUBLE:
-                                       ret = zend_hash_update_current_key_ex(Z_ARRVAL_P(p), HASH_KEY_IS_LONG, NULL, 0, zend_dval_to_lval(Z_DVAL(const_value)), HASH_UPDATE_KEY_IF_BEFORE, NULL);
-                                       break;
-                               case IS_NULL:
-                                       ret = zend_hash_update_current_key_ex(Z_ARRVAL_P(p), HASH_KEY_IS_STRING, "", 1, 0, HASH_UPDATE_KEY_IF_BEFORE, NULL);
-                                       break;
-                               default:
-                                       ret = SUCCESS;
-                                       break;
-                       }
-                       if (ret == SUCCESS) {
-                               zend_hash_move_forward(Z_ARRVAL_P(p));
-                       }
-                       zval_dtor(&const_value);
-               }
-               zend_hash_apply_with_argument(Z_ARRVAL_P(p), (apply_func_arg_t) zval_update_constant_inline_change, (void *) scope TSRMLS_CC);
-               zend_hash_internal_pointer_reset(Z_ARRVAL_P(p));
        } else if (Z_TYPE_P(p) == IS_CONSTANT_AST) {
                SEPARATE_ZVAL_IF_NOT_REF(pp);
                p = *pp;
index b7467b755274c2270af52868967cdf9196e2a1f4..40e5c05bce89ff27c00871eb33e365ef5fac8cc3 100644 (file)
@@ -986,9 +986,7 @@ static_class_constant:
 ;
 
 static_scalar: /* compile-time evaluated scalars */
-               static_scalar_value { zend_do_constant_expression(&$$, $1.u.ast TSRMLS_CC); }
-       |       T_ARRAY '(' static_array_pair_list ')' { $$ = $3; Z_TYPE($$.u.constant) = IS_CONSTANT_ARRAY; }
-       |       '[' static_array_pair_list ']' { $$ = $2; Z_TYPE($$.u.constant) = IS_CONSTANT_ARRAY; }
+       static_scalar_value { zend_do_constant_expression(&$$, $1.u.ast TSRMLS_CC); }
 ;
 
 static_scalar_value:
@@ -997,6 +995,8 @@ static_scalar_value:
        |       namespace_name          { zend_do_fetch_constant(&$$, NULL, &$1, ZEND_CT, 1 TSRMLS_CC); $$.u.ast = zend_ast_create_constant(&$$.u.constant); }
        |       T_NAMESPACE T_NS_SEPARATOR namespace_name { $$.op_type = IS_CONST; ZVAL_EMPTY_STRING(&$$.u.constant);  zend_do_build_namespace_name(&$$, &$$, &$3 TSRMLS_CC); $3 = $$; zend_do_fetch_constant(&$$, NULL, &$3, ZEND_CT, 0 TSRMLS_CC); $$.u.ast = zend_ast_create_constant(&$$.u.constant); }
        |       T_NS_SEPARATOR namespace_name { char *tmp = estrndup(Z_STRVAL($2.u.constant), Z_STRLEN($2.u.constant)+1); memcpy(&(tmp[1]), Z_STRVAL($2.u.constant), Z_STRLEN($2.u.constant)+1); tmp[0] = '\\'; efree(Z_STRVAL($2.u.constant)); Z_STRVAL($2.u.constant) = tmp; ++Z_STRLEN($2.u.constant); zend_do_fetch_constant(&$$, NULL, &$2, ZEND_CT, 0 TSRMLS_CC); $$.u.ast = zend_ast_create_constant(&$$.u.constant); }
+       |       T_ARRAY '(' static_array_pair_list ')' { $$ = $3; }
+       |       '[' static_array_pair_list ']' { $$ = $2; }
        |       static_class_constant { $$.u.ast = zend_ast_create_constant(&$1.u.constant); }
        |       T_CLASS_C                       { $$.u.ast = zend_ast_create_constant(&$1.u.constant); }
        |       static_operation { $$ = $1; }
@@ -1053,8 +1053,8 @@ scalar:
 
 
 static_array_pair_list:
-               /* empty */ { $$.op_type = IS_CONST; INIT_PZVAL(&$$.u.constant); array_init(&$$.u.constant); }
-       |       non_empty_static_array_pair_list possible_comma { $$ = $1; }
+               /* empty */ { $$.op_type = IS_CONST; INIT_PZVAL(&$$.u.constant); array_init(&$$.u.constant); $$.u.ast = zend_ast_create_constant(&$$.u.constant); }
+       |       non_empty_static_array_pair_list possible_comma { zend_ast_dynamic_shrink(&$1.u.ast); $$ = $1; }
 ;
 
 possible_comma:
@@ -1063,10 +1063,10 @@ possible_comma:
 ;
 
 non_empty_static_array_pair_list:
-               non_empty_static_array_pair_list ',' static_scalar T_DOUBLE_ARROW static_scalar { zend_do_add_static_array_element(&$$, &$3, &$5); }
-       |       non_empty_static_array_pair_list ',' static_scalar { zend_do_add_static_array_element(&$$, NULL, &$3); }
-       |       static_scalar T_DOUBLE_ARROW static_scalar { $$.op_type = IS_CONST; INIT_PZVAL(&$$.u.constant); array_init(&$$.u.constant); zend_do_add_static_array_element(&$$, &$1, &$3); }
-       |       static_scalar { $$.op_type = IS_CONST; INIT_PZVAL(&$$.u.constant); array_init(&$$.u.constant); zend_do_add_static_array_element(&$$, NULL, &$1); }
+               non_empty_static_array_pair_list ',' static_scalar_value T_DOUBLE_ARROW static_scalar_value { zend_ast_dynamic_add(&$$.u.ast, $3.u.ast); zend_ast_dynamic_add(&$$.u.ast, $5.u.ast); }
+       |       non_empty_static_array_pair_list ',' static_scalar_value { zend_ast_dynamic_add(&$$.u.ast, NULL); zend_ast_dynamic_add(&$$.u.ast, $3.u.ast); }
+       |       static_scalar_value T_DOUBLE_ARROW static_scalar_value { $$.u.ast = zend_ast_create_dynamic(ZEND_INIT_ARRAY); zend_ast_dynamic_add(&$$.u.ast, $1.u.ast); zend_ast_dynamic_add(&$$.u.ast, $3.u.ast); }
+       |       static_scalar_value { $$.u.ast = zend_ast_create_dynamic(ZEND_INIT_ARRAY); zend_ast_dynamic_add(&$$.u.ast, NULL); zend_ast_dynamic_add(&$$.u.ast, $1.u.ast); }
 ;
 
 expr:
index a18591fdf7d2303b6901ebd0156412a0fa8d2dc8..0f9e184b7e857936e22e8d2edca04d84c74ab2b3 100644 (file)
@@ -36,8 +36,7 @@ ZEND_API void _zval_dtor_func(zval *zvalue ZEND_FILE_LINE_DC)
                        CHECK_ZVAL_STRING_REL(zvalue);
                        str_efree_rel(zvalue->value.str.val);
                        break;
-               case IS_ARRAY:
-               case IS_CONSTANT_ARRAY: {
+               case IS_ARRAY: {
                                TSRMLS_FETCH();
 
                                if (zvalue->value.ht && (zvalue->value.ht != &EG(symbol_table))) {
@@ -86,7 +85,6 @@ ZEND_API void _zval_internal_dtor(zval *zvalue ZEND_FILE_LINE_DC)
                        str_free(zvalue->value.str.val);
                        break;
                case IS_ARRAY:
-               case IS_CONSTANT_ARRAY:
                case IS_CONSTANT_AST:
                case IS_OBJECT:
                case IS_RESOURCE:
@@ -128,8 +126,7 @@ ZEND_API void _zval_copy_ctor_func(zval *zvalue ZEND_FILE_LINE_DC)
                                zvalue->value.str.val = (char *) estrndup_rel(zvalue->value.str.val, zvalue->value.str.len);
                        }
                        break;
-               case IS_ARRAY:
-               case IS_CONSTANT_ARRAY: {
+               case IS_ARRAY: {
                                zval *tmp;
                                HashTable *original_ht = zvalue->value.ht;
                                HashTable *tmp_ht = NULL;
index ed353edbac3db45642f8f5e04149f02b518593c4..08eb471d49d14b8ef83d271a628bc99b42caf0c1 100644 (file)
@@ -5376,9 +5376,6 @@ ZEND_VM_HANDLER(143, ZEND_DECLARE_CONST, CONST, CONST)
                zval *tmp_ptr = &tmp;
 
                ZVAL_COPY_VALUE(&tmp, val);
-               if (Z_TYPE_P(val) == IS_CONSTANT_ARRAY) {
-                       zval_copy_ctor(&tmp);
-               }
                INIT_PZVAL(&tmp);
                zval_update_constant(&tmp_ptr, NULL TSRMLS_CC);
                c.value = *tmp_ptr;
index 4e044b20b8817b5e3289c3566634d0c9ba1a194a..3ddf016efbf52955da65cf59be1e3a2942aaa8e9 100644 (file)
@@ -160,7 +160,7 @@ PHP_COM_DOTNET_API void php_com_variant_from_zval(VARIANT *v, zval *z, int codep
 
                case IS_RESOURCE:
                case IS_CONSTANT:
-               case IS_CONSTANT_ARRAY:
+               case IS_CONSTANT_AST:
                default:
                        V_VT(v) = VT_NULL;
                        break;
index 55f856be5a05dd002d21a4f64b75b2ed9a1caade..faa3641eb1bfa936a0f3a12107612cba05469251 100644 (file)
@@ -2209,8 +2209,10 @@ static void accel_fast_zval_ptr_dtor(zval **zval_ptr)
 #else
                switch (Z_TYPE_P(zvalue) & ~IS_CONSTANT_INDEX) {
 #endif
-                       case IS_ARRAY:
-                       case IS_CONSTANT_ARRAY: {
+#if ZEND_EXTENSION_API_NO <= PHP_5_5_API_NO
+                       case IS_CONSTANT_ARRAY:
+#endif
+                       case IS_ARRAY: {
                                        TSRMLS_FETCH();
 
 #if ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO
index 6204290efe593aad6ca252fdee3fa567654e3618..ae33e765ca76760d6511b68873fa1a5386d12f3a 100644 (file)
@@ -237,19 +237,21 @@ static zend_ast *zend_ast_clone(zend_ast *ast TSRMLS_DC)
                if ((Z_TYPE_P(ast->u.val) & IS_CONSTANT_TYPE_MASK) >= IS_ARRAY) {
                        switch ((Z_TYPE_P(ast->u.val) & IS_CONSTANT_TYPE_MASK)) {
                                case IS_STRING:
-                           case IS_CONSTANT:
+                               case IS_CONSTANT:
                                        Z_STRVAL_P(node->u.val) = (char *) interned_estrndup(Z_STRVAL_P(ast->u.val), Z_STRLEN_P(ast->u.val));
                                        break;
                                case IS_ARRAY:
-                           case IS_CONSTANT_ARRAY:
+#if ZEND_EXTENSION_API_NO <= PHP_5_5_API_NO
+                               case IS_CONSTANT_ARRAY:
+#endif
                                        if (ast->u.val->value.ht && ast->u.val->value.ht != &EG(symbol_table)) {
                                                ALLOC_HASHTABLE(node->u.val->value.ht);
                                                zend_hash_clone_zval(node->u.val->value.ht, ast->u.val->value.ht, 0);
                                        }
                                        break;
-                           case IS_CONSTANT_AST:
-                               Z_AST_P(node->u.val) = zend_ast_clone(Z_AST_P(ast->u.val) TSRMLS_CC);
-                               break;
+                               case IS_CONSTANT_AST:
+                                       Z_AST_P(node->u.val) = zend_ast_clone(Z_AST_P(ast->u.val) TSRMLS_CC);
+                                       break;
                        }
                }
        } else {
@@ -295,20 +297,22 @@ static inline zval* zend_clone_zval(zval *src, int bind TSRMLS_DC)
                switch ((Z_TYPE_P(ret) & ~IS_CONSTANT_INDEX)) {
 #endif
                        case IS_STRING:
-                   case IS_CONSTANT:
+                       case IS_CONSTANT:
                                Z_STRVAL_P(ret) = (char *) interned_estrndup(Z_STRVAL_P(ret), Z_STRLEN_P(ret));
                                break;
                        case IS_ARRAY:
-                   case IS_CONSTANT_ARRAY:
+#if ZEND_EXTENSION_API_NO <= PHP_5_5_API_NO
+                       case IS_CONSTANT_ARRAY:
+#endif
                                if (ret->value.ht && ret->value.ht != &EG(symbol_table)) {
                                        ALLOC_HASHTABLE(ret->value.ht);
                                        zend_hash_clone_zval(ret->value.ht, src->value.ht, 0);
                                }
                                break;
 #if ZEND_EXTENSION_API_NO > PHP_5_5_X_API_NO
-                   case IS_CONSTANT_AST:
-                       Z_AST_P(ret) = zend_ast_clone(Z_AST_P(ret) TSRMLS_CC);
-                       break;
+                       case IS_CONSTANT_AST:
+                               Z_AST_P(ret) = zend_ast_clone(Z_AST_P(ret) TSRMLS_CC);
+                               break;
 #endif
                }
        }
@@ -417,20 +421,22 @@ static void zend_hash_clone_zval(HashTable *ht, HashTable *source, int bind)
                        switch ((Z_TYPE_P((zval*)p->pDataPtr) & ~IS_CONSTANT_INDEX)) {
 #endif
                                case IS_STRING:
-                           case IS_CONSTANT:
+                               case IS_CONSTANT:
                                        Z_STRVAL_P(ppz) = (char *) interned_estrndup(Z_STRVAL_P((zval*)p->pDataPtr), Z_STRLEN_P((zval*)p->pDataPtr));
                                        break;
                                case IS_ARRAY:
-                           case IS_CONSTANT_ARRAY:
+#if ZEND_EXTENSION_API_NO <= PHP_5_5_API_NO
+                               case IS_CONSTANT_ARRAY:
+#endif
                                        if (((zval*)p->pDataPtr)->value.ht && ((zval*)p->pDataPtr)->value.ht != &EG(symbol_table)) {
                                                ALLOC_HASHTABLE(ppz->value.ht);
                                                zend_hash_clone_zval(ppz->value.ht, ((zval*)p->pDataPtr)->value.ht, 0);
                                        }
                                        break;
 #if ZEND_EXTENSION_API_NO > PHP_5_5_X_API_NO
-                           case IS_CONSTANT_AST:
-                               Z_AST_P(ppz) = zend_ast_clone(Z_AST_P(ppz) TSRMLS_CC);
-                               break;
+                               case IS_CONSTANT_AST:
+                                       Z_AST_P(ppz) = zend_ast_clone(Z_AST_P(ppz) TSRMLS_CC);
+                                       break;
 #endif
                        }
                }
index 47f8f883127968b7589829dd7fce966186be51ab..17f8e8798f5fd439b65d5c649fa8d6f3eedcb809 100644 (file)
@@ -174,7 +174,9 @@ static void zend_persist_zval(zval *z TSRMLS_DC)
                        zend_accel_store_interned_string(z->value.str.val, z->value.str.len + 1);
                        break;
                case IS_ARRAY:
+#if ZEND_EXTENSION_API_NO <= PHP_5_5_API_NO
                case IS_CONSTANT_ARRAY:
+#endif
                        zend_accel_store(z->value.ht, sizeof(HashTable));
                        zend_hash_persist(z->value.ht, (zend_persist_func_t) zend_persist_zval_ptr, sizeof(zval**) TSRMLS_CC);
                        break;
index c899ec8ac98fef0a80be845f51efc30a0d597cf2..a01d834a4eff56219f8b41fbc592f0f51c2c3112 100644 (file)
@@ -129,7 +129,9 @@ static uint zend_persist_zval_calc(zval *z TSRMLS_DC)
                        ADD_INTERNED_STRING(Z_STRVAL_P(z), Z_STRLEN_P(z) + 1);
                        break;
                case IS_ARRAY:
+#if ZEND_EXTENSION_API_NO <= PHP_5_5_API_NO
                case IS_CONSTANT_ARRAY:
+#endif
                        ADD_DUP_SIZE(z->value.ht, sizeof(HashTable));
                        ADD_SIZE(zend_hash_persist_calc(z->value.ht, (int (*)(void* TSRMLS_DC)) zend_persist_zval_ptr_calc, sizeof(zval**) TSRMLS_CC));
                        break;
index d36901d8c1f5839239cb1e0ae09d8d748d6798b0..d867f433b23d5692209b31ee930f10fe745178a5 100644 (file)
@@ -5829,9 +5829,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con
                        php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Detected broken meta data. Missing 'is enum'");
                        err = 1;
                }
-               if (!err && (Z_TYPE_PP(val) == IS_ARRAY ||
-                        Z_TYPE_PP(val) == IS_OBJECT ||
-                        Z_TYPE_PP(val) == IS_CONSTANT_ARRAY)) {
+               if (!err && (Z_TYPE_PP(val) == IS_ARRAY || Z_TYPE_PP(val) == IS_OBJECT)) {
                        php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Expects scalar values as field values");
                        err = 1;
                }
index 32e88510e7866bb27bd4ac55722ffb5f849adde2..b225a2d67004f91fe88499d08be08fa12a3cd144 100644 (file)
@@ -154,10 +154,8 @@ encode defaultEncoding[] = {
        {{IS_BOOL, XSD_BOOLEAN_STRING, XSD_NAMESPACE, NULL}, to_zval_bool, to_xml_bool},
        {{IS_CONSTANT, XSD_STRING_STRING, XSD_NAMESPACE, NULL}, to_zval_string, to_xml_string},
        {{IS_ARRAY, SOAP_ENC_ARRAY_STRING, SOAP_1_1_ENC_NAMESPACE, NULL}, to_zval_array, guess_array_map},
-       {{IS_CONSTANT_ARRAY, SOAP_ENC_ARRAY_STRING, SOAP_1_1_ENC_NAMESPACE, NULL}, to_zval_array, to_xml_array},
        {{IS_OBJECT, SOAP_ENC_OBJECT_STRING, SOAP_1_1_ENC_NAMESPACE, NULL}, to_zval_object, to_xml_object},
        {{IS_ARRAY, SOAP_ENC_ARRAY_STRING, SOAP_1_2_ENC_NAMESPACE, NULL}, to_zval_array, guess_array_map},
-       {{IS_CONSTANT_ARRAY, SOAP_ENC_ARRAY_STRING, SOAP_1_2_ENC_NAMESPACE, NULL}, to_zval_array, to_xml_array},
        {{IS_OBJECT, SOAP_ENC_OBJECT_STRING, SOAP_1_2_ENC_NAMESPACE, NULL}, to_zval_object, to_xml_object},
 
        {{XSD_STRING, XSD_STRING_STRING, XSD_NAMESPACE, NULL}, to_zval_string, to_xml_string},
index 799b47b3ef44ab3921087ca92761390d2f106cff..763ff69404157ca6668b33f45891b3e39131ba29 100644 (file)
@@ -1431,7 +1431,6 @@ XMLRPC_VALUE_TYPE get_zval_xmlrpc_type(zval* value, zval** newvalue) /* {{{ */
                                type = xmlrpc_string;
                                break;
                        case IS_ARRAY:
-                       case IS_CONSTANT_ARRAY:
                                type = xmlrpc_vector;
                                break;
                        case IS_OBJECT: