diff --git a/src/collections_methods.c b/src/collections_methods.c index dff8d37..52b6e89 100644 --- a/src/collections_methods.c +++ b/src/collections_methods.c @@ -450,7 +450,8 @@ int collection_offset_exists(zval* object, zval* offset, int check_empty) zend_array* current = COLLECTION_FETCH(object); if (check_empty) { - return zend_hash_num_elements(current) == 0; + zval result; + return zend_is_true(collection_offset_get(object, offset, 0, &result)); } if (Z_TYPE_P(offset) == IS_LONG) { diff --git a/tests/013-array-access.phpt b/tests/013-array-access.phpt index f60a520..21b4a41 100644 --- a/tests/013-array-access.phpt +++ b/tests/013-array-access.phpt @@ -2,12 +2,14 @@ Test implementation of interface ArrayAccess. --FILE-- 'b', 'c' => 'd', 'e' => ['f' => 'g']]; +$array = ['a' => 'b', 'c' => 'd', 'e' => ['f' => 'g'], 'i' => false]; $collection = Collection::init($array); $collection['a'] = 'foo'.strval(123); $collection['h'] = 'bar'; unset($collection['c']); -if (empty($collection) || isset($collection['t']) || !isset($collection['e'])) { +if (empty($collection['e']) || !empty($collection['i']) || + isset($collection['t']) || !isset($collection['e']) +) { echo 'Test for handlers.has_dimension failed.', PHP_EOL; } if ($collection['e']['f'] != 'g') {