From: Felipe Pena Date: Sat, 1 Aug 2009 20:44:00 +0000 (+0000) Subject: - Fixed ReflectionClass::getStaticProperties() to do not return the private propertie... X-Git-Tag: php-5.3.1RC1~209 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c75f162165bc3bc144dbe7ddfd4638f0e910e3de;p=php - Fixed ReflectionClass::getStaticProperties() to do not return the private properties from parent class; behavior already adopted in ReflectionClass::getDefaultProperties() and ReflectionClass::getProperties(). --- diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 8999c19994..7dfc0c86ea 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -3060,13 +3060,16 @@ ZEND_METHOD(reflection_class, getStaticProperties) zend_unmangle_property_name(key, key_len-1, &class_name, &prop_name); - /* copy: enforce read only access */ - ALLOC_ZVAL(prop_copy); - *prop_copy = **value; - zval_copy_ctor(prop_copy); - INIT_PZVAL(prop_copy); + /* filter privates from base classes */ + if (!(class_name && class_name[0] != '*' && strcmp(class_name, ce->name))) { + /* copy: enforce read only access */ + ALLOC_ZVAL(prop_copy); + *prop_copy = **value; + zval_copy_ctor(prop_copy); + INIT_PZVAL(prop_copy); - add_assoc_zval(return_value, prop_name, prop_copy); + add_assoc_zval(return_value, prop_name, prop_copy); + } } zend_hash_move_forward_ex(CE_STATIC_MEMBERS(ce), &pos); } diff --git a/ext/reflection/tests/ReflectionClass_getDefaultProperties_001.phpt b/ext/reflection/tests/ReflectionClass_getDefaultProperties_001.phpt index 3bf8f77ec6..e19db81188 100644 --- a/ext/reflection/tests/ReflectionClass_getDefaultProperties_001.phpt +++ b/ext/reflection/tests/ReflectionClass_getDefaultProperties_001.phpt @@ -109,13 +109,12 @@ Array ( [statPubC] => stat pubC in B [statProtC] => stat protC in B - [statPrivC] => stat privC in A + [statPrivC] => stat privC in B [statPubB] => stat pubB in B [statProtB] => stat protB in B [statPrivB] => stat privB in B [statPubA] => stat pubA in A [statProtA] => stat protA in A - [statPrivA] => stat privA in A ) @@ -146,13 +145,11 @@ Array ( [statPubC] => stat pubC in C [statProtC] => stat protC in C - [statPrivC] => stat privC in A + [statPrivC] => stat privC in C [statPubB] => stat pubB in B [statProtB] => stat protB in B - [statPrivB] => stat privB in B [statPubA] => stat pubA in A [statProtA] => stat protA in A - [statPrivA] => stat privA in A ) @@ -195,4 +192,3 @@ Array [protC] => protC in X [privC] => privC in X ) - diff --git a/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_001.phpt b/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_001.phpt index 70a3bab9c2..082ef676cd 100644 --- a/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_001.phpt +++ b/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_001.phpt @@ -67,11 +67,11 @@ Array ) Array ( - [privateOverridden] => new value 4 + [privateOverridden] => new value 5 [protectedOverridden] => new value 6 [publicOverridden] => new value 7 ) Set non-existent values from A with no default value: Class A does not have a property named protectedOverridden -Class A does not have a property named privateOverridden \ No newline at end of file +Class A does not have a property named privateOverridden diff --git a/ext/reflection/tests/bug49074.phpt b/ext/reflection/tests/bug49074.phpt index 670427594b..7ce23b41e4 100644 --- a/ext/reflection/tests/bug49074.phpt +++ b/ext/reflection/tests/bug49074.phpt @@ -23,13 +23,9 @@ $m['data4'] = 400; var_dump($r->getStaticProperties()); ?> --EXPECT-- -array(4) { +array(2) { ["data2"]=> int(2) ["data3"]=> int(3) - ["data1"]=> - int(1) - ["data4"]=> - int(4) }