Skip to content

Commit d36e95b

Browse files
Slamdunksebastianbergmann
authored andcommitted
Added match
1 parent ac3e8f0 commit d36e95b

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

src/StaticAnalysis/ExecutableLinesFindingVisitor.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,18 @@ public function enterNode(Node $node): void
126126
return;
127127
}
128128

129+
if ($node instanceof Node\Expr\Match_) {
130+
foreach ($node->arms as $arm) {
131+
$this->setLineBranch(
132+
$arm->body->getStartLine(),
133+
$arm->body->getEndLine(),
134+
++$this->nextBranch
135+
);
136+
}
137+
138+
return;
139+
}
140+
129141
if ($node instanceof Node\Stmt\Declare_) {
130142
$this->unsets[] = range($node->getStartLine(), $node->getEndLine());
131143
}

tests/_files/source_for_branched_exec_lines.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,4 +219,34 @@ public function withSwitch() // +1
219219
++$var; // +8
220220
endswitch; // -8
221221
} // 0
222+
public function withMatch() // +9
223+
{ // 0
224+
$var = 1; // 0
225+
$var2 = match ($var) { // 0
226+
0 => ++$var, // +1
227+
1 => ++$var, // +1
228+
default => ++$var, // +1
229+
}; // -3
230+
$var2 // 0
231+
= // 0
232+
match // 0
233+
( // 0
234+
$var // 0
235+
) // 0
236+
{ // 0
237+
0 // 0
238+
=> // 0
239+
++$var // +4
240+
, // -4
241+
1 // 0
242+
=> // 0
243+
++$var // +5
244+
, // -5
245+
default // 0
246+
=> // 0
247+
++$var // +6
248+
, // -6
249+
} // 0
250+
; // 0
251+
} // 0
222252
}

0 commit comments

Comments
 (0)