Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
0c33d75
Move to branch based line analysis
Slamdunk Nov 21, 2022
9c508c3
Corrected `elseif`s conditions
Slamdunk Nov 24, 2022
df986ed
Added `for` and `do-while`
Slamdunk Nov 24, 2022
aff7caf
Added `switch`
Slamdunk Nov 24, 2022
7afb5e6
Added `match`
Slamdunk Nov 24, 2022
ee5db56
Added `return`
Slamdunk Nov 24, 2022
c797803
Added `continue` and `break`
Slamdunk Nov 24, 2022
74f9b32
Added `goto`
Slamdunk Nov 24, 2022
cfdfd5f
Added `try-catch-finally`
Slamdunk Nov 25, 2022
d3d30da
Added `ternary`
Slamdunk Nov 25, 2022
270211a
Added `call-like`
Slamdunk Nov 25, 2022
3337628
Handled empty functions
Slamdunk Nov 28, 2022
e03acf2
Added anonymous functions
Slamdunk Nov 28, 2022
e8af3e1
Added arrow functions
Slamdunk Nov 28, 2022
a6cef72
If condition to return statement
Slamdunk Nov 28, 2022
358256f
Simplified matching of node to be skipped
Slamdunk Nov 28, 2022
fb6e6c2
Functions/Methods: mark as lines only body's ones
Slamdunk Nov 28, 2022
7606d7c
Handle comments and empty lines
Slamdunk Nov 29, 2022
cd4f39d
CodeCoverage: mark as executed all lines of the same branch
Slamdunk Nov 29, 2022
80697da
Added `interface` and `trait`
Slamdunk Nov 29, 2022
57dfea6
Added short ternary and coalesce
Slamdunk Nov 29, 2022
489c8ae
Exclude in-toto non ClassMethods lines from class analysis
Slamdunk Nov 29, 2022
7d6b533
Assign each Stmt a separate branch
Slamdunk Nov 29, 2022
c113904
`match` arms depent too much on autoloading runtime behavior, process…
Slamdunk Nov 30, 2022
5c199ae
Lines ignored by annotations: cover entire range
Slamdunk Nov 30, 2022
8fccb72
Rely only on ExecutableLinesFindingVisitorTest unit test for exec lin…
Slamdunk Nov 30, 2022
ab90d33
Tests different features only for related supported by PHP versions
Slamdunk Nov 30, 2022
9e61b30
SA fixes
Slamdunk Nov 30, 2022
d036036
Adapt missing test cases for PHP <8.1
Slamdunk Nov 30, 2022
5243a2a
Minor optimization
Slamdunk Dec 1, 2022
1eb363a
Multiline strings: skip internal lines
Slamdunk Dec 2, 2022
d909a64
Skip comments within nodes already marked as exec
Slamdunk Dec 2, 2022
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
Prev Previous commit
Next Next commit
Added continue and break
  • Loading branch information
Slamdunk committed Nov 24, 2022
commit c797803f48f61e5410d1584be3e46247b00f1377
6 changes: 5 additions & 1 deletion src/StaticAnalysis/ExecutableLinesFindingVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,11 @@ public function enterNode(Node $node): void
return;
}

if ($node instanceof Node\Stmt\Return_) {
if (
$node instanceof Node\Stmt\Return_ ||
$node instanceof Node\Stmt\Continue_ ||
$node instanceof Node\Stmt\Break_
) {
$returnBranch = $this->executableLinesGroupedByBranch[$node->getStartLine()];
$returnEndLine = $node->getEndLine();
$nextBranch = null;
Expand Down
32 changes: 32 additions & 0 deletions tests/_files/source_for_branched_exec_lines.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,4 +265,36 @@ public function withReturn() // +7
return; // 0
++$var; // +4
}
public function withContinue() // +1
{ // 0
$var = 1; // 0
for ($i = 0; $i < 10; $i++) { // 0
if (false) { // +1
++$var; // +1
continue // 0
1 // 0
; // 0
++$var; // +1
} // -2
++$var; // 0
continue; // 0
++$var; // +3
} // -4
}
public function withBreak() // +5
{ // 0
$var = 1; // 0
for ($i = 0; $i < 10; $i++) { // 0
if (false) { // +1
++$var; // +1
break // 0
1 // 0
; // 0
++$var; // +1
} // -2
++$var; // 0
break; // 0
++$var; // +3
} // -4
}
}