Skip to content

Commit 7c0a6b6

Browse files
Merge branch '12.5'
* 12.5: Prepare release Executable lines: skip `Attributes`
2 parents a9a9019 + a25bde1 commit 7c0a6b6

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

ChangeLog-14.1.md

Lines changed: 7 additions & 0 deletions
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+
## [14.1.1] - 2026-MM-DD
6+
7+
### Fixed
8+
9+
* [#1149](https://github.com/sebastianbergmann/php-code-coverage/pull/1149): Lines spanned by attributes are treated as executable
10+
511
## [14.1.0] - 2026-04-12
612

713
### Added
@@ -16,4 +22,5 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](htt
1622

1723
* [#1147](https://github.com/sebastianbergmann/php-code-coverage/pull/1147): `CoversClass` does not transitively target traits used by enumerations
1824

25+
[14.1.1]: https://github.com/sebastianbergmann/php-code-coverage/compare/14.1.0...main
1926
[14.1.0]: https://github.com/sebastianbergmann/php-code-coverage/compare/14.0.0...14.1.0

src/StaticAnalysis/Visitor/ExecutableLinesFindingVisitor.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ public function enterNode(Node $node): null
8585
return null;
8686
}
8787

88-
if ($node instanceof Node\Stmt\Interface_) {
88+
if ($node instanceof Node\Stmt\Interface_ ||
89+
$node instanceof Node\Attribute
90+
) {
8991
foreach (range($node->getStartLine(), $node->getEndLine()) as $line) {
9092
$this->unsets[$line] = true;
9193
}

tests/_files/source_for_branched_exec_lines.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,3 +609,18 @@ public function m4(): void
609609
{
610610
} // +1
611611
}
612+
613+
#[\Attribute]
614+
class AttributeWithCtor
615+
{
616+
public function __construct(array $myArray)
617+
{} // +2
618+
}
619+
620+
#[AttributeWithCtor(myArray: [
621+
'foo' => [
622+
'bar' => 'baz',
623+
],
624+
])]
625+
class MyClassWithAttribute
626+
{}

0 commit comments

Comments
 (0)