Skip to content

Commit a0434a6

Browse files
Slamdunksebastianbergmann
authored andcommitted
Added ternary
1 parent e90df33 commit a0434a6

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/StaticAnalysis/ExecutableLinesFindingVisitor.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ public function enterNode(Node $node): void
4949
return;
5050
}
5151

52+
if ($node instanceof Node\Expr\Ternary) {
53+
$this->setLineBranch($node->if->getStartLine(), $node->if->getEndLine(), ++$this->nextBranch);
54+
$this->setLineBranch($node->else->getStartLine(), $node->else->getEndLine(), ++$this->nextBranch);
55+
56+
return;
57+
}
58+
5259
if ($node instanceof Node\Stmt\If_ ||
5360
$node instanceof Node\Stmt\ElseIf_ ||
5461
$node instanceof Node\Stmt\Else_ ||

tests/_files/source_for_branched_exec_lines.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,4 +334,15 @@ public function withThrow() // +1
334334
} // -6
335335
++$var; // 0
336336
}
337+
public function withTernaryOperator() // +7
338+
{ // 0
339+
$var // 0
340+
= // 0
341+
true // 0
342+
? // 0
343+
'a' // +1
344+
: // -1
345+
'b' // +2
346+
; // -2
347+
}
337348
}

0 commit comments

Comments
 (0)