Skip to content

Commit d11aae8

Browse files
Slamdunksebastianbergmann
authored andcommitted
Added call-like
1 parent a0434a6 commit d11aae8

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

src/StaticAnalysis/ExecutableLinesFindingVisitor.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ public function enterNode(Node $node): void
162162
$node instanceof Node\Stmt\Break_ ||
163163
$node instanceof Node\Stmt\Goto_ ||
164164
$node instanceof Node\Stmt\Throw_ ||
165-
$node instanceof Node\Stmt\Label
165+
$node instanceof Node\Stmt\Label ||
166+
$node instanceof Node\Expr\CallLike
166167
) {
167168
$returnBranch = $this->executableLinesGroupedByBranch[$node->getStartLine()];
168169
$returnEndLine = $node->getEndLine();

tests/_files/source_for_branched_exec_lines.php

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -322,19 +322,19 @@ public function withThrow() // +1
322322
throw // 0
323323
new // 0
324324
\Exception() // 0
325-
; // 0
326-
++$var; // +1
327-
} catch (\Exception $exception) { // +1
325+
; // +2
326+
++$var; // -1
327+
} catch (\Exception $exception) { // +2
328328
++$var; // 0
329329
} catch (\RuntimeException $re) { // +1
330330
} catch (\Throwable $throwable) { // +1
331331
++$var; // 0
332332
} finally { // +1
333333
++$var; // 0
334-
} // -6
334+
} // -7
335335
++$var; // 0
336336
}
337-
public function withTernaryOperator() // +7
337+
public function withTernaryOperator() // +8
338338
{ // 0
339339
$var // 0
340340
= // 0
@@ -345,4 +345,18 @@ public function withTernaryOperator() // +7
345345
'b' // +2
346346
; // -2
347347
}
348+
public function withCall() // +3
349+
{ // 0
350+
$var = 1; // 0
351+
$var = intval($var); // 0
352+
++$var; // +1
353+
$date = new DateTimeImmutable(); // 0
354+
++$var; // +1
355+
$ymd = $date->format('Ymd'); // 0
356+
++$var; // +1
357+
$ymd = $date?->format('Ymd'); // 0
358+
++$var; // +1
359+
$date = DateTime::createFromImmutable($date); // 0
360+
++$var; // +1
361+
}
348362
}

0 commit comments

Comments
 (0)