php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69802 Reflection on Closure::__invoke borks type hint class name
Submitted: 2015-06-11 19:08 UTC Modified: 2015-06-16 07:57 UTC
From: nikic@php.net Assigned: dmitry
Status: Closed Package: Reflection related
PHP Version: 7.0Git-2015-06-11 (Git) OS:
Private report: No CVE-ID:
 [2015-06-11 19:08 UTC] nikic@php.net
Description:
------------
<?php

$f = function(stdClass $x) {};
$r = new ReflectionMethod($f, '__invoke');
var_dump($r->getParameters()[0]->getClass());

results in:

Fatal error: Uncaught ReflectionException: Class  does not exist ...

because the via-handler function is INTERNAL, while the arginfo uses USER layout. Basically the comment in http://lxr.php.net/xref/PHP_TRUNK/Zend/zend_closures.c#210 is not true where Reflection is concerned.

Maybe we need another flag to specify the arginfo layout independently from the type of the function?


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-06-11 19:08 UTC] nikic@php.net
-Assigned To: +Assigned To: dmitry
 [2015-06-15 12:45 UTC] dmitry@php.net
Automatic comment on behalf of dmitry@zend.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=33e71d5c20ebdaaee9c4d12a82f65ae2cded7cbc
Log: Fixed bug #69802 (Reflection on Closure::__invoke borks type hint class name)
 [2015-06-15 12:45 UTC] dmitry@php.net
-Status: Assigned +Status: Closed
 [2015-06-16 07:57 UTC] nikic@php.net
-Status: Closed +Status: Re-Opened
 [2015-06-16 07:57 UTC] nikic@php.net
This does not fully fix the issue as the handler function can also be internal. For example:

<?php
$f = (new ReflectionFunction('iterator_to_array'))->getClosure();
$r = new ReflectionMethod($f, '__invoke');
var_dump($r->getParameters()[0]->getClass());

now results in

Fatal error: Allowed memory size of 134217728 bytes exhausted at /home/nikic/php-src/Zend/zend_string.h:98 (tried to allocate 7959380068570588552 bytes) in /home/nikic/php-src/t096.php on line 4
 [2015-06-16 10:30 UTC] dmitry@php.net
Automatic comment on behalf of dmitry@zend.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=3180b8e100285e5bd9088e9981608dfd14f6ff27
Log: Fixed bug #69802 (Reflection on Closure::__invoke borks type hint class name) (onr more problem)
 [2015-06-16 10:30 UTC] dmitry@php.net
-Status: Re-Opened +Status: Closed
 [2015-06-23 18:04 UTC] ab@php.net
Automatic comment on behalf of dmitry@zend.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=3180b8e100285e5bd9088e9981608dfd14f6ff27
Log: Fixed bug #69802 (Reflection on Closure::__invoke borks type hint class name) (onr more problem)
 [2015-06-23 18:04 UTC] ab@php.net
Automatic comment on behalf of dmitry@zend.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=33e71d5c20ebdaaee9c4d12a82f65ae2cded7cbc
Log: Fixed bug #69802 (Reflection on Closure::__invoke borks type hint class name)
 [2016-07-20 11:38 UTC] davey@php.net
Automatic comment on behalf of dmitry@zend.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=3180b8e100285e5bd9088e9981608dfd14f6ff27
Log: Fixed bug #69802 (Reflection on Closure::__invoke borks type hint class name) (onr more problem)
 [2016-07-20 11:38 UTC] davey@php.net
Automatic comment on behalf of dmitry@zend.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=33e71d5c20ebdaaee9c4d12a82f65ae2cded7cbc
Log: Fixed bug #69802 (Reflection on Closure::__invoke borks type hint class name)
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Apr 30 18:01:35 2017 UTC