Bug #69802 [Csd->ReO]: Reflection on Closure::__invoke borks type hint class name

From: Date: Tue, 16 Jun 2015 07:57:48 +0000
Subject: Bug #69802 [Csd->ReO]: Reflection on Closure::__invoke borks type hint class name
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-193542@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69802&edit=1

 ID:                 69802
 Updated by:         nikic@php.net
 Reported by:        nikic@php.net
 Summary:            Reflection on Closure::__invoke borks type hint
                     class name
-Status:             Closed
+Status:             Re-Opened
 Type:               Bug
 Package:            Reflection related
 PHP Version:        7.0Git-2015-06-11 (Git)
 Assigned To:        dmitry
 Block user comment: N
 Private report:     N

 New Comment:

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


Previous Comments:
------------------------------------------------------------------------
[2015-06-15 12:45:14] 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-11 19:08:12] 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?



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=69802&edit=1


Thread (4 messages)

« previous php.bugs (#193542) next »