Bug #75231 [Asn->Csd]: ReflectionProperty#getValue() incorrectly works with inherited classes.
| From: | nikic@php.net | Date: | Mon, 02 Jul 2018 16:58:37 +0000 |
| Subject: | Bug #75231 [Asn->Csd]: ReflectionProperty#getValue() incorrectly works with inherited classes. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-216075@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: nikic@php.net
Reported by: t at elless dot me
Summary: ReflectionProperty#getValue() incorrectly works with
inherited classes.
-Status: Assigned
+Status: Closed
Type: Bug
Package: Reflection related
Operating System: Linux (CentOS)
PHP Version: 7.1.9
Assigned To: krakjoe
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of nikita.ppv@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=c97b8bbf8252c3a493a44bcb91fb137952f03710
Log: Fixed bug #75231
Previous Comments:
------------------------------------------------------------------------
[2017-09-20 11:51:51] cmb@php.net
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>
------------------------------------------------------------------------
[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