Skip to content

Commit b5b4f94

Browse files
committed
- Fixed ReflectionProperty::isDefault() giving a wrong result for properties
obtained with ReflectionClass::getProperties().
1 parent 0086bc8 commit b5b4f94

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

NEWS

+2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
sequences. (Gustavo)
4242
- Fixed bug #52929 (Segfault in filter_var with FILTER_VALIDATE_EMAIL with
4343
large amount of data) (CVE-2010-3710). (Adam)
44+
- Fixed ReflectionProperty::isDefault() giving a wrong result for properties
45+
obtained with ReflectionClass::getProperties(). (Gustavo)
4446

4547
- Fixed bug #53144 (Segfault in SplObjectStorage::removeAll()). (Felipe)
4648
- Fixed bug #53071 (SPLObjectStorage defeats gc_collect_cycles). (Gustavo)

ext/reflection/php_reflection.c

+1
Original file line numberDiff line numberDiff line change
@@ -3660,6 +3660,7 @@ static int _adddynproperty(zval **pptr TSRMLS_DC, int num_args, va_list args, ze
36603660
ZVAL_STRINGL(&member, hash_key->arKey, hash_key->nKeyLength-1, 0);
36613661
if (zend_get_property_info(ce, &member, 1 TSRMLS_CC) == &EG(std_property_info)) {
36623662
MAKE_STD_ZVAL(property);
3663+
EG(std_property_info).flags = ZEND_ACC_IMPLICIT_PUBLIC;
36633664
reflection_property_factory(ce, &EG(std_property_info), property TSRMLS_CC);
36643665
add_next_index_zval(retval, property);
36653666
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
--TEST--
2+
ReflectionParameter::isDefault()
3+
--FILE--
4+
<?php
5+
class A {
6+
public $defprop;
7+
}
8+
$a = new A;
9+
$a->myprop = null;
10+
11+
$ro = new ReflectionObject($a);
12+
$props = $ro->getProperties();
13+
$prop1 = $props[0];
14+
var_dump($prop1->isDefault());
15+
$prop2 = $props[1];
16+
var_dump($prop2->isDefault());
17+
18+
var_dump($ro->getProperty('defprop')->isDefault());
19+
var_dump($ro->getProperty('myprop')->isDefault());
20+
21+
$prop1 = new ReflectionProperty($a, 'defprop');
22+
$prop2 = new ReflectionProperty($a, 'myprop');
23+
var_dump($prop1->isDefault());
24+
var_dump($prop2->isDefault());
25+
?>
26+
==DONE==
27+
--EXPECT--
28+
bool(true)
29+
bool(false)
30+
bool(true)
31+
bool(false)
32+
bool(true)
33+
bool(false)
34+
==DONE==

0 commit comments

Comments
 (0)