1--TEST--
2ReflectionMethod class getFileName(), getStartLine() and getEndLine() methods
3--FILE--
4<?php
5
6function reflectMethod($class, $method) {
7    $methodInfo = new ReflectionMethod($class, $method);
8    echo "**********************************\n";
9    echo "Reflecting on method $class::$method()\n\n";
10    echo "\ngetFileName():\n";
11    var_dump($methodInfo->getFileName());
12    echo "\ngetStartLine():\n";
13    var_dump($methodInfo->getStartLine());
14    echo "\ngetEndLine():\n";
15    var_dump($methodInfo->getEndLine());
16    echo "\n**********************************\n";
17}
18
19class TestClass
20{
21    public function foo() {
22
23
24        echo "Called foo()\n";
25
26
27    }
28
29    static function stat() {
30        echo "Called stat()\n";
31    }
32
33    private function priv() {
34        echo "Called priv()\n";
35    }
36
37    protected function prot() {}
38
39    public function __destruct() {}
40}
41
42class DerivedClass extends TestClass {}
43
44interface TestInterface {
45    public function int();
46}
47
48reflectMethod("DerivedClass", "foo");
49reflectMethod("TestClass", "stat");
50reflectMethod("TestClass", "priv");
51reflectMethod("TestClass", "prot");
52reflectMethod("DerivedClass", "prot");
53reflectMethod("TestInterface", "int");
54reflectMethod("ReflectionProperty", "__construct");
55reflectMethod("TestClass", "__destruct");
56
57?>
58--EXPECTF--
59**********************************
60Reflecting on method DerivedClass::foo()
61
62
63getFileName():
64string(%d) "%sReflectionMethod_basic4.php"
65
66getStartLine():
67int(18)
68
69getEndLine():
70int(24)
71
72**********************************
73**********************************
74Reflecting on method TestClass::stat()
75
76
77getFileName():
78string(%d) "%sReflectionMethod_basic4.php"
79
80getStartLine():
81int(26)
82
83getEndLine():
84int(28)
85
86**********************************
87**********************************
88Reflecting on method TestClass::priv()
89
90
91getFileName():
92string(%d) "%sReflectionMethod_basic4.php"
93
94getStartLine():
95int(30)
96
97getEndLine():
98int(32)
99
100**********************************
101**********************************
102Reflecting on method TestClass::prot()
103
104
105getFileName():
106string(%d) "%sReflectionMethod_basic4.php"
107
108getStartLine():
109int(34)
110
111getEndLine():
112int(34)
113
114**********************************
115**********************************
116Reflecting on method DerivedClass::prot()
117
118
119getFileName():
120string(%d) "%sReflectionMethod_basic4.php"
121
122getStartLine():
123int(34)
124
125getEndLine():
126int(34)
127
128**********************************
129**********************************
130Reflecting on method TestInterface::int()
131
132
133getFileName():
134string(%d) "%sReflectionMethod_basic4.php"
135
136getStartLine():
137int(42)
138
139getEndLine():
140int(42)
141
142**********************************
143**********************************
144Reflecting on method ReflectionProperty::__construct()
145
146
147getFileName():
148bool(false)
149
150getStartLine():
151bool(false)
152
153getEndLine():
154bool(false)
155
156**********************************
157**********************************
158Reflecting on method TestClass::__destruct()
159
160
161getFileName():
162string(%d) "%sReflectionMethod_basic4.php"
163
164getStartLine():
165int(36)
166
167getEndLine():
168int(36)
169
170**********************************
171