Skip to content

Commit 19555de

Browse files
committed
Add deprecation warning for array API
This is used by array_column(), the AST, and iterators
1 parent 719d413 commit 19555de

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Zend/zend_API.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2255,9 +2255,6 @@ ZEND_API zend_result array_set_zval_key(HashTable *ht, zval *key, zval *value) /
22552255
case IS_STRING:
22562256
result = zend_symtable_update(ht, Z_STR_P(key), value);
22572257
break;
2258-
case IS_NULL:
2259-
result = zend_hash_update(ht, ZSTR_EMPTY_ALLOC(), value);
2260-
break;
22612258
case IS_RESOURCE:
22622259
zend_use_resource_as_offset(key);
22632260
result = zend_hash_index_update(ht, Z_RES_HANDLE_P(key), value);
@@ -2274,6 +2271,13 @@ ZEND_API zend_result array_set_zval_key(HashTable *ht, zval *key, zval *value) /
22742271
case IS_DOUBLE:
22752272
result = zend_hash_index_update(ht, zend_dval_to_lval_safe(Z_DVAL_P(key)), value);
22762273
break;
2274+
case IS_NULL:
2275+
zend_error(E_DEPRECATED, "Using null as an array offset is deprecated, use an empty string instead");
2276+
if (UNEXPECTED(EG(exception))) {
2277+
return FAILURE;
2278+
}
2279+
result = zend_hash_update(ht, ZSTR_EMPTY_ALLOC(), value);
2280+
break;
22772281
default:
22782282
zend_illegal_container_offset(ZSTR_KNOWN(ZEND_STR_ARRAY), key, BP_VAR_W);
22792283
result = NULL;

0 commit comments

Comments
 (0)