]> granicus.if.org Git - php/commitdiff
BugFix #28879 Inconsistent behavior between explicit and implicit array creation.
authorSara Golemon <pollita@php.net>
Wed, 23 Jun 2004 23:20:44 +0000 (23:20 +0000)
committerSara Golemon <pollita@php.net>
Wed, 23 Jun 2004 23:20:44 +0000 (23:20 +0000)
Changes:

Throw E_WARNING "Illegal offset type" when explicitly creating
array elements with objects, arrays, or resorces as indexes.
This matches implicit creation w/ obj/arr indices.

Throw E_WARNING "Resource ID#%ld used as offset, casting to integer (%ld)"
when implicitly creating array with resource as index. (BC)

Zend/zend_execute.c

index 48d5eb7db181dcb69204d31f5f551c8cdc56cfa9..733826352d86fcfd2a40f01b81367f658cdd3d42 100644 (file)
@@ -839,8 +839,10 @@ fetch_string_dim:
                                }
                        }
                        break;
-               case IS_DOUBLE:
                case IS_RESOURCE:
+                       zend_error(E_WARNING, "Resource ID#%ld used as offset, casting to integer (%ld)", dim->value.lval, dim->value.lval);
+                       /* Fall Through */
+               case IS_DOUBLE:
                case IS_BOOL: 
                case IS_LONG: {
                                long index;
@@ -3402,6 +3404,7 @@ static inline int zend_init_add_array_helper(ZEND_OPCODE_HANDLER_ARGS)
                                zend_hash_update(array_ptr->value.ht, "", sizeof(""), &expr_ptr, sizeof(zval *), NULL);
                                break;
                        default:
+                               zend_error(E_WARNING, "Illegal offset type");
                                zval_ptr_dtor(&expr_ptr);
                                /* do nothing */
                                break;