Skip to content

Commit

Permalink
Merge branch '10.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Mar 12, 2024
2 parents 41fd4ec + 316534a commit 007dc7c
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ChangeLog-11.0.md
Expand Up @@ -2,6 +2,12 @@

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

## [11.0.3] - 2024-MM-DD

### Fixed

* [#1033](https://github.com/sebastianbergmann/php-code-coverage/issues/1033): `@codeCoverageIgnore` annotation does not work on `enum`

## [11.0.2] - 2024-03-09

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

[11.0.3]: https://github.com/sebastianbergmann/php-code-coverage/compare/11.0.2...main
[11.0.2]: https://github.com/sebastianbergmann/php-code-coverage/compare/11.0.1...11.0.2
[11.0.1]: https://github.com/sebastianbergmann/php-code-coverage/compare/11.0.0...11.0.1
[11.0.0]: https://github.com/sebastianbergmann/php-code-coverage/compare/10.1...11.0.0
2 changes: 2 additions & 0 deletions src/StaticAnalysis/IgnoredLinesFindingVisitor.php
Expand Up @@ -15,6 +15,7 @@
use PhpParser\Node\Attribute;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Enum_;
use PhpParser\Node\Stmt\Function_;
use PhpParser\Node\Stmt\Interface_;
use PhpParser\Node\Stmt\Trait_;
Expand Down Expand Up @@ -43,6 +44,7 @@ public function enterNode(Node $node): void
if (!$node instanceof Class_ &&
!$node instanceof Trait_ &&
!$node instanceof Interface_ &&
!$node instanceof Enum_ &&
!$node instanceof ClassMethod &&
!$node instanceof Function_ &&
!$node instanceof Attribute) {
Expand Down
13 changes: 13 additions & 0 deletions tests/_files/source_with_enum_and_enum_level_ignore_annotation.php
@@ -0,0 +1,13 @@
<?php declare(strict_types=1);
/**
* @codeCoverageIgnore
*/
enum TestEnumeration
{
case SomeCase;

public function isSomeCase(): bool
{
return $this === self::SomeCase;
}
}
@@ -0,0 +1,13 @@
<?php declare(strict_types=1);
enum TestEnumeration
{
case SomeCase;

/**
* @codeCoverageIgnore
*/
public function isSomeCase(): bool
{
return $this === self::SomeCase;
}
}
23 changes: 23 additions & 0 deletions tests/tests/StaticAnalysis/ParsingFileAnalyserTest.php
Expand Up @@ -9,6 +9,7 @@
*/
namespace SebastianBergmann\CodeCoverage\StaticAnalysis;

use function range;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Ticket;
use PHPUnit\Framework\TestCase;
Expand Down Expand Up @@ -162,4 +163,26 @@ public function testLinesCanBeIgnoredUsingAttribute(): void
),
);
}

#[Ticket('https://github.com/sebastianbergmann/php-code-coverage/issues/1033')]
public function testEnumWithEnumLevelIgnore(): void
{
$this->assertSame(
range(5, 13),
(new ParsingFileAnalyser(true, true))->ignoredLinesFor(
TEST_FILES_PATH . 'source_with_enum_and_enum_level_ignore_annotation.php',
),
);
}

#[Ticket('https://github.com/sebastianbergmann/php-code-coverage/issues/1033')]
public function testEnumWithMethodLevelIgnore(): void
{
$this->assertSame(
range(9, 12),
(new ParsingFileAnalyser(true, true))->ignoredLinesFor(
TEST_FILES_PATH . 'source_with_enum_and_method_level_ignore_annotation.php',
),
);
}
}

0 comments on commit 007dc7c

Please sign in to comment.