1--TEST--
2ReflectionMethod class __toString() and export() 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 "__toString():\n";
11    var_dump($methodInfo->__toString());
12    echo "\nexport():\n";
13    var_dump(ReflectionMethod::export($class, $method, true));
14    echo "\n**********************************\n";
15}
16
17class TestClass
18{
19    public function foo() {
20        echo "Called foo()\n";
21    }
22
23    static function stat() {
24        echo "Called stat()\n";
25    }
26
27    private function priv() {
28        echo "Called priv()\n";
29    }
30
31    protected function prot() {}
32
33    public function __destruct() {}
34}
35
36class DerivedClass extends TestClass {}
37
38interface TestInterface {
39    public function int();
40}
41
42reflectMethod("DerivedClass", "foo");
43reflectMethod("TestClass", "stat");
44reflectMethod("TestClass", "priv");
45reflectMethod("TestClass", "prot");
46reflectMethod("DerivedClass", "prot");
47reflectMethod("TestInterface", "int");
48reflectMethod("ReflectionProperty", "__construct");
49reflectMethod("TestClass", "__destruct");
50
51?>
52--EXPECTF--
53**********************************
54Reflecting on method DerivedClass::foo()
55
56__toString():
57string(%d) "Method [ <user, inherits TestClass> public method foo ] {
58  @@ %s 16 - 18
59}
60"
61
62export():
63
64Deprecated: Function ReflectionMethod::export() is deprecated in %s on line %d
65string(%d) "Method [ <user, inherits TestClass> public method foo ] {
66  @@ %s 16 - 18
67}
68"
69
70**********************************
71**********************************
72Reflecting on method TestClass::stat()
73
74__toString():
75string(%d) "Method [ <user> static public method stat ] {
76  @@ %s 20 - 22
77}
78"
79
80export():
81
82Deprecated: Function ReflectionMethod::export() is deprecated in %s on line %d
83string(%d) "Method [ <user> static public method stat ] {
84  @@ %s 20 - 22
85}
86"
87
88**********************************
89**********************************
90Reflecting on method TestClass::priv()
91
92__toString():
93string(%d) "Method [ <user> private method priv ] {
94  @@ %s 24 - 26
95}
96"
97
98export():
99
100Deprecated: Function ReflectionMethod::export() is deprecated in %s on line %d
101string(%d) "Method [ <user> private method priv ] {
102  @@ %s 24 - 26
103}
104"
105
106**********************************
107**********************************
108Reflecting on method TestClass::prot()
109
110__toString():
111string(%d) "Method [ <user> protected method prot ] {
112  @@ %s 28 - 28
113}
114"
115
116export():
117
118Deprecated: Function ReflectionMethod::export() is deprecated in %s on line %d
119string(%d) "Method [ <user> protected method prot ] {
120  @@ %s 28 - 28
121}
122"
123
124**********************************
125**********************************
126Reflecting on method DerivedClass::prot()
127
128__toString():
129string(%d) "Method [ <user, inherits TestClass> protected method prot ] {
130  @@ %s 28 - 28
131}
132"
133
134export():
135
136Deprecated: Function ReflectionMethod::export() is deprecated in %s on line %d
137string(%d) "Method [ <user, inherits TestClass> protected method prot ] {
138  @@ %s 28 - 28
139}
140"
141
142**********************************
143**********************************
144Reflecting on method TestInterface::int()
145
146__toString():
147string(%d) "Method [ <user> abstract public method int ] {
148  @@ %s 36 - 36
149}
150"
151
152export():
153
154Deprecated: Function ReflectionMethod::export() is deprecated in %s on line %d
155string(%d) "Method [ <user> abstract public method int ] {
156  @@ %s 36 - 36
157}
158"
159
160**********************************
161**********************************
162Reflecting on method ReflectionProperty::__construct()
163
164__toString():
165string(%d) "Method [ <internal:Reflection, ctor> public method __construct ] {
166
167  - Parameters [2] {
168    Parameter #0 [ <required> $class ]
169    Parameter #1 [ <required> $name ]
170  }
171}
172"
173
174export():
175
176Deprecated: Function ReflectionMethod::export() is deprecated in %s on line %d
177string(%d) "Method [ <internal:Reflection, ctor> public method __construct ] {
178
179  - Parameters [2] {
180    Parameter #0 [ <required> $class ]
181    Parameter #1 [ <required> $name ]
182  }
183}
184"
185
186**********************************
187**********************************
188Reflecting on method TestClass::__destruct()
189
190__toString():
191string(%d) "Method [ <user, dtor> public method __destruct ] {
192  @@ %s 30 - 30
193}
194"
195
196export():
197
198Deprecated: Function ReflectionMethod::export() is deprecated in %s on line %d
199string(%d) "Method [ <user, dtor> public method __destruct ] {
200  @@ %s 30 - 30
201}
202"
203
204**********************************
205