Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Visitor/UnusedMatchVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use PhpParser\Node;
use PhpParser\Node\Arg;
use PhpParser\Node\ArrayItem;
use PhpParser\Node\Expr\ArrowFunction;
use PhpParser\Node\Expr\Assign;
use PhpParser\Node\Expr\AssignOp;
use PhpParser\Node\Expr\BinaryOp\Coalesce;
Expand Down Expand Up @@ -86,7 +87,8 @@ private function isUsed(Node $parent): bool
|| $parent instanceof Ternary
|| $parent instanceof MatchArm
|| $parent instanceof Yield_
|| $parent instanceof YieldFrom;
|| $parent instanceof YieldFrom
|| $parent instanceof ArrowFunction;
}

}
12 changes: 12 additions & 0 deletions tests/Rule/data/ForbidUnusedMatchResultRule/code.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@ public function testUsed(bool $bool): mixed
1 => 'y',
} : null;

function ($int) {
return match ($int) {
0 => 'x',
1 => 'y',
};
};

fn () => match ($int) {
0 => 'x',
1 => 'y',
};

return match ($bool) {
false => 1,
true => 2,
Expand Down