Skip to content

Commit c3a9905

Browse files
committed
Use virtual annotation in XMLReader
All properties of XMLReader are virtual and therefore don't need backing storage.
1 parent 69e392e commit c3a9905

File tree

3 files changed

+63
-15
lines changed

3 files changed

+63
-15
lines changed

ext/xmlreader/php_xmlreader.stub.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,32 +99,46 @@ class XMLReader
9999
public const int SUBST_ENTITIES = UNKNOWN;
100100

101101

102+
/** @virtual */
102103
public int $attributeCount;
103104

105+
/** @virtual */
104106
public string $baseURI;
105107

108+
/** @virtual */
106109
public int $depth;
107110

111+
/** @virtual */
108112
public bool $hasAttributes;
109113

114+
/** @virtual */
110115
public bool $hasValue;
111116

117+
/** @virtual */
112118
public bool $isDefault;
113119

120+
/** @virtual */
114121
public bool $isEmptyElement;
115122

123+
/** @virtual */
116124
public string $localName;
117125

126+
/** @virtual */
118127
public string $name;
119128

129+
/** @virtual */
120130
public string $namespaceURI;
121131

132+
/** @virtual */
122133
public int $nodeType;
123134

135+
/** @virtual */
124136
public string $prefix;
125137

138+
/** @virtual */
126139
public string $value;
127140

141+
/** @virtual */
128142
public string $xmlLang;
129143

130144
/** @tentative-return-type */

ext/xmlreader/php_xmlreader_arginfo.h

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
--TEST--
2+
Virtual property tests
3+
--EXTENSIONS--
4+
xmlreader
5+
--FILE--
6+
<?php
7+
8+
$rc = new ReflectionClass(XMLReader::class);
9+
$prop = $rc->getProperty("nodeType");
10+
var_dump($prop->isVirtual());
11+
var_dump($prop->getSettableType());
12+
var_dump($prop->getHooks());
13+
var_dump($prop->getRawValue(new XMLReader));
14+
var_dump($prop->getValue(new XMLReader));
15+
16+
$reader = XMLReader::XML("<root>hi</root>");
17+
var_dump(json_encode($reader));
18+
var_export($reader); echo "\n";
19+
var_dump(get_object_vars($reader));
20+
21+
?>
22+
--EXPECTF--
23+
bool(true)
24+
object(ReflectionNamedType)#%d (0) {
25+
}
26+
array(0) {
27+
}
28+
int(0)
29+
int(0)
30+
string(2) "{}"
31+
\XMLReader::__set_state(array(
32+
))
33+
array(0) {
34+
}

0 commit comments

Comments
 (0)