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