$array = [$i => 42, new stdClass];
var_dump($array);
+const FOO = [PHP_INT_MAX => 42, "foo"];
+var_dump(FOO);
+
?>
--EXPECTF--
Warning: Cannot add element to the array as the next element is already occupied in %s on line %d
[%d]=>
int(42)
}
+
+Warning: Cannot add element to the array as the next element is already occupied in %s on line %d
+array(1) {
+ [%d]=>
+ int(42)
+}
}
/* }}} */
-void zend_do_add_static_array_element(zval *result, zval *offset, const zval *expr) /* {{{ */
+void zend_do_add_static_array_element(zval *result, zval *offset, zval *expr) /* {{{ */
{
if (offset) {
switch (Z_TYPE_P(offset)) {
break;
}
} else {
- zend_hash_next_index_insert(Z_ARRVAL_P(result), &expr, sizeof(zval *), NULL);
+ if (zend_hash_next_index_insert(Z_ARRVAL_P(result), &expr, sizeof(zval *), NULL) == FAILURE) {
+ zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
+ zval_ptr_dtor(&expr);
+ }
}
}
/* }}} */
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(zval *result, zval *offset, const zval *expr);
+void zend_do_add_static_array_element(zval *result, zval *offset, 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);