File tree Expand file tree Collapse file tree 4 files changed +34
-0
lines changed
src/StaticAnalysis/Visitor
tests/StaticAnalysis/Visitor Expand file tree Collapse file tree 4 files changed +34
-0
lines changed Original file line number Diff line number Diff line change 22
33All notable changes are documented in this file using the [ Keep a CHANGELOG] ( http://keepachangelog.com/ ) principles.
44
5+ ## [ 14.1.2] - 2026-MM-DD
6+
7+ ### Fixed
8+
9+ * [ #1150 ] ( https://github.com/sebastianbergmann/php-code-coverage/issues/1150 ) : Abstract method declarations are incorrectly counted as executable lines
10+
511## [ 14.1.1] - 2026-04-13
612
713### Fixed
@@ -22,5 +28,6 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](htt
2228
2329* [ #1147 ] ( https://github.com/sebastianbergmann/php-code-coverage/pull/1147 ) : ` CoversClass ` does not transitively target traits used by enumerations
2430
31+ [ 14.1.2 ] : https://github.com/sebastianbergmann/php-code-coverage/compare/14.1.1...main
2532[ 14.1.1 ] : https://github.com/sebastianbergmann/php-code-coverage/compare/14.1.0...14.1.1
2633[ 14.1.0 ] : https://github.com/sebastianbergmann/php-code-coverage/compare/14.0.0...14.1.0
Original file line number Diff line number Diff line change @@ -144,6 +144,10 @@ public function enterNode(Node $node): null
144144 $ node instanceof Node \Stmt \ClassMethod ||
145145 $ node instanceof Node \Expr \Closure ||
146146 $ node instanceof Node \Stmt \Trait_) {
147+ if ($ node instanceof Node \Stmt \ClassMethod && $ node ->isAbstract ()) {
148+ return null ;
149+ }
150+
147151 if ($ node instanceof Node \Stmt \Function_ || $ node instanceof Node \Stmt \ClassMethod) {
148152 $ unsets = [];
149153
Original file line number Diff line number Diff line change @@ -5,7 +5,10 @@ abstract class ClassWithAbstractMethod
55{
66 abstract public function abstractMethod (): void ;
77
8+ abstract protected function anotherAbstractMethod (): void ;
9+
810 public function concreteMethod (): void
911 {
12+ echo 'x ' ;
1013 }
1114}
Original file line number Diff line number Diff line change @@ -77,6 +77,26 @@ public function testEmptyForLoopIsProcessedCorrectly(): void
7777 $ this ->assertNotEmpty ($ result );
7878 }
7979
80+ #[Ticket('https://github.com/sebastianbergmann/phpunit/issues/6442 ' )]
81+ public function testAbstractMethodDeclarationsAreNotExecutable (): void
82+ {
83+ $ source = file_get_contents (__DIR__ . '/../../../_files/source_with_abstract_method.php ' );
84+ $ parser = (new ParserFactory )->createForHostVersion ();
85+ $ nodes = $ parser ->parse ($ source );
86+ $ executableLinesFindingVisitor = new ExecutableLinesFindingVisitor ($ source );
87+
88+ $ traverser = new NodeTraverser ;
89+ $ traverser ->addVisitor ($ executableLinesFindingVisitor );
90+ $ traverser ->traverse ($ nodes );
91+
92+ $ executableLines = $ executableLinesFindingVisitor ->executableLinesGroupedByBranch ();
93+
94+ $ this ->assertArrayNotHasKey (6 , $ executableLines );
95+ $ this ->assertArrayNotHasKey (8 , $ executableLines );
96+
97+ $ this ->assertArrayHasKey (12 , $ executableLines );
98+ }
99+
80100 #[Ticket('https://github.com/sebastianbergmann/php-code-coverage/issues/967 ' )]
81101 public function testMatchArmsAreProcessedCorrectly (): void
82102 {
You can’t perform that action at this time.
0 commit comments