Skip to content

Commit

Permalink
Merge branch 'hotfix/2713-fn-closure-ternary-tokenizer' of https://gi…
Browse files Browse the repository at this point in the history
  • Loading branch information
gsherwood committed Nov 20, 2019
2 parents 5157a81 + 8e41312 commit c46d135
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ class Example {
}

$a = fn(?\DateTime $x) : ?\DateTime => $x;

$b = fn ($b) => $b ? true : false;
5 changes: 4 additions & 1 deletion src/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ public function getErrorList($testFile='DisallowInlineIfUnitTest.inc')
{
switch ($testFile) {
case 'DisallowInlineIfUnitTest.inc':
return [8 => 1];
return [
8 => 1,
18 => 1,
];
break;
case 'DisallowInlineIfUnitTest.js':
return [1 => 1];
Expand Down
4 changes: 2 additions & 2 deletions src/Tokenizers/PHP.php
Original file line number Diff line number Diff line change
Expand Up @@ -1083,7 +1083,7 @@ protected function tokenize($string)
$newToken['code'] = T_NULLABLE;
$newToken['type'] = 'T_NULLABLE';
break;
} else if (in_array($tokenType, [T_OPEN_TAG, T_OPEN_TAG_WITH_ECHO, '=', '{', ';'], true) === true) {
} else if (in_array($tokenType, [T_DOUBLE_ARROW, T_OPEN_TAG, T_OPEN_TAG_WITH_ECHO, '=', '{', ';'], true) === true) {
if (PHP_CODESNIFFER_VERBOSITY > 1) {
echo "\t\t* token $stackPtr changed from ? to T_INLINE_THEN".PHP_EOL;
}
Expand Down Expand Up @@ -1486,7 +1486,7 @@ function return types. We want to keep the parenthesis map clean,
}
}

if ($tokens[$i][0] === T_FUNCTION || $tokens[$i][0] === T_USE) {
if ($tokens[$i][0] === T_FUNCTION || $tokens[$i][0] === T_FN || $tokens[$i][0] === T_USE) {
$isReturnType = true;
}
}//end if
Expand Down

0 comments on commit c46d135

Please sign in to comment.