xref: /PHP-7.2/ext/reflection/tests/009.phpt (revision 17ccbeec)
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
17var_dump($func->export("test"));
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
64NULL
65--getName--
66string(4) "test"
67--isInternal--
68bool(false)
69--isUserDefined--
70bool(true)
71--getFilename--
72string(%d) "%s009.php"
73--getStartline--
74int(6)
75--getEndline--
76int(8)
77--getDocComment--
78string(%d) "/**
79hoho
80*/"
81--getStaticVariables--
82array(1) {
83  ["var"]=>
84  int(1)
85}
86--invoke--
87NULL
88--invokeArgs--
89NULL
90--returnsReference--
91bool(false)
92--getParameters--
93array(3) {
94  [0]=>
95  object(ReflectionParameter)#2 (1) {
96    ["name"]=>
97    string(1) "a"
98  }
99  [1]=>
100  object(ReflectionParameter)#3 (1) {
101    ["name"]=>
102    string(1) "b"
103  }
104  [2]=>
105  object(ReflectionParameter)#4 (1) {
106    ["name"]=>
107    string(1) "c"
108  }
109}
110--getNumberOfParameters--
111int(3)
112--getNumberOfRequiredParameters--
113int(1)
114Done
115