summaryrefslogtreecommitdiff
path: root/Zend/tests/dynamic_call_to_ref_returning_function.phpt
blob: c4b6a9bcff791e1f2056496cafcf6b8112eefcdd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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)