summaryrefslogtreecommitdiff
path: root/ext/reflection/tests/ReflectionParameter_canBePassedByValue.phpt
blob: 5655d19972a2ed6b72326e2faf25bc67abb1d9d7 (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
--TEST--
ReflectionParameter class - canBePassedByValue() method.
--FILE--
<?php

function aux($fun) {

    $func = new ReflectionFunction($fun);
    $parameters = $func->getParameters();
    foreach($parameters as $parameter) {
        echo "Name: ", $parameter->getName(), "\n";
        echo "Is passed by reference: ", $parameter->isPassedByReference()?"yes":"no", "\n";
        echo "Can be passed by value: ", $parameter->canBePassedByValue()?"yes":"no", "\n";
        echo "\n";
    }

}

echo "=> array_multisort:\n\n";

aux('array_multisort');


echo "=> sort:\n\n";

aux('sort');

echo "=> user function:\n\n";

function ufunc(&$arg1, $arg2) {}

aux('ufunc');

echo "Done.\n";

?>
--EXPECTF--
=> array_multisort:

Name: arr1
Is passed by reference: yes
Can be passed by value: yes

Name: sort_order
Is passed by reference: yes
Can be passed by value: yes

Name: sort_flags
Is passed by reference: yes
Can be passed by value: yes

Name: arr2
Is passed by reference: yes
Can be passed by value: yes

=> sort:

Name: arg
Is passed by reference: yes
Can be passed by value: no

Name: sort_flags
Is passed by reference: no
Can be passed by value: yes

=> user function:

Name: arg1
Is passed by reference: yes
Can be passed by value: no

Name: arg2
Is passed by reference: no
Can be passed by value: yes

Done.