xref: /php-src/ext/reflection/tests/009.phpt (revision f8d79582)
1--TEST--
2ReflectionFunction basic tests
3--INI--
4opcache.save_comments=1
5--FILE--
6<?php
7
8/**
9hoho
10*/
11function test ($a, $b = 1, $c = "") {
12    static $var = 1;
13}
14
15$func = new ReflectionFunction("test");
16
17echo $func;
18echo "--getName--\n";
19var_dump($func->getName());
20echo "--isInternal--\n";
21var_dump($func->isInternal());
22echo "--isUserDefined--\n";
23var_dump($func->isUserDefined());
24echo "--getFilename--\n";
25var_dump($func->getFilename());
26echo "--getStartline--\n";
27var_dump($func->getStartline());
28echo "--getEndline--\n";
29var_dump($func->getEndline());
30echo "--getDocComment--\n";
31var_dump($func->getDocComment());
32echo "--getStaticVariables--\n";
33var_dump($func->getStaticVariables());
34echo "--invoke--\n";
35var_dump($func->invoke(array(1,2,3)));
36echo "--invokeArgs--\n";
37var_dump($func->invokeArgs(array(1,2,3)));
38echo "--returnsReference--\n";
39var_dump($func->returnsReference());
40echo "--getParameters--\n";
41var_dump($func->getParameters());
42echo "--getNumberOfParameters--\n";
43var_dump($func->getNumberOfParameters());
44echo "--getNumberOfRequiredParameters--\n";
45var_dump($func->getNumberOfRequiredParameters());
46
47echo "Done\n";
48
49?>
50--EXPECTF--
51/**
52hoho
53*/
54Function [ <user> function test ] {
55  @@ %s009.php 6 - 8
56
57  - Parameters [3] {
58    Parameter #0 [ <required> $a ]
59    Parameter #1 [ <optional> $b = 1 ]
60    Parameter #2 [ <optional> $c = '' ]
61  }
62}
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(%d) "/**
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