/
vshmidt
/
php
Обзор
Документация
Войти
/
vshmidt
/
php
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
ext/spl/tests/recursive_tree_iterator_007.phpt
37 строк
925 B
Gina Peter Banyard
ext/spl: Deprecate ArrayObject and ArrayIterator with objects (#19420)
14 авг 2025, 14:38
Не верифицирован
14 авг 2025, 14:38
fb87b14
Код
Авторство
О чём код?
--TEST-- SPL: RecursiveTreeIterator and Exception from getEntry() --FILE-- <?php $ary = [ ['string'], [new stdClass], ]; class RecursiveArrayIteratorAggregated implements IteratorAggregate { public RecursiveArrayIterator $it; function __construct(array $it) { $this->it = new RecursiveArrayIterator($it); } function getIterator(): Traversable { return $this->it; } } $it = new RecursiveArrayIteratorAggregated($ary); try { foreach(new RecursiveTreeIterator($it) as $k => $v) { echo "[$k] => $v\n"; } } catch (Error $e) { echo $e->getMessage(), "\n"; } ?> --EXPECTF-- [0] => |-Array [0] => | \-string [1] => \-Array Deprecated: ArrayIterator::__construct(): Using an object as a backing array for ArrayIterator is deprecated, as it allows violating class constraints and invariants in %s on line %d Object of class stdClass could not be converted to string