summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntony Dovgal <tony2001@php.net>2006-10-02 12:16:35 +0000
committerAntony Dovgal <tony2001@php.net>2006-10-02 12:16:35 +0000
commitc356ad3b65709d41c2b5030c252bc54b7295daa3 (patch)
tree254c98c28a1a47c5177d6d9d6be94734648e195e
parent2b1b2db8ec8d5ef26da2ec671d163182f72f1206 (diff)
downloadphp-git-c356ad3b65709d41c2b5030c252bc54b7295daa3.tar.gz
MFH: #39001 (ReflectionProperty returns incorrect declaring class for protected properties)
-rw-r--r--NEWS2
-rw-r--r--ext/reflection/php_reflection.c11
-rw-r--r--ext/reflection/tests/bug39001.phpt27
3 files changed, 38 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index 7861123bf1..2182ee1a9f 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,8 @@ PHP NEWS
working exactly like in php.ini; with FastCGI -d affects all requests).
(Dmitry)
- Fixed bug #39003 (__autoload() is called for type hinting). (Dmitry, Tony)
+- Fixed bug #39001 (ReflectionProperty returns incorrect declaring class for
+ protected properties). (Tony)
- Fixed bug #38993 (Fixed safe_mode/open_basedir checks for
session.save_path, allowing them to account for extra parameters). (Ilia)
- Fixed bug #38981 (using FTP URLs in get_headers() causes crash). (Tony)
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index 65ad634949..d7d17f7618 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -4008,14 +4008,21 @@ ZEND_METHOD(reflection_property, getDeclaringClass)
property_reference *ref;
zend_class_entry *tmp_ce, *ce;
zend_property_info *tmp_info;
+ char *prop_name, *class_name;
+ int prop_name_len;
METHOD_NOTSTATIC_NUMPARAMS(reflection_property_ptr, 0);
GET_REFLECTION_OBJECT_PTR(ref);
+ if (zend_unmangle_property_name(ref->prop->name, ref->prop->name_length, &class_name, &prop_name) != SUCCESS) {
+ RETURN_FALSE;
+ }
+
+ prop_name_len = strlen(prop_name);
ce = tmp_ce = ref->ce;
- while (tmp_ce && zend_hash_find(&tmp_ce->properties_info, ref->prop->name, ref->prop->name_length + 1, (void **) &tmp_info) == SUCCESS) {
+ while (tmp_ce && zend_hash_find(&tmp_ce->properties_info, prop_name, prop_name_len + 1, (void **) &tmp_info) == SUCCESS) {
ce = tmp_ce;
- tmp_ce = tmp_ce->parent;
+ tmp_ce = tmp_ce->parent;
}
zend_reflection_class_factory(ce, return_value TSRMLS_CC);
diff --git a/ext/reflection/tests/bug39001.phpt b/ext/reflection/tests/bug39001.phpt
new file mode 100644
index 0000000000..1ed675f029
--- /dev/null
+++ b/ext/reflection/tests/bug39001.phpt
@@ -0,0 +1,27 @@
+--TEST--
+Bug #39001 (ReflectionProperty returns incorrect declaring class for protected properties)
+--FILE--
+<?php
+
+class Meta {
+}
+
+class CParent extends Meta {
+ public $publicVar;
+ protected $protectedVar;
+}
+
+class Child extends CParent {
+}
+
+$r = new ReflectionClass('Child');
+
+var_dump($r->getProperty('publicVar')->getDeclaringClass()->getName());
+var_dump($r->getProperty('protectedVar')->getDeclaringClass()->getName());
+
+echo "Done\n";
+?>
+--EXPECTF--
+string(7) "CParent"
+string(7) "CParent"
+Done