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