Fix bug for `ArrayAccess` implementation.
This commit is contained in:
parent
639479d031
commit
b9f5b14b56
|
@ -450,7 +450,8 @@ int collection_offset_exists(zval* object, zval* offset, int check_empty)
|
||||||
zend_array* current = COLLECTION_FETCH(object);
|
zend_array* current = COLLECTION_FETCH(object);
|
||||||
if (check_empty)
|
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)
|
if (Z_TYPE_P(offset) == IS_LONG)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,12 +2,14 @@
|
||||||
Test implementation of interface ArrayAccess.
|
Test implementation of interface ArrayAccess.
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
$array = ['a' => 'b', 'c' => 'd', 'e' => ['f' => 'g']];
|
$array = ['a' => 'b', 'c' => 'd', 'e' => ['f' => 'g'], 'i' => false];
|
||||||
$collection = Collection::init($array);
|
$collection = Collection::init($array);
|
||||||
$collection['a'] = 'foo'.strval(123);
|
$collection['a'] = 'foo'.strval(123);
|
||||||
$collection['h'] = 'bar';
|
$collection['h'] = 'bar';
|
||||||
unset($collection['c']);
|
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;
|
echo 'Test for handlers.has_dimension failed.', PHP_EOL;
|
||||||
}
|
}
|
||||||
if ($collection['e']['f'] != 'g') {
|
if ($collection['e']['f'] != 'g') {
|
||||||
|
|
Reference in New Issue