Skip to content

Commit 436a610

Browse files
committed
Merge branch 'php-8.0/squiz-objectinstantiation-support-match' of https://github.com/jrfnl/PHP_CodeSniffer
2 parents f2cd66d + 3148f1b commit 436a610

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/Standards/Squiz/Sniffs/Objects/ObjectInstantiationSniff.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ public function process(File $phpcsFile, $stackPtr)
5050
$allowedTokens = [
5151
T_EQUAL => true,
5252
T_DOUBLE_ARROW => true,
53+
T_FN_ARROW => true,
54+
T_MATCH_ARROW => true,
5355
T_THROW => true,
5456
T_RETURN => true,
5557
T_INLINE_THEN => true,

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,16 @@ function foo() { return new MyClass(); }
1313

1414
$doodad = $x ? new Foo : new Bar;
1515

16+
function returnFn() {
17+
$fn = fn($x) => new MyClass();
18+
}
19+
20+
function returnMatch() {
21+
$match = match($x) {
22+
0 => new MyClass()
23+
}
24+
}
25+
26+
// Intentional parse error. This must be the last test in the file.
1627
function new
1728
?>

0 commit comments

Comments
 (0)