xref: /PHP-5.4/ext/reflection/tests/009.phpt (revision 610c7fbe)
1--TEST--
2ReflectionFunction basic tests
3--FILE--
4<?php
5
6/**
7hoho
8*/
9function test ($a, $b = 1, $c = "") {
10	static $var = 1;
11}
12
13$func = new ReflectionFunction("test");
14
15var_dump($func->export("test"));
16echo "--getName--\n";
17var_dump($func->getName());
18echo "--isInternal--\n";
19var_dump($func->isInternal());
20echo "--isUserDefined--\n";
21var_dump($func->isUserDefined());
22echo "--getFilename--\n";
23var_dump($func->getFilename());
24echo "--getStartline--\n";
25var_dump($func->getStartline());
26echo "--getEndline--\n";
27var_dump($func->getEndline());
28echo "--getDocComment--\n";
29var_dump($func->getDocComment());
30echo "--getStaticVariables--\n";
31var_dump($func->getStaticVariables());
32echo "--invoke--\n";
33var_dump($func->invoke(array(1,2,3)));
34echo "--invokeArgs--\n";
35var_dump($func->invokeArgs(array(1,2,3)));
36echo "--returnsReference--\n";
37var_dump($func->returnsReference());
38echo "--getParameters--\n";
39var_dump($func->getParameters());
40echo "--getNumberOfParameters--\n";
41var_dump($func->getNumberOfParameters());
42echo "--getNumberOfRequiredParameters--\n";
43var_dump($func->getNumberOfRequiredParameters());
44
45echo "Done\n";
46
47?>
48--EXPECTF--
49/**
50hoho
51*/
52Function [ <user> function test ] {
53  @@ %s009.php 6 - 8
54
55  - Parameters [3] {
56    Parameter #0 [ <required> $a ]
57    Parameter #1 [ <optional> $b = 1 ]
58    Parameter #2 [ <optional> $c = '' ]
59  }
60}
61
62NULL
63--getName--
64string(4) "test"
65--isInternal--
66bool(false)
67--isUserDefined--
68bool(true)
69--getFilename--
70string(%d) "%s009.php"
71--getStartline--
72int(6)
73--getEndline--
74int(8)
75--getDocComment--
76string(11) "/**
77hoho
78*/"
79--getStaticVariables--
80array(1) {
81  ["var"]=>
82  int(1)
83}
84--invoke--
85NULL
86--invokeArgs--
87NULL
88--returnsReference--
89bool(false)
90--getParameters--
91array(3) {
92  [0]=>
93  &object(ReflectionParameter)#2 (1) {
94    ["name"]=>
95    string(1) "a"
96  }
97  [1]=>
98  &object(ReflectionParameter)#3 (1) {
99    ["name"]=>
100    string(1) "b"
101  }
102  [2]=>
103  &object(ReflectionParameter)#4 (1) {
104    ["name"]=>
105    string(1) "c"
106  }
107}
108--getNumberOfParameters--
109int(3)
110--getNumberOfRequiredParameters--
111int(1)
112Done
113