1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 08:12:21 +01:00
Files
archived-php-src/ext/spl/tests/recursive_tree_iterator_007.phpt

38 lines
925 B
PHP

--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