Skip to content

Commit 9a04e97

Browse files
Fix GH-16162: No ReflectionProperty::IS_VIRTUAL
1 parent 341c26f commit 9a04e97

7 files changed

+167
-6
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ PHP NEWS
5151
- Reflection:
5252
. Fixed bug GH-16122 (The return value of ReflectionFunction::getNamespaceName()
5353
and ReflectionFunction::inNamespace() for closures is incorrect). (timwolla)
54+
. Fixed bug GH-16162 (No ReflectionProperty::IS_VIRTUAL) (DanielEScherzer)
5455

5556
- SAPI:
5657
. Fixed bug GHSA-9pqp-7h25-4f32 (Erroneous parsing of multipart form data).

ext/reflection/php_reflection.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1595,6 +1595,9 @@ ZEND_METHOD(Reflection, getModifierNames)
15951595
if (modifiers & ZEND_ACC_FINAL) {
15961596
add_next_index_stringl(return_value, "final", sizeof("final")-1);
15971597
}
1598+
if (modifiers & ZEND_ACC_VIRTUAL) {
1599+
add_next_index_stringl(return_value, "virtual", sizeof("virtual")-1);
1600+
}
15981601

15991602
/* These are mutually exclusive */
16001603
switch (modifiers & ZEND_ACC_PPP_MASK) {

ext/reflection/php_reflection.stub.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,8 @@ class ReflectionProperty implements Reflector
470470
public const int IS_PROTECTED_SET = UNKNOWN;
471471
/** @cvalue ZEND_ACC_PRIVATE_SET */
472472
public const int IS_PRIVATE_SET = UNKNOWN;
473+
/** @cvalue ZEND_ACC_VIRTUAL */
474+
public const int IS_VIRTUAL = UNKNOWN;
473475
/** @cvalue ZEND_ACC_FINAL */
474476
public const int IS_FINAL = UNKNOWN;
475477

ext/reflection/php_reflection_arginfo.h

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/reflection/tests/ReflectionClass_getProperties_003.phpt

Lines changed: 142 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,19 @@ class C {
1414
static public $pubs2;
1515
static private $privs1;
1616
static private $privs2;
17+
public $pubVirt1 { get {} set {} }
18+
public $pubVirt2 { get {} }
19+
public $pubVirt3 { set {} }
20+
private $privVirt1 { get {} set {} }
21+
private $privVirt2 { get {} }
22+
private $privVirt3 { set {} }
1723
}
1824

1925
$rc = new ReflectionClass("C");
2026
$StaticFlag = ReflectionProperty::IS_STATIC;
2127
$pubFlag = ReflectionProperty::IS_PUBLIC;
2228
$privFlag = ReflectionProperty::IS_PRIVATE;
29+
$virtFlag = ReflectionProperty::IS_VIRTUAL;
2330

2431
echo "No properties:";
2532
var_dump($rc->getProperties(0));
@@ -35,11 +42,14 @@ var_dump($rc->getProperties($StaticFlag | $pubFlag));
3542

3643
echo "Private or static properties:";
3744
var_dump($rc->getProperties($StaticFlag | $privFlag));
45+
46+
echo "Virtual properties:";
47+
var_dump($rc->getProperties($virtFlag));
3848
?>
3949
--EXPECTF--
4050
No properties:array(0) {
4151
}
42-
Public properties:array(4) {
52+
Public properties:array(7) {
4353
[0]=>
4454
object(ReflectionProperty)#%d (2) {
4555
["name"]=>
@@ -68,8 +78,29 @@ Public properties:array(4) {
6878
["class"]=>
6979
string(1) "C"
7080
}
81+
[4]=>
82+
object(ReflectionProperty)#%d (2) {
83+
["name"]=>
84+
string(8) "pubVirt1"
85+
["class"]=>
86+
string(1) "C"
87+
}
88+
[5]=>
89+
object(ReflectionProperty)#%d (2) {
90+
["name"]=>
91+
string(8) "pubVirt2"
92+
["class"]=>
93+
string(1) "C"
94+
}
95+
[6]=>
96+
object(ReflectionProperty)#%d (2) {
97+
["name"]=>
98+
string(8) "pubVirt3"
99+
["class"]=>
100+
string(1) "C"
101+
}
71102
}
72-
Private properties:array(4) {
103+
Private properties:array(7) {
73104
[0]=>
74105
object(ReflectionProperty)#%d (2) {
75106
["name"]=>
@@ -98,8 +129,29 @@ Private properties:array(4) {
98129
["class"]=>
99130
string(1) "C"
100131
}
132+
[4]=>
133+
object(ReflectionProperty)#%d (2) {
134+
["name"]=>
135+
string(9) "privVirt1"
136+
["class"]=>
137+
string(1) "C"
138+
}
139+
[5]=>
140+
object(ReflectionProperty)#%d (2) {
141+
["name"]=>
142+
string(9) "privVirt2"
143+
["class"]=>
144+
string(1) "C"
145+
}
146+
[6]=>
147+
object(ReflectionProperty)#%d (2) {
148+
["name"]=>
149+
string(9) "privVirt3"
150+
["class"]=>
151+
string(1) "C"
152+
}
101153
}
102-
Public or static properties:array(6) {
154+
Public or static properties:array(9) {
103155
[0]=>
104156
object(ReflectionProperty)#%d (2) {
105157
["name"]=>
@@ -142,8 +194,29 @@ Public or static properties:array(6) {
142194
["class"]=>
143195
string(1) "C"
144196
}
197+
[6]=>
198+
object(ReflectionProperty)#%d (2) {
199+
["name"]=>
200+
string(8) "pubVirt1"
201+
["class"]=>
202+
string(1) "C"
203+
}
204+
[7]=>
205+
object(ReflectionProperty)#%d (2) {
206+
["name"]=>
207+
string(8) "pubVirt2"
208+
["class"]=>
209+
string(1) "C"
210+
}
211+
[8]=>
212+
object(ReflectionProperty)#%d (2) {
213+
["name"]=>
214+
string(8) "pubVirt3"
215+
["class"]=>
216+
string(1) "C"
217+
}
145218
}
146-
Private or static properties:array(6) {
219+
Private or static properties:array(9) {
147220
[0]=>
148221
object(ReflectionProperty)#%d (2) {
149222
["name"]=>
@@ -186,4 +259,69 @@ Private or static properties:array(6) {
186259
["class"]=>
187260
string(1) "C"
188261
}
262+
[6]=>
263+
object(ReflectionProperty)#%d (2) {
264+
["name"]=>
265+
string(9) "privVirt1"
266+
["class"]=>
267+
string(1) "C"
268+
}
269+
[7]=>
270+
object(ReflectionProperty)#%d (2) {
271+
["name"]=>
272+
string(9) "privVirt2"
273+
["class"]=>
274+
string(1) "C"
275+
}
276+
[8]=>
277+
object(ReflectionProperty)#%d (2) {
278+
["name"]=>
279+
string(9) "privVirt3"
280+
["class"]=>
281+
string(1) "C"
282+
}
283+
}
284+
Virtual properties:array(6) {
285+
[0]=>
286+
object(ReflectionProperty)#%d (2) {
287+
["name"]=>
288+
string(8) "pubVirt1"
289+
["class"]=>
290+
string(1) "C"
291+
}
292+
[1]=>
293+
object(ReflectionProperty)#%d (2) {
294+
["name"]=>
295+
string(8) "pubVirt2"
296+
["class"]=>
297+
string(1) "C"
298+
}
299+
[2]=>
300+
object(ReflectionProperty)#%d (2) {
301+
["name"]=>
302+
string(8) "pubVirt3"
303+
["class"]=>
304+
string(1) "C"
305+
}
306+
[3]=>
307+
object(ReflectionProperty)#%d (2) {
308+
["name"]=>
309+
string(9) "privVirt1"
310+
["class"]=>
311+
string(1) "C"
312+
}
313+
[4]=>
314+
object(ReflectionProperty)#%d (2) {
315+
["name"]=>
316+
string(9) "privVirt2"
317+
["class"]=>
318+
string(1) "C"
319+
}
320+
[5]=>
321+
object(ReflectionProperty)#%d (2) {
322+
["name"]=>
323+
string(9) "privVirt3"
324+
["class"]=>
325+
string(1) "C"
326+
}
189327
}

ext/reflection/tests/ReflectionProperty_getModifiers_basic.phpt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ class C {
1212
static private $a6;
1313
public final $a7;
1414
public static final $a8;
15+
public $a9 { get {} set {} }
16+
public $a10 { get {} }
17+
public $a11 { set {} }
1518
}
1619

1720
class D extends C {
@@ -23,7 +26,7 @@ class D extends C {
2326
static private $a6;
2427
}
2528

26-
for ($i = 1;$i <= 8;$i++) {
29+
for ($i = 1;$i <= 11;$i++) {
2730
$rp = new ReflectionProperty("C", "a$i");
2831
echo "C::a$i: ";
2932
var_dump($rp->getModifiers());
@@ -50,3 +53,9 @@ C::a7: int(33)
5053
D::a7: int(33)
5154
C::a8: int(49)
5255
D::a8: int(49)
56+
C::a9: int(513)
57+
D::a9: int(513)
58+
C::a10: int(513)
59+
D::a10: int(513)
60+
C::a11: int(513)
61+
D::a11: int(513)

ext/reflection/tests/Reflection_getModifierNames_001.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ printModifiers(ReflectionClass::IS_EXPLICIT_ABSTRACT);
1414
printModifiers(ReflectionMethod::IS_ABSTRACT | ReflectionMethod::IS_FINAL);
1515
printModifiers(ReflectionProperty::IS_PUBLIC | ReflectionProperty::IS_STATIC | ReflectionProperty::IS_READONLY);
1616
printModifiers(ReflectionClass::IS_READONLY);
17+
printModifiers(ReflectionProperty::IS_VIRTUAL);
1718
?>
1819
--EXPECT--
1920
private
@@ -23,3 +24,4 @@ abstract
2324
abstract,final
2425
public,static,readonly
2526
readonly
27+
virtual

0 commit comments

Comments
 (0)