com php-src: Fixed bug #75231: NEWS ext/reflection/php_reflec tion.c ext/reflection/tests/bug75231.phpt
| From: | Nikita Popov | Date: | Mon, 02 Jul 2018 16:56:27 +0000 |
| Subject: | com php-src: Fixed bug #75231: NEWS ext/reflection/php_reflec tion.c ext/reflection/tests/bug75231.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-102370@lists.php.net to get a copy of this message | ||
Commit: c97b8bbf8252c3a493a44bcb91fb137952f03710
Author: Nikita Popov <nikita.ppv@gmail.com> Mon, 2 Jul 2018 18:56:27 +0200
Parents: 787593b708372f67fdaabbe4ae7667f6ee5b062f
Branches: PHP-7.1 PHP-7.2 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=c97b8bbf8252c3a493a44bcb91fb137952f03710
Log:
Fixed bug #75231
The behavior is now consistent with ReflectionMethod.
Bugs:
https://bugs.php.net/75231
Changed paths:
M NEWS
M ext/reflection/php_reflection.c
A ext/reflection/tests/bug75231.phpt
Diff:
diff --git a/NEWS b/NEWS
index 3e208f1..d4ebb9a 100644
--- a/NEWS
+++ b/NEWS
@@ -36,6 +36,8 @@ PHP NEWS
- Reflection:
. Fixed bug #76536 (PHP crashes with core dump when throwing exception in
error handler). (Laruence)
+ . Fixed bug #75231 (ReflectionProperty#getValue() incorrectly works with
+ inherited classes). (Nikita)
- Standard:
. Fixed bug #76505 (array_merge_recursive() is duplicating sub-array keys).
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index 95b86e7..690aaa0 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -5645,7 +5645,7 @@ ZEND_METHOD(reflection_property, getValue)
return;
}
- if (!instanceof_function(Z_OBJCE_P(object), ref->ce)) {
+ if (!instanceof_function(Z_OBJCE_P(object), ref->prop.ce)) {
_DO_THROW("Given object is not an instance of the class this property was declared
in");
/* Returns from this function */
}
diff --git a/ext/reflection/tests/bug75231.phpt b/ext/reflection/tests/bug75231.phpt
new file mode 100644
index 0000000..5aff0be
--- /dev/null
+++ b/ext/reflection/tests/bug75231.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Bug #75231: ReflectionProperty#getValue() incorrectly works with inherited classes
+--FILE--
+<?php
+class A
+{
+ public $prop;
+ public function __construct()
+ {
+ $this->prop = 'prop';
+ }
+ public function method()
+ {
+ return 'method';
+ }
+}
+class B extends A
+{
+}
+print_r((new ReflectionMethod(B::class, 'method'))->invoke(new A()).PHP_EOL);
+print_r((new ReflectionProperty(B::class, 'prop'))->getValue(new A()).PHP_EOL);
+?>
+--EXPECT--
+method
+prop