forked from php/php-src
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfromStream_custom_constructor.phpt
62 lines (58 loc) · 1.14 KB
/
fromStream_custom_constructor.phpt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
--TEST--
XMLReader::fromStream() - custom constructor
--EXTENSIONS--
xmlreader
--FILE--
<?php
class CustomXMLReader extends XMLReader {
public int $myField;
public function __construct() {
$this->myField = 1234;
echo "hello world\n";
}
}
$h = fopen("php://memory", "w+");
fwrite($h, "<root/>");
fseek($h, 0);
$reader = CustomXMLReader::fromStream($h, encoding: "UTF-8");
var_dump($reader);
var_dump($reader->read());
var_dump($reader->nodeType);
fclose($h);
?>
--EXPECTF--
hello world
object(CustomXMLReader)#%d (1) {
["attributeCount"]=>
uninitialized(int)
["baseURI"]=>
uninitialized(string)
["depth"]=>
uninitialized(int)
["hasAttributes"]=>
uninitialized(bool)
["hasValue"]=>
uninitialized(bool)
["isDefault"]=>
uninitialized(bool)
["isEmptyElement"]=>
uninitialized(bool)
["localName"]=>
uninitialized(string)
["name"]=>
uninitialized(string)
["namespaceURI"]=>
uninitialized(string)
["nodeType"]=>
uninitialized(int)
["prefix"]=>
uninitialized(string)
["value"]=>
uninitialized(string)
["xmlLang"]=>
uninitialized(string)
["myField"]=>
int(1234)
}
bool(true)
int(1)