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