Skip to content

Commit 5934e85

Browse files
committed
Merge branch 'feature/3789-tokenizer-match-vs-inline-else' of https://github.com/jrfnl/PHP_CodeSniffer
2 parents daddaa3 + 577b2b8 commit 5934e85

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/Standards/Squiz/Tests/Objects/ObjectInstantiationUnitTest.inc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ function nonAssignmentTernary() {
4141
}
4242
}
4343

44+
// Test for tokenizer issue #3789.
45+
$a = $b !== null
46+
? match ($c) {
47+
default => 5,
48+
}
49+
: new Foo;
50+
4451
// Intentional parse error. This must be the last test in the file.
4552
function new
4653
?>

src/Tokenizers/PHP.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2250,11 +2250,12 @@ function return types. We want to keep the parenthesis map clean,
22502250

22512251
if (is_array($tokens[$i]) === false
22522252
&& ($tokens[$i] === ';'
2253-
|| $tokens[$i] === '{')
2253+
|| $tokens[$i] === '{'
2254+
|| $tokens[$i] === '}')
22542255
) {
22552256
break;
22562257
}
2257-
}
2258+
}//end for
22582259
}//end if
22592260

22602261
if ($isInlineIf === true) {

0 commit comments

Comments
 (0)