4 changed files with 63 additions and 0 deletions
-
39Zend/tests/dynamic_call_to_ref_returning_function.phpt
-
3Zend/zend_closures.c
-
9ext/reflection/php_reflection.c
-
12ext/standard/basic_functions.c
@ -0,0 +1,39 @@ |
|||
--TEST-- |
|||
When performing a dynamic call to a ret-by-ref function, the reference should be unwrapped |
|||
--FILE-- |
|||
<?php |
|||
|
|||
namespace Foo; |
|||
|
|||
function &retRef($x) { |
|||
return $x; |
|||
} |
|||
|
|||
var_dump(call_user_func('Foo\retRef', 42)); |
|||
var_dump(call_user_func_array('Foo\retRef', [42])); |
|||
|
|||
$closure = function &($x) { |
|||
return $x; |
|||
}; |
|||
var_dump($closure->call(new class {}, 42)); |
|||
|
|||
var_dump((new \ReflectionFunction('Foo\retRef'))->invoke(42)); |
|||
var_dump((new \ReflectionFunction('Foo\retRef'))->invokeArgs([42])); |
|||
|
|||
class Bar { |
|||
function &method($x) { |
|||
return $x; |
|||
} |
|||
} |
|||
var_dump((new \ReflectionMethod('Foo\Bar', 'method'))->invoke(new Bar, 42)); |
|||
var_dump((new \ReflectionMethod('Foo\Bar', 'method'))->invokeArgs(new Bar, [42])); |
|||
|
|||
?> |
|||
--EXPECT-- |
|||
int(42) |
|||
int(42) |
|||
int(42) |
|||
int(42) |
|||
int(42) |
|||
int(42) |
|||
int(42) |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue