Skip to content

Commit ab80064

Browse files
committed
Introduce zend_symtable_exists_ind() for API consistency
1 parent 1ce0ea7 commit ab80064

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

Zend/zend_hash.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,18 @@ static zend_always_inline int zend_symtable_exists(HashTable *ht, zend_string *k
377377
{
378378
zend_ulong idx;
379379

380+
if (ZEND_HANDLE_NUMERIC(key, idx)) {
381+
return zend_hash_index_exists(ht, idx);
382+
} else {
383+
return zend_hash_exists(ht, key);
384+
}
385+
}
386+
387+
388+
static zend_always_inline int zend_symtable_exists_ind(HashTable *ht, zend_string *key)
389+
{
390+
zend_ulong idx;
391+
380392
if (ZEND_HANDLE_NUMERIC(key, idx)) {
381393
return zend_hash_index_exists(ht, idx);
382394
} else {

ext/standard/array.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5429,7 +5429,7 @@ PHP_FUNCTION(array_key_exists)
54295429

54305430
switch (Z_TYPE_P(key)) {
54315431
case IS_STRING:
5432-
if (zend_symtable_exists(array, Z_STR_P(key))) {
5432+
if (zend_symtable_exists_ind(array, Z_STR_P(key))) {
54335433
RETURN_TRUE;
54345434
}
54355435
RETURN_FALSE;
@@ -5439,7 +5439,7 @@ PHP_FUNCTION(array_key_exists)
54395439
}
54405440
RETURN_FALSE;
54415441
case IS_NULL:
5442-
if (zend_hash_exists(array, ZSTR_EMPTY_ALLOC())) {
5442+
if (zend_hash_exists_ind(array, ZSTR_EMPTY_ALLOC())) {
54435443
RETURN_TRUE;
54445444
}
54455445
RETURN_FALSE;

0 commit comments

Comments
 (0)