Fix bug for `ArrayAccess` implementation.

This commit is contained in:
CismonX 2018-08-31 01:27:19 +08:00
parent 639479d031
commit b9f5b14b56
2 changed files with 6 additions and 3 deletions

View File

@ -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)
{

View File

@ -2,12 +2,14 @@
Test implementation of interface ArrayAccess.
--FILE--
<?php
$array = ['a' => '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') {