1--TEST--
2XMLReader::fromStream() - legit usage
3--EXTENSIONS--
4xmlreader
5--FILE--
6<?php
7$h = fopen("php://memory", "w+");
8fwrite($h, "<root><!--my comment--><child/></root>");
9fseek($h, 0);
10
11$reader = XMLReader::fromStream($h, encoding: "UTF-8");
12while ($reader->read()) {
13    switch ($reader->nodeType) {
14        case XMLReader::ELEMENT:
15            echo "Element: ", $reader->name, "\n";
16            break;
17        case XMLReader::COMMENT:
18            echo "Comment: ", $reader->value, "\n";
19            break;
20    }
21}
22
23// Force cleanup of stream reference
24unset($reader);
25
26var_dump(ftell($h));
27
28fclose($h);
29?>
30--EXPECT--
31Element: root
32Comment: my comment
33Element: child
34int(38)
35