Completed
Push — master ( a32632...c637b7 )
by Juliette
9s
created

getNonVersionArrayKeys()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * PHPCompatibility_Sniffs_PHP_NewFunctionParametersSniff.
4
 *
5
 * @category  PHP
6
 * @package   PHPCompatibility
7
 * @author    Wim Godden <[email protected]>
8
 */
9
10
/**
11
 * PHPCompatibility_Sniffs_PHP_newFunctionParametersSniff.
12
 *
13
 * @category  PHP
14
 * @package   PHPCompatibility
15
 * @author    Wim Godden <[email protected]>
16
 */
17
class PHPCompatibility_Sniffs_PHP_NewFunctionParametersSniff extends PHPCompatibility_AbstractNewFeatureSniff
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
18
{
19
    /**
20
     * A list of new functions, not present in older versions.
21
     *
22
     * The array lists : version number with false (not present) or true (present).
23
     * The index is the location of the parameter in the parameter list, starting at 0 !
24
     * If's sufficient to list the first version where the function appears.
25
     *
26
     * @var array
27
     */
28
    protected $newFunctionParameters = array(
29
                                        'array_filter' => array(
30
                                            2 => array(
31
                                                'name' => 'flag',
32
                                                '5.5' => false,
33
                                                '5.6' => true
34
                                            ),
35
                                        ),
36
                                        'array_slice' => array(
37
                                            1 => array(
38
                                                'name' => 'preserve_keys',
39
                                                '5.0.1' => false,
40
                                                '5.0.2' => true
41
                                            ),
42
                                        ),
43
                                        'array_unique' => array(
44
                                            1 => array(
45
                                                'name' => 'sort_flags',
46
                                                '5.2.8' => false,
47
                                                '5.2.9' => true
48
                                            ),
49
                                        ),
50
                                        'assert' => array(
51
                                            1 => array(
52
                                                'name' => 'description',
53
                                                '5.4.7' => false,
54
                                                '5.4.8' => true
55
                                            ),
56
                                        ),
57
                                        'base64_decode' => array(
58
                                            1 => array(
59
                                                'name' => 'strict',
60
                                                '5.1' => false,
61
                                                '5.2' => true
62
                                            ),
63
                                        ),
64
                                        'class_implements' => array(
65
                                            1 => array(
66
                                                'name' => 'autoload',
67
                                                '5.0' => false,
68
                                                '5.1' => true
69
                                            ),
70
                                        ),
71
                                        'class_parents' => array(
72
                                            1 => array(
73
                                                'name' => 'autoload',
74
                                                '5.0' => false,
75
                                                '5.1' => true
76
                                            ),
77
                                        ),
78
                                        'clearstatcache' => array(
79
                                            0 => array(
80
                                                'name' => 'clear_realpath_cache',
81
                                                '5.2' => false,
82
                                                '5.3' => true
83
                                            ),
84
                                            1 => array(
85
                                                'name' => 'filename',
86
                                                '5.2' => false,
87
                                                '5.3' => true
88
                                            ),
89
                                        ),
90
                                        'copy' => array(
91
                                            2 => array(
92
                                                'name' => 'context',
93
                                                '5.2' => false,
94
                                                '5.3' => true
95
                                            ),
96
                                        ),
97
                                        'curl_multi_info_read' => array(
98
                                            1 => array(
99
                                                'name' => 'msgs_in_queue',
100
                                                '5.1' => false,
101
                                                '5.2' => true
102
                                            ),
103
                                        ),
104
                                        'debug_backtrace' => array(
105
                                            0 => array(
106
                                                'name' => 'options',
107
                                                '5.2.4' => false,
108
                                                '5.2.5' => true
109
                                            ),
110
                                            1 => array(
111
                                                'name' => 'limit',
112
                                                '5.3' => false,
113
                                                '5.4' => true
114
                                            ),
115
                                        ),
116
                                        'debug_print_backtrace' => array(
117
                                            0 => array(
118
                                                'name' => 'options',
119
                                                '5.3.5' => false,
120
                                                '5.3.6' => true
121
                                            ),
122
                                            1 => array(
123
                                                'name' => 'limit',
124
                                                '5.3' => false,
125
                                                '5.4' => true
126
                                            ),
127
                                        ),
128
                                        'dirname' => array(
129
                                            1 => array(
130
                                                'name' => 'levels',
131
                                                '5.6' => false,
132
                                                '7.0' => true
133
                                            ),
134
                                        ),
135
                                        'dns_get_record' => array(
136
                                            4 => array(
137
                                                'name' => 'raw',
138
                                                '5.3' => false,
139
                                                '5.4' => true
140
                                            ),
141
                                        ),
142
                                        'fgetcsv' => array(
143
                                            4 => array(
144
                                                'name' => 'escape',
145
                                                '5.2' => false,
146
                                                '5.3' => true
147
                                            ),
148
                                        ),
149
                                        'fputcsv' => array(
150
                                            4 => array(
151
                                                'name' => 'escape_char',
152
                                                '5.5.3' => false,
153
                                                '5.5.4' => true
154
                                            ),
155
                                        ),
156
                                        'file_get_contents' => array(
157
                                            3 => array(
158
                                                'name' => 'offset',
159
                                                '5.0' => false,
160
                                                '5.1' => true
161
                                            ),
162
                                            4 => array(
163
                                                'name' => 'maxlen',
164
                                                '5.0' => false,
165
                                                '5.1' => true
166
                                            ),
167
                                        ),
168
                                        'filter_input_array' => array(
169
                                            2 => array(
170
                                                'name' => 'add_empty',
171
                                                '5.3' => false,
172
                                                '5.4' => true
173
                                            ),
174
                                        ),
175
                                        'filter_var_array' => array(
176
                                            2 => array(
177
                                                'name' => 'add_empty',
178
                                                '5.3' => false,
179
                                                '5.4' => true
180
                                            ),
181
                                        ),
182
                                        'gettimeofday' => array(
183
                                            0 => array(
184
                                                'name' => 'return_float',
185
                                                '5.0' => false,
186
                                                '5.1' => true
187
                                            ),
188
                                        ),
189
                                        'get_html_translation_table' => array(
190
                                            2 => array(
191
                                                'name' => 'encoding',
192
                                                '5.3.3' => false,
193
                                                '5.3.4' => true
194
                                            ),
195
                                        ),
196
                                        'get_loaded_extensions' => array(
197
                                            0 => array(
198
                                                'name' => 'zend_extensions',
199
                                                '5.2.3' => false,
200
                                                '5.2.4' => true
201
                                            ),
202
                                        ),
203
                                        'gzcompress' => array(
204
                                            2 => array(
205
                                                'name' => 'encoding',
206
                                                '5.3' => false,
207
                                                '5.4' => true
208
                                            ),
209
                                        ),
210
                                        'gzdeflate' => array(
211
                                            2 => array(
212
                                                'name' => 'encoding',
213
                                                '5.3' => false,
214
                                                '5.4' => true
215
                                            ),
216
                                        ),
217
                                        'htmlentities' => array(
218
                                            3 => array(
219
                                                'name' => 'double_encode',
220
                                                '5.2.2' => false,
221
                                                '5.2.3' => true
222
                                            ),
223
                                        ),
224
                                        'htmlspecialchars' => array(
225
                                            3 => array(
226
                                                'name' => 'double_encode',
227
                                                '5.2.2' => false,
228
                                                '5.2.3' => true
229
                                            ),
230
                                        ),
231
                                        'http_build_query' => array(
232
                                            2 => array(
233
                                                'name' => 'arg_separator',
234
                                                '5.1.1' => false,
235
                                                '5.1.2' => true
236
                                            ),
237
                                            3 => array(
238
                                                'name' => 'enc_type',
239
                                                '5.3' => false,
240
                                                '5.4' => true
241
                                            ),
242
                                        ),
243
                                        'idn_to_ascii' => array(
244
                                            2 => array(
245
                                                'name' => 'variant',
246
                                                '5.3' => false,
247
                                                '5.4' => true
248
                                            ),
249
                                            3 => array(
250
                                                'name' => 'idna_info',
251
                                                '5.3' => false,
252
                                                '5.4' => true
253
                                            ),
254
                                        ),
255
                                        'idn_to_utf8' => array(
256
                                            2 => array(
257
                                                'name' => 'variant',
258
                                                '5.3' => false,
259
                                                '5.4' => true
260
                                            ),
261
                                            3 => array(
262
                                                'name' => 'idna_info',
263
                                                '5.3' => false,
264
                                                '5.4' => true
265
                                            ),
266
                                        ),
267
                                        'imagecolorset' => array(
268
                                            5 => array(
269
                                                'name' => 'alpha',
270
                                                '5.3' => false,
271
                                                '5.4' => true
272
                                            ),
273
                                        ),
274
                                        'imagepng' => array(
275
                                            2 => array(
276
                                                'name' => 'quality',
277
                                                '5.1.1' => false,
278
                                                '5.1.2' => true
279
                                            ),
280
                                            3 => array(
281
                                                'name' => 'filters',
282
                                                '5.1.2' => false,
283
                                                '5.1.3' => true
284
                                            ),
285
                                        ),
286
                                        'imagerotate' => array(
287
                                            3 => array(
288
                                                'name' => 'ignore_transparent',
289
                                                '5.0' => false,
290
                                                '5.1' => true
291
                                            ),
292
                                        ),
293
                                        'imap_open' => array(
294
                                            4 => array(
295
                                                'name' => 'n_retries',
296
                                                '5.1' => false,
297
                                                '5.2' => true
298
                                            ),
299
                                            5 => array(
300
                                                'name' => 'params',
301
                                                '5.3.1' => false,
302
                                                '5.3.2' => true
303
                                            ),
304
                                        ),
305
                                        'imap_reopen' => array(
306
                                            3 => array(
307
                                                'name' => 'n_retries',
308
                                                '5.1' => false,
309
                                                '5.2' => true
310
                                            ),
311
                                        ),
312
                                        'ini_get_all' => array(
313
                                            1 => array(
314
                                                'name' => 'details',
315
                                                '5.2' => false,
316
                                                '5.3' => true
317
                                            ),
318
                                        ),
319
                                        'is_a' => array(
320
                                            2 => array(
321
                                                'name' => 'allow_string',
322
                                                '5.3.8' => false,
323
                                                '5.3.9' => true
324
                                            ),
325
                                        ),
326
                                        'is_subclass_of' => array(
327
                                            2 => array(
328
                                                'name' => 'allow_string',
329
                                                '5.3.8' => false,
330
                                                '5.3.9' => true
331
                                            ),
332
                                        ),
333
                                        'iterator_to_array' => array(
334
                                            1 => array(
335
                                                'name' => 'use_keys',
336
                                                '5.2' => false,
337
                                                '5.2.1' => true
338
                                            ),
339
                                        ),
340
                                        'json_decode' => array(
341
                                            2 => array(
342
                                                'name' => 'depth',
343
                                                '5.2' => false,
344
                                                '5.3' => true
345
                                            ),
346
                                            3 => array(
347
                                                'name' => 'options',
348
                                                '5.3' => false,
349
                                                '5.4' => true
350
                                            ),
351
                                        ),
352
                                        'json_encode' => array(
353
                                            1 => array(
354
                                                'name' => 'options',
355
                                                '5.2' => false,
356
                                                '5.3' => true
357
                                            ),
358
                                            2 => array(
359
                                                'name' => 'depth',
360
                                                '5.4' => false,
361
                                                '5.5' => true
362
                                            ),
363
                                        ),
364
                                        'memory_get_peak_usage' => array(
365
                                            0 => array(
366
                                                'name' => 'real_usage',
367
                                                '5.1' => false,
368
                                                '5.2' => true
369
                                            ),
370
                                        ),
371
                                        'memory_get_usage' => array(
372
                                            0 => array(
373
                                                'name' => 'real_usage',
374
                                                '5.1' => false,
375
                                                '5.2' => true
376
                                            ),
377
                                        ),
378
                                        'mb_encode_numericentity' => array(
379
                                            3 => array(
380
                                                'name' => 'is_hex',
381
                                                '5.3' => false,
382
                                                '5.4' => true
383
                                            ),
384
                                        ),
385
                                        'mb_strrpos' => array(
386
                                            /*
387
                                             * Note: the actual position is 2, but the original 3rd
388
                                             * parameter 'encoding' was moved to the 4th position.
389
                                             * So the only way to detect if offset is used is when
390
                                             * both offset and encoding are set.
391
                                             */
392
                                            3 => array(
393
                                                'name' => 'offset',
394
                                                '5.1' => false,
395
                                                '5.2' => true
396
                                            ),
397
                                        ),
398
                                        'mssql_connect' => array(
399
                                            3 => array(
400
                                                'name' => 'new_link',
401
                                                '5.0' => false,
402
                                                '5.1' => true
403
                                            ),
404
                                        ),
405
                                        'mysqli_commit' => array(
406
                                            1 => array(
407
                                                'name' => 'flags',
408
                                                '5.4' => false,
409
                                                '5.5' => true
410
                                            ),
411
                                            2 => array(
412
                                                'name' => 'name',
413
                                                '5.4' => false,
414
                                                '5.5' => true
415
                                            ),
416
                                        ),
417
                                        'mysqli_rollback' => array(
418
                                            1 => array(
419
                                                'name' => 'flags',
420
                                                '5.4' => false,
421
                                                '5.5' => true
422
                                            ),
423
                                            2 => array(
424
                                                'name' => 'name',
425
                                                '5.4' => false,
426
                                                '5.5' => true
427
                                            ),
428
                                        ),
429
                                        'nl2br' => array(
430
                                            1 => array(
431
                                                'name' => 'is_xhtml',
432
                                                '5.2' => false,
433
                                                '5.3' => true
434
                                            ),
435
                                        ),
436
                                        'openssl_decrypt' => array(
437
                                            4 => array(
438
                                                'name' => 'iv',
439
                                                '5.3.2' => false,
440
                                                '5.3.3' => true
441
                                            ),
442
                                            5 => array(
443
                                                'name' => 'tag',
444
                                                '7.0' => false,
445
                                                '7.1' => true
446
                                            ),
447
                                            6 => array(
448
                                                'name' => 'aad',
449
                                                '7.0' => false,
450
                                                '7.1' => true
451
                                            ),
452
                                        ),
453
                                        'openssl_encrypt' => array(
454
                                            4 => array(
455
                                                'name' => 'iv',
456
                                                '5.3.2' => false,
457
                                                '5.3.3' => true
458
                                            ),
459
                                            5 => array(
460
                                                'name' => 'tag',
461
                                                '7.0' => false,
462
                                                '7.1' => true
463
                                            ),
464
                                            6 => array(
465
                                                'name' => 'aad',
466
                                                '7.0' => false,
467
                                                '7.1' => true
468
                                            ),
469
                                            7 => array(
470
                                                'name' => 'tag_length',
471
                                                '7.0' => false,
472
                                                '7.1' => true
473
                                            ),
474
                                        ),
475
                                        'openssl_pkcs7_verify' => array(
476
                                            5 => array(
477
                                                'name' => 'content',
478
                                                '5.0' => false,
479
                                                '5.1' => true
480
                                            ),
481
                                        ),
482
                                        'openssl_seal' => array(
483
                                            4 => array(
484
                                                'name' => 'method',
485
                                                '5.2' => false,
486
                                                '5.3' => true
487
                                            ),
488
                                        ),
489
                                        'openssl_verify' => array(
490
                                            3 => array(
491
                                                'name' => 'signature_alg',
492
                                                '5.1' => false,
493
                                                '5.2' => true
494
                                            ),
495
                                        ),
496
                                        'parse_ini_file' => array(
497
                                            2 => array(
498
                                                'name' => 'scanner_mode',
499
                                                '5.2' => false,
500
                                                '5.3' => true
501
                                            ),
502
                                        ),
503
                                        'parse_url' => array(
504
                                            1 => array(
505
                                                'name' => 'component',
506
                                                '5.1.1' => false,
507
                                                '5.1.2' => true
508
                                            ),
509
                                        ),
510
                                        'pg_lo_create' => array(
511
                                            1 => array(
512
                                                'name' => 'object_id',
513
                                                '5.2' => false,
514
                                                '5.3' => true
515
                                            ),
516
                                        ),
517
                                        'pg_lo_import' => array(
518
                                            2 => array(
519
                                                'name' => 'object_id',
520
                                                '5.2' => false,
521
                                                '5.3' => true
522
                                            ),
523
                                        ),
524
                                        'preg_replace' => array(
525
                                            4 => array(
526
                                                'name' => 'count',
527
                                                '5.0' => false,
528
                                                '5.1' => true
529
                                            ),
530
                                        ),
531
                                        'preg_replace_callback' => array(
532
                                            4 => array(
533
                                                'name' => 'count',
534
                                                '5.0' => false,
535
                                                '5.1' => true
536
                                            ),
537
                                        ),
538
                                        'round' => array(
539
                                            2 => array(
540
                                                'name' => 'mode',
541
                                                '5.2' => false,
542
                                                '5.3' => true
543
                                            ),
544
                                        ),
545
                                        'sem_acquire' => array(
546
                                            1 => array(
547
                                                'name' => 'nowait',
548
                                                '5.6' => false,
549
                                                '5.6.1' => true
550
                                            ),
551
                                        ),
552
                                        'session_regenerate_id' => array(
553
                                            0 => array(
554
                                                'name' => 'delete_old_session',
555
                                                '5.0' => false,
556
                                                '5.1' => true
557
                                            ),
558
                                        ),
559
                                        'session_set_cookie_params' => array(
560
                                            4 => array(
561
                                                'name' => 'httponly',
562
                                                '5.1' => false,
563
                                                '5.2' => true
564
                                            ),
565
                                        ),
566
                                        'session_set_save_handler' => array(
567
                                            6 => array(
568
                                                'name' => 'create_sid',
569
                                                '5.5' => false,
570
                                                '5.5.1' => true
571
                                            ),
572
                                        ),
573
                                        'session_start' => array(
574
                                            0 => array(
575
                                                'name' => 'options',
576
                                                '5.6' => false,
577
                                                '7.0' => true
578
                                            ),
579
                                        ),
580
                                        'setcookie' => array(
581
                                            6 => array(
582
                                                'name' => 'httponly',
583
                                                '5.1' => false,
584
                                                '5.2' => true
585
                                            ),
586
                                        ),
587
                                        'setrawcookie' => array(
588
                                            6 => array(
589
                                                'name' => 'httponly',
590
                                                '5.1' => false,
591
                                                '5.2' => true
592
                                            ),
593
                                        ),
594
                                        'simplexml_load_file' => array(
595
                                            4 => array(
596
                                                'name' => 'is_prefix',
597
                                                '5.1' => false,
598
                                                '5.2' => true
599
                                            ),
600
                                        ),
601
                                        'simplexml_load_string' => array(
602
                                            4 => array(
603
                                                'name' => 'is_prefix',
604
                                                '5.1' => false,
605
                                                '5.2' => true
606
                                            ),
607
                                        ),
608
                                        'spl_autoload_register' => array(
609
                                            2 => array(
610
                                                'name' => 'prepend',
611
                                                '5.2' => false,
612
                                                '5.3' => true
613
                                            ),
614
                                        ),
615
                                        'stream_context_create' => array(
616
                                            1 => array(
617
                                                'name' => 'params',
618
                                                '5.2' => false,
619
                                                '5.3' => true
620
                                            ),
621
                                        ),
622
                                        'stream_copy_to_stream' => array(
623
                                            3 => array(
624
                                                'name' => 'offset',
625
                                                '5.0' => false,
626
                                                '5.1' => true
627
                                            ),
628
                                        ),
629
                                        'stream_get_contents' => array(
630
                                            2 => array(
631
                                                'name' => 'offset',
632
                                                '5.0' => false,
633
                                                '5.1' => true
634
                                            ),
635
                                        ),
636
                                        'stream_wrapper_register' => array(
637
                                            2 => array(
638
                                                'name' => 'flags',
639
                                                '5.2.3' => false,
640
                                                '5.2.4' => true
641
                                            ),
642
                                        ),
643
                                        'stristr' => array(
644
                                            2 => array(
645
                                                'name' => 'before_needle',
646
                                                '5.2' => false,
647
                                                '5.3' => true
648
                                            ),
649
                                        ),
650
                                        'strstr' => array(
651
                                            2 => array(
652
                                                'name' => 'before_needle',
653
                                                '5.2' => false,
654
                                                '5.3' => true
655
                                            ),
656
                                        ),
657
                                        'str_word_count' => array(
658
                                            2 => array(
659
                                                'name' => 'charlist',
660
                                                '5.0' => false,
661
                                                '5.1' => true
662
                                            ),
663
                                        ),
664
                                        'substr_count' => array(
665
                                            2 => array(
666
                                                'name' => 'offset',
667
                                                '5.0' => false,
668
                                                '5.1' => true
669
                                            ),
670
                                            3 => array(
671
                                                'name' => 'length',
672
                                                '5.0' => false,
673
                                                '5.1' => true
674
                                            ),
675
                                        ),
676
                                        'sybase_connect' => array(
677
                                            5 => array(
678
                                                'name' => 'new',
679
                                                '5.2' => false,
680
                                                '5.3' => true
681
                                            ),
682
                                        ),
683
                                        'timezone_transitions_get' => array(
684
                                            1 => array(
685
                                                'name' => 'timestamp_begin',
686
                                                '5.2' => false,
687
                                                '5.3' => true
688
                                            ),
689
                                            2 => array(
690
                                                'name' => 'timestamp_end',
691
                                                '5.2' => false,
692
                                                '5.3' => true
693
                                            ),
694
                                        ),
695
                                        'timezone_identifiers_list' => array(
696
                                            0 => array(
697
                                                'name' => 'what',
698
                                                '5.2' => false,
699
                                                '5.3' => true
700
                                            ),
701
                                            1 => array(
702
                                                'name' => 'country',
703
                                                '5.2' => false,
704
                                                '5.3' => true
705
                                            ),
706
                                        ),
707
                                        'token_get_all' => array(
708
                                            1 => array(
709
                                                'name' => 'flags',
710
                                                '5.6' => false,
711
                                                '7.0' => true
712
                                            ),
713
                                        ),
714
                                        'ucwords' => array(
715
                                            1 => array(
716
                                                'name' => 'delimiters',
717
                                                '5.4.31' => false,
718
                                                '5.5.15' => false,
719
                                                '5.4.32' => true,
720
                                                '5.5.16' => true
721
                                            ),
722
                                        ),
723
                                        'unserialize' => array(
724
                                            1 => array(
725
                                                'name' => 'options',
726
                                                '5.6' => false,
727
                                                '7.0' => true
728
                                            ),
729
                                        ),
730
                                    );
731
732
733
    /**
734
     * Returns an array of tokens this test wants to listen for.
735
     *
736
     * @return array
737
     */
738
    public function register()
739
    {
740
        // Handle case-insensitivity of function names.
741
        $this->newFunctionParameters = $this->arrayKeysToLowercase($this->newFunctionParameters);
742
743
        return array(T_STRING);
744
    }//end register()
745
746
    /**
747
     * Processes this test, when one of its tokens is encountered.
748
     *
749
     * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
750
     * @param int                  $stackPtr  The position of the current token in
751
     *                                        the stack passed in $tokens.
752
     *
753
     * @return void
754
     */
755 View Code Duplication
    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
756
    {
757
        $tokens = $phpcsFile->getTokens();
758
759
        $ignore = array(
760
                T_DOUBLE_COLON,
761
                T_OBJECT_OPERATOR,
762
                T_FUNCTION,
763
                T_CONST,
764
        );
765
766
        $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
767
        if (in_array($tokens[$prevToken]['code'], $ignore) === true) {
768
            // Not a call to a PHP function.
769
            return;
770
        }
771
772
        $function   = $tokens[$stackPtr]['content'];
773
        $functionLc = strtolower($function);
774
775
        if (isset($this->newFunctionParameters[$functionLc]) === false) {
776
            return;
777
        }
778
779
        $parameterCount = $this->getFunctionCallParameterCount($phpcsFile, $stackPtr);
780
        if ($parameterCount === 0) {
781
            return;
782
        }
783
784
        // If the parameter count returned > 0, we know there will be valid open parenthesis.
785
        $openParenthesis = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
786
        $parameterOffsetFound = $parameterCount - 1;
787
788
        foreach($this->newFunctionParameters[$functionLc] as $offset => $parameterDetails) {
789
            if ($offset <= $parameterOffsetFound) {
790
                $itemInfo = array(
791
                    'name'   => $function,
792
                    'nameLc' => $functionLc,
793
                    'offset' => $offset,
794
                );
795
                $this->handleFeature($phpcsFile, $openParenthesis, $itemInfo);
0 ignored issues
show
Security Bug introduced by
It seems like $openParenthesis defined by $phpcsFile->findNext(\PH...null, true, null, true) on line 785 can also be of type false; however, PHPCompatibility_Abstrac...nSniff::handleFeature() does only seem to accept integer, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
796
            }
797
        }
798
799
    }//end process()
800
801
802
    /**
803
     * Get the relevant sub-array for a specific item from a multi-dimensional array.
804
     *
805
     * @param array $itemInfo Base information about the item.
806
     *
807
     * @return array Version and other information about the item.
808
     */
809
    public function getItemArray(array $itemInfo)
810
    {
811
        return $this->newFunctionParameters[$itemInfo['nameLc']][$itemInfo['offset']];
812
    }
813
814
815
    /**
816
     * Get an array of the non-PHP-version array keys used in a sub-array.
817
     *
818
     * @return array
819
     */
820
    protected function getNonVersionArrayKeys()
821
    {
822
        return array('name');
823
    }
824
825
826
    /**
827
     * Retrieve the relevant detail (version) information for use in an error message.
828
     *
829
     * @param array $itemArray Version and other information about the item.
830
     * @param array $itemInfo  Base information about the item.
831
     *
832
     * @return array
833
     */
834
    public function getErrorInfo(array $itemArray, array $itemInfo)
835
    {
836
        $errorInfo = parent::getErrorInfo($itemArray, $itemInfo);
837
        $errorInfo['paramName'] = $itemArray['name'];
838
839
        return $errorInfo;
840
    }
841
842
843
    /**
844
     * Get the item name to be used for the creation of the error code.
845
     *
846
     * @param array $itemInfo  Base information about the item.
847
     * @param array $errorInfo Detail information about an item.
848
     *
849
     * @return string
850
     */
851
    protected function getItemName(array $itemInfo, array $errorInfo)
852
    {
853
        return $itemInfo['name'].'_'.$errorInfo['paramName'];
854
    }
855
856
857
    /**
858
     * Get the error message template for this sniff.
859
     *
860
     * @return string
861
     */
862
    protected function getErrorMsgTemplate()
863
    {
864
        return 'The function %s() does not have a parameter "%s" in PHP version %s or earlier';
865
    }
866
867
868
    /**
869
     * Allow for concrete child classes to filter the error data before it's passed to PHPCS.
870
     *
871
     * @param array $data      The error data array which was created.
872
     * @param array $itemInfo  Base information about the item this error message applied to.
873
     * @param array $errorInfo Detail information about an item this error message applied to.
874
     *
875
     * @return array
876
     */
877
    protected function filterErrorData(array $data, array $itemInfo, array $errorInfo)
878
    {
879
        array_shift($data);
880
        array_unshift($data, $itemInfo['name'], $errorInfo['paramName']);
881
        return $data;
882
    }
883
884
885
}//end class
886