@@ -1379,7 +1379,7 @@ function return types. We want to keep the parenthesis map clean,
1379
1379
// Convert colons that are actually the ELSE component of an
1380
1380
// inline IF statement.
1381
1381
if (empty ($ insideInlineIf ) === false && $ newToken ['code ' ] === T_COLON ) {
1382
- // Make sure this isn't the return type separator of a closure .
1382
+ // Make sure this isn't a return type separator.
1383
1383
$ isInlineIf = true ;
1384
1384
for ($ i = ($ stackPtr - 1 ); $ i > 0 ; $ i --) {
1385
1385
if (is_array ($ tokens [$ i ]) === false
@@ -1405,12 +1405,15 @@ function return types. We want to keep the parenthesis map clean,
1405
1405
}
1406
1406
1407
1407
// We've found the open parenthesis, so if the previous
1408
- // non-empty token is FUNCTION or USE, this is a closure.
1408
+ // non-empty token is FUNCTION or USE, this is a return type.
1409
+ // Note that we need to skip T_STRING tokens here as these
1410
+ // can be function names.
1409
1411
for ($ i --; $ i > 0 ; $ i --) {
1410
1412
if (is_array ($ tokens [$ i ]) === false
1411
1413
|| ($ tokens [$ i ][0 ] !== T_DOC_COMMENT
1412
1414
&& $ tokens [$ i ][0 ] !== T_COMMENT
1413
- && $ tokens [$ i ][0 ] !== T_WHITESPACE )
1415
+ && $ tokens [$ i ][0 ] !== T_WHITESPACE
1416
+ && $ tokens [$ i ][0 ] !== T_STRING )
1414
1417
) {
1415
1418
break ;
1416
1419
}
@@ -1419,7 +1422,7 @@ function return types. We want to keep the parenthesis map clean,
1419
1422
if ($ tokens [$ i ][0 ] === T_FUNCTION || $ tokens [$ i ][0 ] === T_FN || $ tokens [$ i ][0 ] === T_USE ) {
1420
1423
$ isInlineIf = false ;
1421
1424
if (PHP_CODESNIFFER_VERBOSITY > 1 ) {
1422
- Common::printStatusMessage ('* token is function return type, not T_INLINE_ELSE ' , 2 );
1425
+ Common::printStatusMessage ('* token is return type, not T_INLINE_ELSE ' , 2 );
1423
1426
}
1424
1427
}
1425
1428
}//end if
0 commit comments