Skip to content

Commit 007dc7c

Browse files
Merge branch '10.1'
2 parents 41fd4ec + 316534a commit 007dc7c

5 files changed

+58
-0
lines changed

Diff for: ChangeLog-11.0.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+
## [11.0.3] - 2024-MM-DD
6+
7+
### Fixed
8+
9+
* [#1033](https://github.com/sebastianbergmann/php-code-coverage/issues/1033): `@codeCoverageIgnore` annotation does not work on `enum`
10+
511
## [11.0.2] - 2024-03-09
612

713
### Changed
@@ -22,6 +28,7 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](htt
2228
* This component now requires PHP-Parser 5
2329
* This component is no longer supported on PHP 8.1
2430

31+
[11.0.3]: https://github.com/sebastianbergmann/php-code-coverage/compare/11.0.2...main
2532
[11.0.2]: https://github.com/sebastianbergmann/php-code-coverage/compare/11.0.1...11.0.2
2633
[11.0.1]: https://github.com/sebastianbergmann/php-code-coverage/compare/11.0.0...11.0.1
2734
[11.0.0]: https://github.com/sebastianbergmann/php-code-coverage/compare/10.1...11.0.0

Diff for: src/StaticAnalysis/IgnoredLinesFindingVisitor.php

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use PhpParser\Node\Attribute;
1616
use PhpParser\Node\Stmt\Class_;
1717
use PhpParser\Node\Stmt\ClassMethod;
18+
use PhpParser\Node\Stmt\Enum_;
1819
use PhpParser\Node\Stmt\Function_;
1920
use PhpParser\Node\Stmt\Interface_;
2021
use PhpParser\Node\Stmt\Trait_;
@@ -43,6 +44,7 @@ public function enterNode(Node $node): void
4344
if (!$node instanceof Class_ &&
4445
!$node instanceof Trait_ &&
4546
!$node instanceof Interface_ &&
47+
!$node instanceof Enum_ &&
4648
!$node instanceof ClassMethod &&
4749
!$node instanceof Function_ &&
4850
!$node instanceof Attribute) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php declare(strict_types=1);
2+
/**
3+
* @codeCoverageIgnore
4+
*/
5+
enum TestEnumeration
6+
{
7+
case SomeCase;
8+
9+
public function isSomeCase(): bool
10+
{
11+
return $this === self::SomeCase;
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php declare(strict_types=1);
2+
enum TestEnumeration
3+
{
4+
case SomeCase;
5+
6+
/**
7+
* @codeCoverageIgnore
8+
*/
9+
public function isSomeCase(): bool
10+
{
11+
return $this === self::SomeCase;
12+
}
13+
}

Diff for: tests/tests/StaticAnalysis/ParsingFileAnalyserTest.php

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

12+
use function range;
1213
use PHPUnit\Framework\Attributes\CoversClass;
1314
use PHPUnit\Framework\Attributes\Ticket;
1415
use PHPUnit\Framework\TestCase;
@@ -162,4 +163,26 @@ public function testLinesCanBeIgnoredUsingAttribute(): void
162163
),
163164
);
164165
}
166+
167+
#[Ticket('https://github.com/sebastianbergmann/php-code-coverage/issues/1033')]
168+
public function testEnumWithEnumLevelIgnore(): void
169+
{
170+
$this->assertSame(
171+
range(5, 13),
172+
(new ParsingFileAnalyser(true, true))->ignoredLinesFor(
173+
TEST_FILES_PATH . 'source_with_enum_and_enum_level_ignore_annotation.php',
174+
),
175+
);
176+
}
177+
178+
#[Ticket('https://github.com/sebastianbergmann/php-code-coverage/issues/1033')]
179+
public function testEnumWithMethodLevelIgnore(): void
180+
{
181+
$this->assertSame(
182+
range(9, 12),
183+
(new ParsingFileAnalyser(true, true))->ignoredLinesFor(
184+
TEST_FILES_PATH . 'source_with_enum_and_method_level_ignore_annotation.php',
185+
),
186+
);
187+
}
165188
}

0 commit comments

Comments
 (0)