sebastianbergmann / php-code-coverage

Library that provides collection, processing, and rendering functionality for PHP code coverage information.
BSD 3-Clause "New" or "Revised" License
8.82k stars 374 forks source link

`@codeCoverageIgnore` annotation does not work on `enum` #1033

Closed KorDum closed 8 months ago

KorDum commented 8 months ago
Q A
PHPUnit version 10.5.12
PHP version 8.3.3
Installation Method Composer

Summary

If you specify an annotation at a class, code coverage ignores the class and its methods. This is correct behavior. But the same does not work for enum, but it works for its methods.

Current behavior

Annotation codeCoverageIgnore ingores for enums.

How to reproduce

/**
 * @codeCoverageIgnore
 */
enum Some
{
    case SomeCase;

    // not ignored, red coverage
    public function isSomeCase(): bool
    {
        return $this === self::SomeCase;
    }
}

enum Some
{
    case SomeCase;

    /**
     * @codeCoverageIgnore
     * ok ignored, without coverage
     */
    public function isSomeCase(): bool
    {
        return $this === self::SomeCase;
    }
}

Expected behavior

Code coverage will ignore enum and predicate.