Skip to content

Commit 09c0fda

Browse files
committedJun 29, 2024··
Closes #967
1 parent 9b0a889 commit 09c0fda

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed
 

Diff for: ‎ChangeLog-10.1.md

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
All notable changes are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
44

5+
## [10.1.15] - 2024-MM-DD
6+
7+
### Fixed
8+
9+
* [#967](https://github.com/sebastianbergmann/php-code-coverage/issues/967): Identification of executable lines for `match` expressions does not work correctly
10+
511
## [10.1.14] - 2024-03-12
612

713
### Fixed
@@ -101,6 +107,7 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](htt
101107

102108
* The `SebastianBergmann\CodeCoverage\Filter::includeDirectory()`, `SebastianBergmann\CodeCoverage\Filter::excludeDirectory()`, and `SebastianBergmann\CodeCoverage\Filter::excludeFile()` methods are now deprecated
103109

110+
[10.1.15]: https://github.com/sebastianbergmann/php-code-coverage/compare/10.1.14...10.1
104111
[10.1.14]: https://github.com/sebastianbergmann/php-code-coverage/compare/10.1.13...10.1.14
105112
[10.1.13]: https://github.com/sebastianbergmann/php-code-coverage/compare/10.1.12...10.1.13
106113
[10.1.12]: https://github.com/sebastianbergmann/php-code-coverage/compare/10.1.11...10.1.12

Diff for: ‎src/StaticAnalysis/ExecutableLinesFindingVisitor.php

+12-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ public function enterNode(Node $node): void
105105
$node instanceof Node\Stmt\Use_ ||
106106
$node instanceof Node\Stmt\UseUse ||
107107
$node instanceof Node\Expr\ConstFetch ||
108-
$node instanceof Node\Expr\Match_ ||
109108
$node instanceof Node\Expr\Variable ||
110109
$node instanceof Node\Expr\Throw_ ||
111110
$node instanceof Node\ComplexType ||
@@ -117,6 +116,18 @@ public function enterNode(Node $node): void
117116
return;
118117
}
119118

119+
if ($node instanceof Node\Expr\Match_) {
120+
foreach ($node->arms as $arm) {
121+
$this->setLineBranch(
122+
$arm->body->getStartLine(),
123+
$arm->body->getEndLine(),
124+
++$this->nextBranch,
125+
);
126+
}
127+
128+
return;
129+
}
130+
120131
/*
121132
* nikic/php-parser ^4.18 represents <code>throw</code> statements
122133
* as <code>Stmt\Throw_</code> objects

Diff for: ‎tests/tests/StaticAnalysis/ExecutableLinesFindingVisitorTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
*/
1010
namespace SebastianBergmann\CodeCoverage\StaticAnalysis;
1111

12-
use PHPUnit\Framework\Attributes\Ticket;
1312
use function explode;
1413
use function file_get_contents;
1514
use function preg_match;
@@ -18,6 +17,7 @@
1817
use PhpParser\ParserFactory;
1918
use PHPUnit\Framework\Attributes\CoversClass;
2019
use PHPUnit\Framework\Attributes\RequiresPhp;
20+
use PHPUnit\Framework\Attributes\Ticket;
2121
use PHPUnit\Framework\TestCase;
2222

2323
#[CoversClass(ExecutableLinesFindingVisitor::class)]

0 commit comments

Comments
 (0)
Please sign in to comment.