--TEST--
SPL: RecursiveIteratorIterator and beginChildren/endChildren
--FILE--
getArrayCopy());
}
}
class MenuOutput extends RecursiveIteratorIterator
{
function __construct(Menu $it)
{
parent::__construct($it);
}
function rewind(): void
{
echo "
\n";
parent::rewind();
}
function beginChildren(): void
{
echo str_repeat(' ',$this->getDepth())."\n";
}
function endChildren(): void
{
echo str_repeat(' ',$this->getDepth())."
\n";
}
function valid(): bool
{
if (!parent::valid()) {
echo "\n";
return false;
}
return true;
}
}
$arr = [
"a",
[
"ba",
["bba", "bbb"],
[
["bcaa"]
]
],
["ca"],
"d",
];
$obj = new Menu($arr);
$rit = new MenuOutput($obj);
foreach($rit as $k=>$v)
{
echo str_repeat(' ',$rit->getDepth()+1)."$k=>$v\n";
}
?>
--EXPECT--
Menu::getIterator