source: src/router/php7/Zend/tests/dynamic_call_to_ref_returning_function.phpt @ 31874

Last change on this file since 31874 was 31874, checked in by brainslayer, 4 months ago

update php

File size: 791 bytes
Line 
1--TEST--
2When performing a dynamic call to a ret-by-ref function, the reference should be unwrapped
3--FILE--
4<?php
5
6namespace Foo;
7
8function &retRef($x) {
9    return $x;
10}
11
12var_dump(call_user_func('Foo\retRef', 42));
13var_dump(call_user_func_array('Foo\retRef', [42]));
14
15$closure = function &($x) {
16    return $x;
17};
18var_dump($closure->call(new class {}, 42));
19
20var_dump((new \ReflectionFunction('Foo\retRef'))->invoke(42));
21var_dump((new \ReflectionFunction('Foo\retRef'))->invokeArgs([42]));
22
23class Bar {
24    function &method($x) {
25        return $x;
26    }
27}
28var_dump((new \ReflectionMethod('Foo\Bar', 'method'))->invoke(new Bar, 42));
29var_dump((new \ReflectionMethod('Foo\Bar', 'method'))->invokeArgs(new Bar, [42]));
30
31?>
32--EXPECT--
33int(42)
34int(42)
35int(42)
36int(42)
37int(42)
38int(42)
39int(42)
Note: See TracBrowser for help on using the repository browser.