1--TEST--
2Deprecation of self/parent/static in callables
3--FILE--
4<?php
5
6class A {
7    public function foo() {}
8}
9class B extends A {
10    public function test() {
11        // Different callables using self/parent/static
12        $variants = [
13            '"self::foo"'            => "self::foo",
14            '"parent::foo"'          => "parent::foo",
15            '"static::foo"'          => "static::foo",
16            '["self", "foo"]'        => ["self", "foo"],
17            '["parent", "foo"]'      => ["parent", "foo"],
18            '["static", "foo"]'      => ["static", "foo"],
19            '["B", "self::foo"]'     => ["B", "self::foo"],
20            '["B", "parent::foo"]'   => ["B", "parent::foo"],
21            '["B", "static::foo"]'   => ["B", "static::foo"],
22            '["B", "A::foo"]'        => ["B", "A::foo"],
23            '[$this, "self::foo"]'   => [$this, "self::foo"],
24            '[$this, "parent::foo"]' => [$this, "parent::foo"],
25            '[$this, "static::foo"]' => [$this, "static::foo"],
26            '[$this, "A::foo"]'      => [$this, "A::foo"],
27        ];
28
29        echo "==> Test call_user_func\n";
30        foreach ($variants as $description => $callable) {
31            echo "$description\n";
32            call_user_func($callable);
33        }
34        echo "\n==> Test call_user_func_array\n";
35        foreach ($variants as $description => $callable) {
36                    echo "$description\n";
37            call_user_func_array($callable, []);
38        }
39
40        // Also applies to other things performing calls
41        echo "\n==> Test array_map\n";
42        foreach ($variants as $description => $callable) {
43            echo "$description\n";
44            array_map($callable, [1]);
45        }
46
47        echo "\n==> Test is_callable()\n";
48        foreach ($variants as $description => $callable) {
49            echo "$description\n";
50            var_dump(is_callable($callable));
51        }
52
53        echo "\n==> Test callable type hint\n";
54        foreach ($variants as $description => $callable) {
55            echo "$description\n";
56            $this->callableTypeHint($callable);
57        }
58    }
59
60    public function callableTypeHint(callable $c) {}
61}
62
63$b = new B;
64$b->test();
65
66?>
67--EXPECTF--
68==> Test call_user_func
69"self::foo"
70
71Deprecated: Use of "self" in callables is deprecated in %s on line %d
72"parent::foo"
73
74Deprecated: Use of "parent" in callables is deprecated in %s on line %d
75"static::foo"
76
77Deprecated: Use of "static" in callables is deprecated in %s on line %d
78["self", "foo"]
79
80Deprecated: Use of "self" in callables is deprecated in %s on line %d
81["parent", "foo"]
82
83Deprecated: Use of "parent" in callables is deprecated in %s on line %d
84["static", "foo"]
85
86Deprecated: Use of "static" in callables is deprecated in %s on line %d
87["B", "self::foo"]
88
89Deprecated: Callables of the form ["B", "self::foo"] are deprecated in %s on line %d
90["B", "parent::foo"]
91
92Deprecated: Callables of the form ["B", "parent::foo"] are deprecated in %s on line %d
93["B", "static::foo"]
94
95Deprecated: Callables of the form ["B", "static::foo"] are deprecated in %s on line %d
96["B", "A::foo"]
97
98Deprecated: Callables of the form ["B", "A::foo"] are deprecated in %s on line %d
99[$this, "self::foo"]
100
101Deprecated: Callables of the form ["B", "self::foo"] are deprecated in %s on line %d
102[$this, "parent::foo"]
103
104Deprecated: Callables of the form ["B", "parent::foo"] are deprecated in %s on line %d
105[$this, "static::foo"]
106
107Deprecated: Callables of the form ["B", "static::foo"] are deprecated in %s on line %d
108[$this, "A::foo"]
109
110Deprecated: Callables of the form ["B", "A::foo"] are deprecated in %s on line %d
111
112==> Test call_user_func_array
113"self::foo"
114
115Deprecated: Use of "self" in callables is deprecated in %s on line %d
116"parent::foo"
117
118Deprecated: Use of "parent" in callables is deprecated in %s on line %d
119"static::foo"
120
121Deprecated: Use of "static" in callables is deprecated in %s on line %d
122["self", "foo"]
123
124Deprecated: Use of "self" in callables is deprecated in %s on line %d
125["parent", "foo"]
126
127Deprecated: Use of "parent" in callables is deprecated in %s on line %d
128["static", "foo"]
129
130Deprecated: Use of "static" in callables is deprecated in %s on line %d
131["B", "self::foo"]
132
133Deprecated: Callables of the form ["B", "self::foo"] are deprecated in %s on line %d
134["B", "parent::foo"]
135
136Deprecated: Callables of the form ["B", "parent::foo"] are deprecated in %s on line %d
137["B", "static::foo"]
138
139Deprecated: Callables of the form ["B", "static::foo"] are deprecated in %s on line %d
140["B", "A::foo"]
141
142Deprecated: Callables of the form ["B", "A::foo"] are deprecated in %s on line %d
143[$this, "self::foo"]
144
145Deprecated: Callables of the form ["B", "self::foo"] are deprecated in %s on line %d
146[$this, "parent::foo"]
147
148Deprecated: Callables of the form ["B", "parent::foo"] are deprecated in %s on line %d
149[$this, "static::foo"]
150
151Deprecated: Callables of the form ["B", "static::foo"] are deprecated in %s on line %d
152[$this, "A::foo"]
153
154Deprecated: Callables of the form ["B", "A::foo"] are deprecated in %s on line %d
155
156==> Test array_map
157"self::foo"
158
159Deprecated: Use of "self" in callables is deprecated in %s on line %d
160"parent::foo"
161
162Deprecated: Use of "parent" in callables is deprecated in %s on line %d
163"static::foo"
164
165Deprecated: Use of "static" in callables is deprecated in %s on line %d
166["self", "foo"]
167
168Deprecated: Use of "self" in callables is deprecated in %s on line %d
169["parent", "foo"]
170
171Deprecated: Use of "parent" in callables is deprecated in %s on line %d
172["static", "foo"]
173
174Deprecated: Use of "static" in callables is deprecated in %s on line %d
175["B", "self::foo"]
176
177Deprecated: Callables of the form ["B", "self::foo"] are deprecated in %s on line %d
178["B", "parent::foo"]
179
180Deprecated: Callables of the form ["B", "parent::foo"] are deprecated in %s on line %d
181["B", "static::foo"]
182
183Deprecated: Callables of the form ["B", "static::foo"] are deprecated in %s on line %d
184["B", "A::foo"]
185
186Deprecated: Callables of the form ["B", "A::foo"] are deprecated in %s on line %d
187[$this, "self::foo"]
188
189Deprecated: Callables of the form ["B", "self::foo"] are deprecated in %s on line %d
190[$this, "parent::foo"]
191
192Deprecated: Callables of the form ["B", "parent::foo"] are deprecated in %s on line %d
193[$this, "static::foo"]
194
195Deprecated: Callables of the form ["B", "static::foo"] are deprecated in %s on line %d
196[$this, "A::foo"]
197
198Deprecated: Callables of the form ["B", "A::foo"] are deprecated in %s on line %d
199
200==> Test is_callable()
201"self::foo"
202
203Deprecated: Use of "self" in callables is deprecated in %s on line %d
204bool(true)
205"parent::foo"
206
207Deprecated: Use of "parent" in callables is deprecated in %s on line %d
208bool(true)
209"static::foo"
210
211Deprecated: Use of "static" in callables is deprecated in %s on line %d
212bool(true)
213["self", "foo"]
214
215Deprecated: Use of "self" in callables is deprecated in %s on line %d
216bool(true)
217["parent", "foo"]
218
219Deprecated: Use of "parent" in callables is deprecated in %s on line %d
220bool(true)
221["static", "foo"]
222
223Deprecated: Use of "static" in callables is deprecated in %s on line %d
224bool(true)
225["B", "self::foo"]
226
227Deprecated: Callables of the form ["B", "self::foo"] are deprecated in %s on line %d
228bool(true)
229["B", "parent::foo"]
230
231Deprecated: Callables of the form ["B", "parent::foo"] are deprecated in %s on line %d
232bool(true)
233["B", "static::foo"]
234
235Deprecated: Callables of the form ["B", "static::foo"] are deprecated in %s on line %d
236bool(true)
237["B", "A::foo"]
238
239Deprecated: Callables of the form ["B", "A::foo"] are deprecated in %s on line %d
240bool(true)
241[$this, "self::foo"]
242
243Deprecated: Callables of the form ["B", "self::foo"] are deprecated in %s on line %d
244bool(true)
245[$this, "parent::foo"]
246
247Deprecated: Callables of the form ["B", "parent::foo"] are deprecated in %s on line %d
248bool(true)
249[$this, "static::foo"]
250
251Deprecated: Callables of the form ["B", "static::foo"] are deprecated in %s on line %d
252bool(true)
253[$this, "A::foo"]
254
255Deprecated: Callables of the form ["B", "A::foo"] are deprecated in %s on line %d
256bool(true)
257
258==> Test callable type hint
259"self::foo"
260
261Deprecated: Use of "self" in callables is deprecated in %s on line %d
262"parent::foo"
263
264Deprecated: Use of "parent" in callables is deprecated in %s on line %d
265"static::foo"
266
267Deprecated: Use of "static" in callables is deprecated in %s on line %d
268["self", "foo"]
269
270Deprecated: Use of "self" in callables is deprecated in %s on line %d
271["parent", "foo"]
272
273Deprecated: Use of "parent" in callables is deprecated in %s on line %d
274["static", "foo"]
275
276Deprecated: Use of "static" in callables is deprecated in %s on line %d
277["B", "self::foo"]
278
279Deprecated: Callables of the form ["B", "self::foo"] are deprecated in %s on line %d
280["B", "parent::foo"]
281
282Deprecated: Callables of the form ["B", "parent::foo"] are deprecated in %s on line %d
283["B", "static::foo"]
284
285Deprecated: Callables of the form ["B", "static::foo"] are deprecated in %s on line %d
286["B", "A::foo"]
287
288Deprecated: Callables of the form ["B", "A::foo"] are deprecated in %s on line %d
289[$this, "self::foo"]
290
291Deprecated: Callables of the form ["B", "self::foo"] are deprecated in %s on line %d
292[$this, "parent::foo"]
293
294Deprecated: Callables of the form ["B", "parent::foo"] are deprecated in %s on line %d
295[$this, "static::foo"]
296
297Deprecated: Callables of the form ["B", "static::foo"] are deprecated in %s on line %d
298[$this, "A::foo"]
299
300Deprecated: Callables of the form ["B", "A::foo"] are deprecated in %s on line %d
301