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.81k stars 373 forks source link

Improve method coverage line /w attributes #1030

Open mvorisek opened 8 months ago

mvorisek commented 8 months ago
Q A
php-code-coverage version 10.1.11
PHP version 8.3.0
Driver Xdebug
PCOV version (if used) n/a
Xdebug version (if used) 3.3.1
Installation Method Composer
Usage Method PHPUnit
PHPUnit version (if used) 10.5.9

repro code:

<?php

declare(strict_types=1);

namespace Atk4\Data\Persistence;

// dummy space to match the line numbers in the screenshot below
//

class GenericPlatform extends Platforms\AbstractPlatform
{
    private function createNotSupportedException(): \Exception
    {
        return DbalException::notSupported('SQL');
    }

    #[\Override]
    public function getName(): string
    {
        return 'atk4_data_generic';
    }

    #[\Override]
    protected function initializeDoctrineTypeMappings(): void {}
}

image

This is a feature request to improve the emitted coverage line of method to be the "line where the method name (or visibility) is declared".

In the example screen, I would coverage to be emitted on l18 and l24 (instead l17 and l23).

sebastianbergmann commented 8 months ago

Lines that only contain attribute declarations should be marked as not executable / coverable.