File tree Expand file tree Collapse file tree 7 files changed +43
-10
lines changed
Standards/Squiz/Tests/Arrays Expand file tree Collapse file tree 7 files changed +43
-10
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
38
38
- Fixed bug #2850 : Generic.PHP.LowerCaseKeyword complains __HALT_COMPILER is uppercase
39
39
- Fixed bug #2853 : Undefined variable error when using Info report
40
40
-- Thanks to Juliette Reinders Folmer for the patch
41
+ - Fixed bug #2865 : Double arrow tokenized as T_STRING when placed after function named "fn"
41
42
- Fixed bug #2868 : phpcs:ignore annotation doesnt work inside a docblock
42
43
- Fixed bug #2878 : PSR12.Files.FileHeader conflicts with Generic.Files.LineEndings
43
44
</notes>
Original file line number Diff line number Diff line change @@ -424,6 +424,11 @@ $array = array(
424
424
3 => '3 ' ,
425
425
);
426
426
427
+ $ foo = array (
428
+ $ this ->fn => 'value ' ,
429
+ $ foo ->fn => 'value ' ,
430
+ );
431
+
427
432
// Intentional syntax error.
428
433
$ a = array (
429
434
'a ' =>
Original file line number Diff line number Diff line change @@ -452,6 +452,11 @@ $array = array(
452
452
3 => '3',
453
453
);
454
454
455
+ $foo = array(
456
+ $this->fn => 'value',
457
+ $foo->fn => 'value',
458
+ );
459
+
455
460
// Intentional syntax error.
456
461
$a = array(
457
462
'a' =>
Original file line number Diff line number Diff line change @@ -413,6 +413,11 @@ $array = [
413
413
3 => '3 ' ,
414
414
];
415
415
416
+ $ foo = [
417
+ $ this ->fn => 'value ' ,
418
+ $ foo ->fn => 'value ' ,
419
+ ];
420
+
416
421
// Intentional syntax error.
417
422
$ a = [
418
423
'a ' =>
Original file line number Diff line number Diff line change @@ -439,6 +439,11 @@ $array = [
439
439
3 => '3',
440
440
];
441
441
442
+ $foo = [
443
+ $this->fn => 'value',
444
+ $foo->fn => 'value',
445
+ ];
446
+
442
447
// Intentional syntax error.
443
448
$a = [
444
449
'a' =>
Original file line number Diff line number Diff line change @@ -113,6 +113,7 @@ public function getErrorList($testFile='')
113
113
370 => 1 ,
114
114
383 => 1 ,
115
115
394 => 1 ,
116
+ 429 => 1 ,
116
117
];
117
118
case 'ArrayDeclarationUnitTest.2.inc ' :
118
119
return [
@@ -188,6 +189,7 @@ public function getErrorList($testFile='')
188
189
358 => 1 ,
189
190
372 => 1 ,
190
191
383 => 1 ,
192
+ 418 => 1 ,
191
193
];
192
194
default :
193
195
return [];
Original file line number Diff line number Diff line change @@ -1227,6 +1227,9 @@ protected function tokenize($string)
1227
1227
// detect the T_FN token more easily.
1228
1228
$ tokens [$ stackPtr ][0 ] = T_FN ;
1229
1229
$ token [0 ] = T_FN ;
1230
+ if (PHP_CODESNIFFER_VERBOSITY > 1 ) {
1231
+ echo "\t\t* token $ stackPtr changed from T_STRING to T_FN " .PHP_EOL ;
1232
+ }
1230
1233
}
1231
1234
1232
1235
/*
@@ -1241,18 +1244,25 @@ protected function tokenize($string)
1241
1244
|| $ token [0 ] === T_FN )
1242
1245
&& $ finalTokens [$ lastNotEmptyToken ]['code ' ] !== T_USE
1243
1246
) {
1244
- for ($ x = ($ stackPtr + 1 ); $ x < $ numTokens ; $ x ++) {
1245
- if (is_array ($ tokens [$ x ]) === false
1246
- || isset (Util \Tokens::$ emptyTokens [$ tokens [$ x ][0 ]]) === false
1247
- ) {
1248
- // Non-empty content.
1249
- break ;
1247
+ if ($ token [0 ] === T_FUNCTION ) {
1248
+ for ($ x = ($ stackPtr + 1 ); $ x < $ numTokens ; $ x ++) {
1249
+ if (is_array ($ tokens [$ x ]) === false
1250
+ || isset (Util \Tokens::$ emptyTokens [$ tokens [$ x ][0 ]]) === false
1251
+ ) {
1252
+ // Non-empty content.
1253
+ break ;
1254
+ }
1250
1255
}
1251
- }
1252
1256
1253
- if ($ x < $ numTokens && is_array ($ tokens [$ x ]) === true ) {
1254
- $ tokens [$ x ][0 ] = T_STRING ;
1255
- }
1257
+ if ($ x < $ numTokens && is_array ($ tokens [$ x ]) === true ) {
1258
+ if (PHP_CODESNIFFER_VERBOSITY > 1 ) {
1259
+ $ oldType = Util \Tokens::tokenName ($ tokens [$ x ][0 ]);
1260
+ echo "\t\t* token $ x changed from $ oldType to T_STRING " .PHP_EOL ;
1261
+ }
1262
+
1263
+ $ tokens [$ x ][0 ] = T_STRING ;
1264
+ }
1265
+ }//end if
1256
1266
1257
1267
/*
1258
1268
This is a special condition for T_ARRAY tokens used for
You can’t perform that action at this time.
0 commit comments