1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* PHPCompatibility_Sniffs_PHP_NewIniDirectivesSniff. |
4
|
|
|
* |
5
|
|
|
* @category PHP |
6
|
|
|
* @package PHPCompatibility |
7
|
|
|
* @author Wim Godden <[email protected]> |
8
|
|
|
* @copyright 2013 Cu.be Solutions bvba |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* PHPCompatibility_Sniffs_PHP_NewIniDirectivesSniff. |
13
|
|
|
* |
14
|
|
|
* Discourages the use of new INI directives through ini_set() or ini_get(). |
15
|
|
|
* |
16
|
|
|
* @category PHP |
17
|
|
|
* @package PHPCompatibility |
18
|
|
|
* @author Wim Godden <[email protected]> |
19
|
|
|
* @copyright 2013 Cu.be Solutions bvba |
20
|
|
|
*/ |
21
|
|
|
class PHPCompatibility_Sniffs_PHP_NewIniDirectivesSniff extends PHPCompatibility_AbstractNewFeatureSniff |
|
|
|
|
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* A list of new INI directives |
25
|
|
|
* |
26
|
|
|
* The array lists : version number with false (not present) or true (present). |
27
|
|
|
* If's sufficient to list the first version where the ini directive appears. |
28
|
|
|
* |
29
|
|
|
* @var array(string) |
30
|
|
|
*/ |
31
|
|
|
protected $newIniDirectives = array( |
32
|
|
|
'auto_globals_jit' => array( |
33
|
|
|
'4.4' => false, |
34
|
|
|
'5.0' => true, |
35
|
|
|
), |
36
|
|
|
'com.code_page' => array( |
37
|
|
|
'4.4' => false, |
38
|
|
|
'5.0' => true, |
39
|
|
|
), |
40
|
|
|
'date.default_latitude' => array( |
41
|
|
|
'4.4' => false, |
42
|
|
|
'5.0' => true, |
43
|
|
|
), |
44
|
|
|
'date.default_longitude' => array( |
45
|
|
|
'4.4' => false, |
46
|
|
|
'5.0' => true, |
47
|
|
|
), |
48
|
|
|
'date.sunrise_zenith' => array( |
49
|
|
|
'4.4' => false, |
50
|
|
|
'5.0' => true, |
51
|
|
|
), |
52
|
|
|
'date.sunset_zenith' => array( |
53
|
|
|
'4.4' => false, |
54
|
|
|
'5.0' => true, |
55
|
|
|
), |
56
|
|
|
'ibase.default_charset' => array( |
57
|
|
|
'4.4' => false, |
58
|
|
|
'5.0' => true, |
59
|
|
|
), |
60
|
|
|
'ibase.default_db' => array( |
61
|
|
|
'4.4' => false, |
62
|
|
|
'5.0' => true, |
63
|
|
|
), |
64
|
|
|
'mail.force_extra_parameters' => array( |
65
|
|
|
'4.4' => false, |
66
|
|
|
'5.0' => true, |
67
|
|
|
), |
68
|
|
|
'mime_magic.debug' => array( |
69
|
|
|
'4.4' => false, |
70
|
|
|
'5.0' => true, |
71
|
|
|
), |
72
|
|
|
'mysqli.max_links' => array( |
73
|
|
|
'4.4' => false, |
74
|
|
|
'5.0' => true, |
75
|
|
|
), |
76
|
|
|
'mysqli.default_port' => array( |
77
|
|
|
'4.4' => false, |
78
|
|
|
'5.0' => true, |
79
|
|
|
), |
80
|
|
|
'mysqli.default_socket' => array( |
81
|
|
|
'4.4' => false, |
82
|
|
|
'5.0' => true, |
83
|
|
|
), |
84
|
|
|
'mysqli.default_host' => array( |
85
|
|
|
'4.4' => false, |
86
|
|
|
'5.0' => true, |
87
|
|
|
), |
88
|
|
|
'mysqli.default_user' => array( |
89
|
|
|
'4.4' => false, |
90
|
|
|
'5.0' => true, |
91
|
|
|
), |
92
|
|
|
'mysqli.default_pw' => array( |
93
|
|
|
'4.4' => false, |
94
|
|
|
'5.0' => true, |
95
|
|
|
), |
96
|
|
|
'report_zend_debug' => array( |
97
|
|
|
'4.4' => false, |
98
|
|
|
'5.0' => true, |
99
|
|
|
), |
100
|
|
|
'session.hash_bits_per_character' => array( |
101
|
|
|
'4.4' => false, |
102
|
|
|
'5.0' => true, |
103
|
|
|
), |
104
|
|
|
'session.hash_function' => array( |
105
|
|
|
'4.4' => false, |
106
|
|
|
'5.0' => true, |
107
|
|
|
), |
108
|
|
|
'soap.wsdl_cache_dir' => array( |
109
|
|
|
'4.4' => false, |
110
|
|
|
'5.0' => true, |
111
|
|
|
), |
112
|
|
|
'soap.wsdl_cache_enabled' => array( |
113
|
|
|
'4.4' => false, |
114
|
|
|
'5.0' => true, |
115
|
|
|
), |
116
|
|
|
'soap.wsdl_cache_ttl' => array( |
117
|
|
|
'4.4' => false, |
118
|
|
|
'5.0' => true, |
119
|
|
|
), |
120
|
|
|
'sqlite.assoc_case' => array( |
121
|
|
|
'4.4' => false, |
122
|
|
|
'5.0' => true, |
123
|
|
|
), |
124
|
|
|
'tidy.clean_output' => array( |
125
|
|
|
'4.4' => false, |
126
|
|
|
'5.0' => true, |
127
|
|
|
), |
128
|
|
|
'tidy.default_config' => array( |
129
|
|
|
'4.4' => false, |
130
|
|
|
'5.0' => true, |
131
|
|
|
), |
132
|
|
|
'zend.ze1_compatibility_mode' => array( |
133
|
|
|
'4.4' => false, |
134
|
|
|
'5.0' => true, |
135
|
|
|
), |
136
|
|
|
|
137
|
|
|
'date.timezone' => array( |
138
|
|
|
'5.0' => false, |
139
|
|
|
'5.1' => true, |
140
|
|
|
), |
141
|
|
|
'detect_unicode' => array( |
142
|
|
|
'5.0' => false, |
143
|
|
|
'5.1' => true, |
144
|
|
|
), |
145
|
|
|
'fbsql.batchsize' => array( |
146
|
|
|
'5.0' => false, |
147
|
|
|
'5.1' => true, |
148
|
|
|
'alternative' => 'fbsql.batchSize', |
149
|
|
|
), |
150
|
|
|
'realpath_cache_size' => array( |
151
|
|
|
'5.0' => false, |
152
|
|
|
'5.1' => true, |
153
|
|
|
), |
154
|
|
|
'realpath_cache_ttl' => array( |
155
|
|
|
'5.0' => false, |
156
|
|
|
'5.1' => true, |
157
|
|
|
), |
158
|
|
|
|
159
|
|
|
'mbstring.strict_detection' => array( |
160
|
|
|
'5.1.1' => false, |
161
|
|
|
'5.1.2' => true, |
162
|
|
|
), |
163
|
|
|
'mssql.charset' => array( |
164
|
|
|
'5.1.1' => false, |
165
|
|
|
'5.1.2' => true, |
166
|
|
|
), |
167
|
|
|
|
168
|
|
|
'gd.jpeg_ignore_warning' => array( |
169
|
|
|
'5.1.2' => false, |
170
|
|
|
'5.1.3' => true, |
171
|
|
|
), |
172
|
|
|
|
173
|
|
|
'fbsql.show_timestamp_decimals' => array( |
174
|
|
|
'5.1.4' => false, |
175
|
|
|
'5.1.5' => true, |
176
|
|
|
), |
177
|
|
|
'soap.wsdl_cache' => array( |
178
|
|
|
'5.1.4' => false, |
179
|
|
|
'5.1.5' => true, |
180
|
|
|
), |
181
|
|
|
'soap.wsdl_cache_limit' => array( |
182
|
|
|
'5.1.4' => false, |
183
|
|
|
'5.1.5' => true, |
184
|
|
|
), |
185
|
|
|
|
186
|
|
|
'allow_url_include' => array( |
187
|
|
|
'5.1' => false, |
188
|
|
|
'5.2' => true, |
189
|
|
|
), |
190
|
|
|
'filter.default' => array( |
191
|
|
|
'5.1' => false, |
192
|
|
|
'5.2' => true, |
193
|
|
|
), |
194
|
|
|
'filter.default_flags' => array( |
195
|
|
|
'5.1' => false, |
196
|
|
|
'5.2' => true, |
197
|
|
|
), |
198
|
|
|
'pcre.backtrack_limit' => array( |
199
|
|
|
'5.1' => false, |
200
|
|
|
'5.2' => true, |
201
|
|
|
), |
202
|
|
|
'pcre.recursion_limit' => array( |
203
|
|
|
'5.1' => false, |
204
|
|
|
'5.2' => true, |
205
|
|
|
), |
206
|
|
|
'session.cookie_httponly' => array( |
207
|
|
|
'5.1' => false, |
208
|
|
|
'5.2' => true, |
209
|
|
|
), |
210
|
|
|
|
211
|
|
|
'cgi.check_shebang_line' => array( |
212
|
|
|
'5.2.0' => false, |
213
|
|
|
'5.2.1' => true, |
214
|
|
|
), |
215
|
|
|
|
216
|
|
|
'max_input_nesting_level' => array( |
217
|
|
|
'5.2.2' => false, |
218
|
|
|
'5.2.3' => true, |
219
|
|
|
), |
220
|
|
|
|
221
|
|
|
'mysqli.allow_local_infile' => array( |
222
|
|
|
'5.2.3' => false, |
223
|
|
|
'5.2.4' => true, |
224
|
|
|
), |
225
|
|
|
|
226
|
|
|
'max_file_uploads' => array( |
227
|
|
|
'5.2.11' => false, |
228
|
|
|
'5.2.12' => true, |
229
|
|
|
), |
230
|
|
|
|
231
|
|
|
'cgi.discard_path' => array( |
232
|
|
|
'5.2' => false, |
233
|
|
|
'5.3' => true, |
234
|
|
|
), |
235
|
|
|
'exit_on_timeout' => array( |
236
|
|
|
'5.2' => false, |
237
|
|
|
'5.3' => true, |
238
|
|
|
), |
239
|
|
|
'intl.default_locale' => array( |
240
|
|
|
'5.2' => false, |
241
|
|
|
'5.3' => true, |
242
|
|
|
), |
243
|
|
|
'intl.error_level' => array( |
244
|
|
|
'5.2' => false, |
245
|
|
|
'5.3' => true, |
246
|
|
|
), |
247
|
|
|
'mail.add_x_header' => array( |
248
|
|
|
'5.2' => false, |
249
|
|
|
'5.3' => true, |
250
|
|
|
), |
251
|
|
|
'mail.log' => array( |
252
|
|
|
'5.2' => false, |
253
|
|
|
'5.3' => true, |
254
|
|
|
), |
255
|
|
|
'mbstring.http_output_conv_mimetype' => array( |
256
|
|
|
'5.2' => false, |
257
|
|
|
'5.3' => true, |
258
|
|
|
), |
259
|
|
|
'mysqli.allow_persistent' => array( |
260
|
|
|
'5.2' => false, |
261
|
|
|
'5.3' => true, |
262
|
|
|
), |
263
|
|
|
'mysqli.cache_size' => array( |
264
|
|
|
'5.2' => false, |
265
|
|
|
'5.3' => true, |
266
|
|
|
), |
267
|
|
|
'mysqli.max_persistent' => array( |
268
|
|
|
'5.2' => false, |
269
|
|
|
'5.3' => true, |
270
|
|
|
), |
271
|
|
|
'mysqlnd.collect_memory_statistics' => array( |
272
|
|
|
'5.2' => false, |
273
|
|
|
'5.3' => true, |
274
|
|
|
), |
275
|
|
|
'mysqlnd.collect_statistics' => array( |
276
|
|
|
'5.2' => false, |
277
|
|
|
'5.3' => true, |
278
|
|
|
), |
279
|
|
|
'mysqlnd.debug' => array( |
280
|
|
|
'5.2' => false, |
281
|
|
|
'5.3' => true, |
282
|
|
|
), |
283
|
|
|
'mysqlnd.net_read_buffer_size' => array( |
284
|
|
|
'5.2' => false, |
285
|
|
|
'5.3' => true, |
286
|
|
|
), |
287
|
|
|
'odbc.default_cursortype' => array( |
288
|
|
|
'5.2' => false, |
289
|
|
|
'5.3' => true, |
290
|
|
|
), |
291
|
|
|
'request_order' => array( |
292
|
|
|
'5.2' => false, |
293
|
|
|
'5.3' => true, |
294
|
|
|
), |
295
|
|
|
'user_ini.cache_ttl' => array( |
296
|
|
|
'5.2' => false, |
297
|
|
|
'5.3' => true, |
298
|
|
|
), |
299
|
|
|
'user_ini.filename' => array( |
300
|
|
|
'5.2' => false, |
301
|
|
|
'5.3' => true, |
302
|
|
|
), |
303
|
|
|
'zend.enable_gc' => array( |
304
|
|
|
'5.2' => false, |
305
|
|
|
'5.3' => true, |
306
|
|
|
), |
307
|
|
|
|
308
|
|
|
'curl.cainfo' => array( |
309
|
|
|
'5.3.6' => false, |
310
|
|
|
'5.3.7' => true, |
311
|
|
|
), |
312
|
|
|
|
313
|
|
|
'max_input_vars' => array( |
314
|
|
|
'5.3.8' => false, |
315
|
|
|
'5.3.9' => true, |
316
|
|
|
), |
317
|
|
|
|
318
|
|
|
'sqlite3.extension_dir' => array( |
319
|
|
|
'5.3.10' => false, |
320
|
|
|
'5.3.11' => true, |
321
|
|
|
), |
322
|
|
|
|
323
|
|
|
'cli.pager' => array( |
324
|
|
|
'5.3' => false, |
325
|
|
|
'5.4' => true, |
326
|
|
|
), |
327
|
|
|
'cli.prompt' => array( |
328
|
|
|
'5.3' => false, |
329
|
|
|
'5.4' => true, |
330
|
|
|
), |
331
|
|
|
'cli_server.color' => array( |
332
|
|
|
'5.3' => false, |
333
|
|
|
'5.4' => true, |
334
|
|
|
), |
335
|
|
|
'enable_post_data_reading' => array( |
336
|
|
|
'5.3' => false, |
337
|
|
|
'5.4' => true, |
338
|
|
|
), |
339
|
|
|
'mysqlnd.mempool_default_size' => array( |
340
|
|
|
'5.3' => false, |
341
|
|
|
'5.4' => true, |
342
|
|
|
), |
343
|
|
|
'mysqlnd.net_cmd_buffer_size' => array( |
344
|
|
|
'5.3' => false, |
345
|
|
|
'5.4' => true, |
346
|
|
|
), |
347
|
|
|
'mysqlnd.net_read_timeout' => array( |
348
|
|
|
'5.3' => false, |
349
|
|
|
'5.4' => true, |
350
|
|
|
), |
351
|
|
|
'phar.cache_list' => array( |
352
|
|
|
'5.3' => false, |
353
|
|
|
'5.4' => true, |
354
|
|
|
), |
355
|
|
|
'session.upload_progress.enabled' => array( |
356
|
|
|
'5.3' => false, |
357
|
|
|
'5.4' => true, |
358
|
|
|
), |
359
|
|
|
'session.upload_progress.cleanup' => array( |
360
|
|
|
'5.3' => false, |
361
|
|
|
'5.4' => true, |
362
|
|
|
), |
363
|
|
|
'session.upload_progress.name' => array( |
364
|
|
|
'5.3' => false, |
365
|
|
|
'5.4' => true, |
366
|
|
|
), |
367
|
|
|
'session.upload_progress.freq' => array( |
368
|
|
|
'5.3' => false, |
369
|
|
|
'5.4' => true, |
370
|
|
|
), |
371
|
|
|
'session.upload_progress.min_freq' => array( |
372
|
|
|
'5.3' => false, |
373
|
|
|
'5.4' => true, |
374
|
|
|
), |
375
|
|
|
'session.upload_progress.prefix' => array( |
376
|
|
|
'5.3' => false, |
377
|
|
|
'5.4' => true, |
378
|
|
|
), |
379
|
|
|
'windows_show_crt_warning' => array( |
380
|
|
|
'5.3' => false, |
381
|
|
|
'5.4' => true, |
382
|
|
|
), |
383
|
|
|
'zend.detect_unicode' => array( |
384
|
|
|
'5.3' => false, |
385
|
|
|
'5.4' => true, |
386
|
|
|
'alternative' => 'detect_unicode', |
387
|
|
|
), |
388
|
|
|
'zend.multibyte' => array( |
389
|
|
|
'5.3' => false, |
390
|
|
|
'5.4' => true, |
391
|
|
|
), |
392
|
|
|
'zend.script_encoding' => array( |
393
|
|
|
'5.3' => false, |
394
|
|
|
'5.4' => true, |
395
|
|
|
), |
396
|
|
|
'zend.signal_check' => array( |
397
|
|
|
'5.3' => false, |
398
|
|
|
'5.4' => true, |
399
|
|
|
), |
400
|
|
|
'mysqlnd.log_mask' => array( |
401
|
|
|
'5.3' => false, |
402
|
|
|
'5.4' => true, |
403
|
|
|
), |
404
|
|
|
|
405
|
|
|
'intl.use_exceptions' => array( |
406
|
|
|
'5.4' => false, |
407
|
|
|
'5.5' => true, |
408
|
|
|
), |
409
|
|
|
'mysqlnd.sha256_server_public_key' => array( |
410
|
|
|
'5.4' => false, |
411
|
|
|
'5.5' => true, |
412
|
|
|
), |
413
|
|
|
'mysqlnd.trace_alloc' => array( |
414
|
|
|
'5.4' => false, |
415
|
|
|
'5.5' => true, |
416
|
|
|
), |
417
|
|
|
'sys_temp_dir' => array( |
418
|
|
|
'5.4' => false, |
419
|
|
|
'5.5' => true, |
420
|
|
|
), |
421
|
|
|
'xsl.security_prefs' => array( |
422
|
|
|
'5.4' => false, |
423
|
|
|
'5.5' => true, |
424
|
|
|
), |
425
|
|
|
|
426
|
|
|
'session.use_strict_mode' => array( |
427
|
|
|
'5.5.1' => false, |
428
|
|
|
'5.5.2' => true, |
429
|
|
|
), |
430
|
|
|
|
431
|
|
|
'mysqli.rollback_on_cached_plink' => array( |
432
|
|
|
'5.5' => false, |
433
|
|
|
'5.6' => true, |
434
|
|
|
), |
435
|
|
|
|
436
|
|
|
'assert.exception' => array( |
437
|
|
|
'5.6' => false, |
438
|
|
|
'7.0' => true, |
439
|
|
|
), |
440
|
|
|
'pcre.jit' => array( |
441
|
|
|
'5.6' => false, |
442
|
|
|
'7.0' => true, |
443
|
|
|
), |
444
|
|
|
'session.lazy_write' => array( |
445
|
|
|
'5.6' => false, |
446
|
|
|
'7.0' => true, |
447
|
|
|
), |
448
|
|
|
'zend.assertions' => array( |
449
|
|
|
'5.6' => false, |
450
|
|
|
'7.0' => true, |
451
|
|
|
), |
452
|
|
|
|
453
|
|
|
'session.sid_length' => array( |
454
|
|
|
'7.0' => false, |
455
|
|
|
'7.1' => true, |
456
|
|
|
), |
457
|
|
|
'session.sid_bits_per_character' => array( |
458
|
|
|
'7.0' => false, |
459
|
|
|
'7.1' => true, |
460
|
|
|
), |
461
|
|
|
); |
462
|
|
|
|
463
|
|
|
/** |
464
|
|
|
* Returns an array of tokens this test wants to listen for. |
465
|
|
|
* |
466
|
|
|
* @return array |
467
|
|
|
*/ |
468
|
106 |
|
public function register() |
469
|
|
|
{ |
470
|
106 |
|
return array(T_STRING); |
471
|
|
|
|
472
|
|
|
}//end register() |
473
|
|
|
|
474
|
|
|
/** |
475
|
|
|
* Processes this test, when one of its tokens is encountered. |
476
|
|
|
* |
477
|
|
|
* @param PHP_CodeSniffer_File $phpcsFile The file being scanned. |
478
|
|
|
* @param int $stackPtr The position of the current token in the |
479
|
|
|
* stack passed in $tokens. |
480
|
|
|
* |
481
|
|
|
* @return void |
482
|
|
|
*/ |
483
|
10 |
View Code Duplication |
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) |
|
|
|
|
484
|
|
|
{ |
485
|
10 |
|
$tokens = $phpcsFile->getTokens(); |
486
|
|
|
|
487
|
|
|
$ignore = array( |
488
|
10 |
|
T_DOUBLE_COLON, |
489
|
|
|
T_OBJECT_OPERATOR, |
490
|
|
|
T_FUNCTION, |
491
|
|
|
T_CONST, |
492
|
|
|
); |
493
|
|
|
|
494
|
10 |
|
$prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); |
495
|
10 |
|
if (in_array($tokens[$prevToken]['code'], $ignore) === true) { |
496
|
|
|
// Not a call to a PHP function. |
497
|
10 |
|
return; |
498
|
|
|
} |
499
|
|
|
|
500
|
10 |
|
$functionLc = strtolower($tokens[$stackPtr]['content']); |
501
|
10 |
|
if (isset($this->iniFunctions[$functionLc]) === false) { |
502
|
10 |
|
return; |
503
|
|
|
} |
504
|
|
|
|
505
|
10 |
|
$iniToken = $this->getFunctionCallParameter($phpcsFile, $stackPtr, $this->iniFunctions[$functionLc]); |
506
|
10 |
|
if ($iniToken === false) { |
507
|
|
|
return; |
508
|
|
|
} |
509
|
|
|
|
510
|
10 |
|
$filteredToken = $this->stripQuotes($iniToken['raw']); |
511
|
10 |
|
if (isset($this->newIniDirectives[$filteredToken]) === false) { |
512
|
10 |
|
return; |
513
|
|
|
} |
514
|
|
|
|
515
|
|
|
$itemInfo = array( |
516
|
10 |
|
'name' => $filteredToken, |
517
|
10 |
|
'functionLc' => $functionLc, |
518
|
|
|
); |
519
|
10 |
|
$this->handleFeature($phpcsFile, $iniToken['end'], $itemInfo); |
520
|
|
|
|
521
|
10 |
|
}//end process() |
522
|
|
|
|
523
|
|
|
|
524
|
|
|
/** |
525
|
|
|
* Get the relevant sub-array for a specific item from a multi-dimensional array. |
526
|
|
|
* |
527
|
|
|
* @param array $itemInfo Base information about the item. |
528
|
|
|
* |
529
|
|
|
* @return array Version and other information about the item. |
530
|
|
|
*/ |
531
|
10 |
|
public function getItemArray(array $itemInfo) |
532
|
|
|
{ |
533
|
10 |
|
return $this->newIniDirectives[$itemInfo['name']]; |
534
|
|
|
} |
535
|
|
|
|
536
|
|
|
|
537
|
|
|
/** |
538
|
|
|
* Get an array of the non-PHP-version array keys used in a sub-array. |
539
|
|
|
* |
540
|
|
|
* @return array |
541
|
|
|
*/ |
542
|
10 |
|
protected function getNonVersionArrayKeys() |
543
|
|
|
{ |
544
|
10 |
|
return array('alternative'); |
545
|
|
|
} |
546
|
|
|
|
547
|
|
|
|
548
|
|
|
/** |
549
|
|
|
* Retrieve the relevant detail (version) information for use in an error message. |
550
|
|
|
* |
551
|
|
|
* @param array $itemArray Version and other information about the item. |
552
|
|
|
* @param array $itemInfo Base information about the item. |
553
|
|
|
* |
554
|
|
|
* @return array |
555
|
|
|
*/ |
556
|
10 |
|
public function getErrorInfo(array $itemArray, array $itemInfo) |
557
|
|
|
{ |
558
|
10 |
|
$errorInfo = parent::getErrorInfo($itemArray, $itemInfo); |
559
|
10 |
|
$errorInfo['alternative'] = ''; |
560
|
|
|
|
561
|
10 |
|
if (isset($itemArray['alternative']) === true) { |
562
|
10 |
|
$errorInfo['alternative'] = $itemArray['alternative']; |
563
|
|
|
} |
564
|
|
|
|
565
|
|
|
// Lower error level to warning if the function used was ini_get. |
566
|
10 |
View Code Duplication |
if ($errorInfo['error'] === true && $itemInfo['functionLc'] === 'ini_get') { |
|
|
|
|
567
|
10 |
|
$errorInfo['error'] = false; |
568
|
|
|
} |
569
|
|
|
|
570
|
10 |
|
return $errorInfo; |
571
|
|
|
} |
572
|
|
|
|
573
|
|
|
|
574
|
|
|
/** |
575
|
|
|
* Get the error message template for this sniff. |
576
|
|
|
* |
577
|
|
|
* @return string |
578
|
|
|
*/ |
579
|
8 |
|
protected function getErrorMsgTemplate() |
580
|
|
|
{ |
581
|
8 |
|
return "INI directive '%s' is not present in PHP version %s or earlier"; |
582
|
|
|
} |
583
|
|
|
|
584
|
|
|
|
585
|
|
|
/** |
586
|
|
|
* Allow for concrete child classes to filter the error message before it's passed to PHPCS. |
587
|
|
|
* |
588
|
|
|
* @param string $error The error message which was created. |
589
|
|
|
* @param array $itemInfo Base information about the item this error message applied to. |
590
|
|
|
* @param array $errorInfo Detail information about an item this error message applied to. |
591
|
|
|
* |
592
|
|
|
* @return string |
593
|
|
|
*/ |
594
|
8 |
|
protected function filterErrorMsg($error, array $itemInfo, array $errorInfo) |
595
|
|
|
{ |
596
|
8 |
|
if ($errorInfo['alternative'] !== '') { |
597
|
4 |
|
$error .= ". This directive was previously called '%s'."; |
598
|
|
|
} |
599
|
|
|
|
600
|
8 |
|
return $error; |
601
|
|
|
} |
602
|
|
|
|
603
|
|
|
|
604
|
|
|
/** |
605
|
|
|
* Allow for concrete child classes to filter the error data before it's passed to PHPCS. |
606
|
|
|
* |
607
|
|
|
* @param array $data The error data array which was created. |
608
|
|
|
* @param array $itemInfo Base information about the item this error message applied to. |
609
|
|
|
* @param array $errorInfo Detail information about an item this error message applied to. |
610
|
|
|
* |
611
|
|
|
* @return array |
612
|
|
|
*/ |
613
|
8 |
|
protected function filterErrorData(array $data, array $itemInfo, array $errorInfo) |
614
|
|
|
{ |
615
|
8 |
|
if ($errorInfo['alternative'] !== '') { |
616
|
4 |
|
$data[] = $errorInfo['alternative']; |
617
|
|
|
} |
618
|
|
|
|
619
|
8 |
|
return $data; |
620
|
|
|
} |
621
|
|
|
|
622
|
|
|
|
623
|
|
|
}//end class |
624
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.