Edit report at https://bugs.php.net/bug.php?id=63857&edit=1
ID: 63857
User updated by: alexander dot moldova at gmail dot com
Reported by: alexander dot moldova at gmail dot com
Summary: calling closure when providing it as an arg from the
args array
Status: Not a bug
Type: Bug
Package: Reflection related
Operating System: ubuntu 12.10
PHP Version: 5.4.10
Block user comment: N
Private report: N
New Comment:
yeap, i've already realized, thanks )
Previous Comments:
------------------------------------------------------------------------
[2012-12-26 15:50:52] [email protected]
>From the error message, the closure declared like: function(array $param);
see http://php.net/call_user_func_array
so :
call_user_func_array($b, $c) + $a; <=> call_user_func_array($b, array(2)) + 0;
and <=> $closure(2);
2 is not an array
------------------------------------------------------------------------
[2012-12-26 15:32:04] alexander dot moldova at gmail dot com
Description:
------------
calling closure when providing it as an arg from the args array provided as the
second parameter for the invokeArgs method from \ReflectionMethod class
Test script:
---------------
method is:
public function simpleTest($a, callable $b, array $c)
{
return (int) call_user_func_array($b, $c) + $a;
}
$params is:
array (size=3)
0 => int 2
1 =>
object(Closure)[95]
2 =>
array (size=1)
0 => int 2
and calling:
$this->refl->invokeArgs(new Blablabla, $params);
will generate the bug
Expected result:
----------------
method returning value
Actual result:
--------------
Error: Argument 1 passed to {closure}() must be of the type array, integer given
In fact instead or the array is provided the "int 2"
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=63857&edit=1