--TEST-- XMLReader::fromStream() - custom constructor --EXTENSIONS-- xmlreader --FILE-- myField = 1234; echo "hello world\n"; } } $h = fopen("php://memory", "w+"); fwrite($h, ""); fseek($h, 0); $reader = CustomXMLReader::fromStream($h, encoding: "UTF-8"); try { var_dump($reader); } catch (Error $e) { echo $e->getMessage(), "\n"; } var_dump($reader->read()); var_dump($reader->nodeType); fclose($h); ?> --EXPECTF-- hello world object(CustomXMLReader)#%d (14) { ["myField"]=> int(1234) ["attributeCount"]=> int(0) ["baseURI"]=> string(0) "" ["depth"]=> int(0) ["hasAttributes"]=> bool(false) ["hasValue"]=> bool(false) ["isDefault"]=> bool(false) ["localName"]=> string(0) "" ["name"]=> string(0) "" ["namespaceURI"]=> string(0) "" ["nodeType"]=> int(0) ["prefix"]=> string(0) "" ["value"]=> string(0) "" ["xmlLang"]=> string(0) "" } Failed to read property because no XML data has been read yet bool(true) int(1)