I believe the issue is somewhere around Tokenizers/PHP.php:862 but without taking a deep dive into the code it is beyond my ability to fix - otherwise I would have submitted a pull request.
if ($tokens[$x]['code'] === T_OPEN_PARENTHESIS) {
$tokens[$i]['code'] = T_CLOSURE;
$tokens[$i]['type'] = 'T_CLOSURE';
if (PHP_CODESNIFFER_VERBOSITY > 1) {
$line = $tokens[$i]['line'];
echo "\t* token $i on line $line changed from T_FUNCTION to T_CLOSURE".PHP_EOL;
}
I was using
PSR1.Files.SideEffects
and it was failing on code using a closure that returned by reference.I did some poking in that Sniff and from what I can understand it's not the Sniff's fault, it's the tokenizers fault.
I determined that in the following which passes there is no
T_FUNCTION
symbol, but there is aT_CLOSURE
However with this it fails, which simply changes the closure to return by reference, there is a
T_FUNCTION
and noT_CLOSURE
I believe the issue is somewhere around
Tokenizers/PHP.php:862
but without taking a deep dive into the code it is beyond my ability to fix - otherwise I would have submitted a pull request.