Bug #60620 [Opn->Csd]: ReflectionFunction Internal Error provocation
Edit report at https://bugs.php.net/bug.php?id=60620&edit=1
ID: 60620
Updated by: cmb@php.net
Reported by: hanskrentel at yahoo dot de
Summary: ReflectionFunction Internal Error provocation
-Status: Open
+Status: Closed
Type: Bug
Package: Reflection related
Operating System: win
PHP Version: 5.3.8
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
As of PHP 7.0.0 a TypeError is thrown, if the parameter is not a
string, see <https://3v4l.org/DuLJt>.
Previous Comments:
------------------------------------------------------------------------
[2011-12-29 01:37:38] hanskrentel at yahoo dot de
Description:
------------
Normally Instantiation fails (ReflectionException):
$test = new ReflectionFunction('');
However this can be fooled:
$obj = new stdClass();
$test = new ReflectionFunction($obj);
echo $test;
The echo line triggers a fatal error then:
Fatal error: ReflectionFunction::__toString(): Internal error: Failed to
retrieve the reflection object
Before that happens there is a slightly misworded warning ahead:
Warning: ReflectionFunction::__construct() expects parameter 1 to be string,
object given
Misworded in the sense that it's possible objects with __toString() and
closures.
Probably something in the logic inside the constructor is not right. It would be
good if in such cases an ReflectionException is thrown on instantiation.
Test script:
---------------
$obj = new stdClass();
$test = new ReflectionFunction($obj);
echo $test;
Expected result:
----------------
ReflectionException
Actual result:
--------------
Fatal Error
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=60620&edit=1
Thread (7 messages)