1--TEST--
2ReflectionParameter class - isPassedByReferenceMethod()
3--CREDITS--
4Robin Fernandes <robinf@php.net>
5Steve Seear <stevseea@php.net>
6--FILE--
7<?php
8class ReflectTestClass {
9    public static function staticMethod(&$paramOne, $anotherParam) {
10        return ++$theIncrement;
11    }
12
13    public function instanceMethod($firstParam, &$secondParam) {
14      $firstParam = "Hello\n";
15    }
16}
17
18// Create an instance of the Reflection_Method class
19$method = new ReflectionMethod('ReflectTestClass', 'staticMethod');
20// Get the parameters
21$parameters = $method->getParameters();
22echo "Parameters from staticMethod:\n\n";
23foreach($parameters as $parameter) {
24    var_dump($parameter);
25    if($parameter->isPassedByReference()) {
26        echo "This param is passed by reference\n";
27    } else {
28        echo "This param is not passed by reference\n";
29    }
30    echo "\n";
31}
32
33// Create an instance of the Reflection_Method class
34$method = new ReflectionMethod('ReflectTestClass', 'instanceMethod');
35// Get the parameters
36$parameters = $method->getParameters();
37echo "Parameters from instanceMethod:\n\n";
38foreach($parameters as $parameter) {
39    var_dump($parameter);
40    if($parameter->isPassedByReference()) {
41        echo "This param is passed by reference\n";
42    } else {
43        echo "This param is not passed by reference\n";
44    }
45    echo "\n";
46}
47
48echo "done\n";
49
50?>
51--EXPECTF--
52Parameters from staticMethod:
53
54object(ReflectionParameter)#%i (1) {
55  ["name"]=>
56  string(8) "paramOne"
57}
58This param is passed by reference
59
60object(ReflectionParameter)#%i (1) {
61  ["name"]=>
62  string(12) "anotherParam"
63}
64This param is not passed by reference
65
66Parameters from instanceMethod:
67
68object(ReflectionParameter)#%i (1) {
69  ["name"]=>
70  string(10) "firstParam"
71}
72This param is not passed by reference
73
74object(ReflectionParameter)#%i (1) {
75  ["name"]=>
76  string(11) "secondParam"
77}
78This param is passed by reference
79
80done
81