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

Interface methods are not ignored when their signature is split over multiple lines #1018

Closed Muriano closed 10 months ago

Muriano commented 10 months ago

When generating code coverage in HTML format (using xdebug or PCOV) using PHPUnit 10.4.2, reports of uncovered lines in interfaces are reported. It only seems to happen when method signature is splitted.

phpunit.xml

<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.4/phpunit.xsd"
         bootstrap="vendor/autoload.php"
         cacheDirectory="test/cache/.phpunit"
         executionOrder="depends,defects"
         beStrictAboutOutputDuringTests="true"
         failOnRisky="true"
         failOnWarning="true">
    <testsuites>
        <testsuite name="default">
            <directory>test</directory>
        </testsuite>
    </testsuites>

    <source restrictDeprecations="true" restrictNotices="true" restrictWarnings="true">
        <include>
            <directory>src</directory>
        </include>
    </source>

    <coverage includeUncoveredFiles="true" pathCoverage="true">
        <report>
            <text outputFile="php://stdout"/>
            <html outputDirectory="test/coverage/html"/>
        </report>
    </coverage>
</phpunit>

Actual Text Report (It is OK)

Code Coverage Report:
  2023-11-15 10:04:51

 Summary:
  Classes: 25.00% (2/8)
  Methods: 14.81% (4/27)
  Paths:   26.92% (7/26)
  Branches:   28.57% (10/35)
  Lines:   22.81% (13/57)

GR\CircuitBreaker\Exception\OpenCircuit
  Methods: 100.00% ( 1/ 1)   Paths: 100.00% (  1/  1)   Branches: 100.00% (  1/  1)   Lines: 100.00% (  1/  1)
GR\CircuitBreaker\ServiceCall\CommandServiceCall
  Methods:  50.00% ( 1/ 2)   Paths:  50.00% (  2/  4)   Branches:  37.50% (  3/  8)   Lines:  37.50% (  3/  8)
GR\CircuitBreaker\ServiceCall\QueryServiceCall
  Methods: 100.00% ( 2/ 2)   Paths: 100.00% (  4/  4)   Branches: 100.00% (  6/  6)   Lines: 100.00% (  9/  9)

Actual HTML Report image

Expected HTML Report As @sebastianbergmann says in sebastianbergmann/phpunit#3195 : There is no point in trying to cover an interface, so, reports (all formats) should ignore coverage for interfaces.

sebastianbergmann commented 10 months ago

@Slamdunk Can you have a look? Thanks!