--TEST-- SPL: SimpleXMLIterator and overridden iterator methods() --EXTENSIONS-- simplexml libxml --FILE-- Plain text. Bla bla 1. Here we have some text data. And here some more. Wow once again. Bla bla 2. Foo Bar EOF; class SXETest extends SimpleXMLIterator { function rewind(): void { echo __METHOD__ . "\n"; parent::rewind(); } function valid(): bool { echo __METHOD__ . "\n"; return parent::valid(); } function current(): SimpleXMLElement { echo __METHOD__ . "\n"; return parent::current(); } function key(): string { echo __METHOD__ . "\n"; return parent::key(); } function next(): void { echo __METHOD__ . "\n"; parent::next(); } function hasChildren(): bool { echo __METHOD__ . "\n"; return parent::hasChildren(); } function getChildren(): ?SimpleXMLIterator { echo __METHOD__ . "\n"; return parent::getChildren(); } } $sxe = new SXETest($xml); $rit = new RecursiveIteratorIterator($sxe, RecursiveIteratorIterator::SELF_FIRST); foreach($rit as $data) { var_dump(get_class($data)); var_dump(trim($data)); } ?> --EXPECT-- SXETest::rewind SXETest::valid SXETest::hasChildren SXETest::valid SXETest::current string(7) "SXETest" string(10) "Bla bla 1." SXETest::getChildren SXETest::rewind SXETest::valid SXETest::hasChildren SXETest::valid SXETest::current string(7) "SXETest" string(28) "Here we have some text data." SXETest::getChildren SXETest::rewind SXETest::valid SXETest::hasChildren SXETest::valid SXETest::current string(7) "SXETest" string(19) "And here some more." SXETest::getChildren SXETest::rewind SXETest::valid SXETest::hasChildren SXETest::valid SXETest::current string(7) "SXETest" string(15) "Wow once again." SXETest::next SXETest::valid SXETest::next SXETest::valid SXETest::next SXETest::valid SXETest::next SXETest::valid SXETest::hasChildren SXETest::valid SXETest::current string(7) "SXETest" string(10) "Bla bla 2." SXETest::getChildren SXETest::rewind SXETest::valid SXETest::hasChildren SXETest::valid SXETest::current string(7) "SXETest" string(7) "Foo Bar" SXETest::next SXETest::valid SXETest::next SXETest::valid SXETest::valid