Bug #60620 [Com]: ReflectionFunction Internal Error provocation
Edit report at https://bugs.php.net/bug.php?id=60620&edit=1
ID: 60620
Comment by: spam2 at rhsoft dot net
Reported by: hanskrentel at yahoo dot de
Summary: ReflectionFunction Internal Error provocation
Status: Closed
Type: Bug
Package: Reflection related
Operating System: win
PHP Version: 5.3.8
Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
that below is part of my fuzzy-call-suite for string params with work with 7.0/7.1/7.2 perfectly -
you can catch fatal errors starzing with PHP 7.0
try
{
$params[] = $reflection_param->getDefaultValue();
}
catch(Throwable $exception)
{
$params[] = bin2hex(random_bytes(5));
}
Previous Comments:
------------------------------------------------------------------------
[2017-09-13 17:22:21] cmb@php.net
As of PHP 7.0.0 a TypeError is thrown, if the parameter is not a
string, see <https://3v4l.org/DuLJt>.
------------------------------------------------------------------------
[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)