1--TEST--
2XMLReader::fromString() - custom constructor
3--EXTENSIONS--
4xmlreader
5--FILE--
6<?php
7class CustomXMLReader extends XMLReader {
8    public int $myField;
9
10    public function __construct() {
11        $this->myField = 1234;
12        echo "hello world\n";
13    }
14}
15
16$reader = CustomXMLReader::fromString("<root/>");
17try {
18    var_dump($reader);
19} catch (Error $e) {
20    echo $e->getMessage(), "\n";
21}
22var_dump($reader->read());
23var_dump($reader->nodeType);
24?>
25--EXPECTF--
26hello world
27object(CustomXMLReader)#%d (14) {
28  ["myField"]=>
29  int(1234)
30  ["attributeCount"]=>
31  int(0)
32  ["baseURI"]=>
33  string(0) ""
34  ["depth"]=>
35  int(0)
36  ["hasAttributes"]=>
37  bool(false)
38  ["hasValue"]=>
39  bool(false)
40  ["isDefault"]=>
41  bool(false)
42  ["localName"]=>
43  string(0) ""
44  ["name"]=>
45  string(0) ""
46  ["namespaceURI"]=>
47  string(0) ""
48  ["nodeType"]=>
49  int(0)
50  ["prefix"]=>
51  string(0) ""
52  ["value"]=>
53  string(0) ""
54  ["xmlLang"]=>
55  string(0) ""
56}
57Failed to read property because no XML data has been read yet
58bool(true)
59int(1)
60