summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Pena <felipe@php.net>2009-08-01 20:44:00 +0000
committerFelipe Pena <felipe@php.net>2009-08-01 20:44:00 +0000
commitc75f162165bc3bc144dbe7ddfd4638f0e910e3de (patch)
treef37bc9c62d4ef5706550bddec2f9af2d7be87758
parentade24c7e355cf65874d10c9d72bb7710919b0084 (diff)
downloadphp-git-c75f162165bc3bc144dbe7ddfd4638f0e910e3de.tar.gz
- Fixed ReflectionClass::getStaticProperties() to do not return the private properties from parent class;
behavior already adopted in ReflectionClass::getDefaultProperties() and ReflectionClass::getProperties().
-rw-r--r--ext/reflection/php_reflection.c15
-rw-r--r--ext/reflection/tests/ReflectionClass_getDefaultProperties_001.phpt8
-rw-r--r--ext/reflection/tests/ReflectionClass_setStaticPropertyValue_001.phpt4
-rw-r--r--ext/reflection/tests/bug49074.phpt6
4 files changed, 14 insertions, 19 deletions
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)
}