Bug #75231 [Opn]: ReflectionProperty#getValue() incorrectly works with inherited classes.
| From: | cmb@php.net | Date: | Wed, 20 Sep 2017 11:51:53 +0000 |
| Subject: | Bug #75231 [Opn]: ReflectionProperty#getValue() incorrectly works with inherited classes. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-211262@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=75231&edit=1
ID: 75231
Updated by: cmb@php.net
Reported by: t at elless dot me
Summary: ReflectionProperty#getValue() incorrectly works with
inherited classes.
Status: Open
Type: Bug
Package: Reflection related
Operating System: Linux (CentOS)
PHP Version: 7.1.9
-Assigned To:
+Assigned To: krakjoe
Block user comment: N
Private report: N
New Comment:
It seems to me that the current implementation checks whether the given object
is an instance of the ReflectionProperty object's class property[1]. So indeed,
either the exception message is wrong, or the implementation. Not sure which.
Joe?
[1] <https://github.com/php/php-src/blob/php-7.1.9/ext/reflection/php_reflection.c#L5648>
Previous Comments:
------------------------------------------------------------------------
[2017-09-20 08:22:53] t at elless dot me
Description:
------------
Relates to https://bugs.php.net/bug.php?id=72209
ReflectionProperty#getValue($object) probably incorrectly checks the type of $object.
ReflectionProperty#invoke($object) correctly detect inheritance.
Anyway fix 72209 bug has BC which were not specified in the changes 7.0 => 7.1.
And error message kinda incorrect. "Given object is not an instance of the class this property
was declared in" bug given object is exactly an instance of the class this property was
declared in.
Test script:
---------------
https://gist.github.com/telless/fe942e202b408b1b614faf638d7aea30
Expected result:
----------------
method
prop
Actual result:
--------------
method
PHP Fatal error: Uncaught ReflectionException: Given object is not an instance of the class this
property was declared in in php71reflection.php:23
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=75231&edit=1