Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. RawCodeCoverageData.php

function RawCodeCoverageData::fromXdebugWithPathCoverage

@psalm-param XdebugCodeCoverageWithPathCoverageType $rawCoverage

1 call to RawCodeCoverageData::fromXdebugWithPathCoverage()
XdebugDriver::stop in vendor/phpunit/php-code-coverage/src/Driver/XdebugDriver.php

File

vendor/phpunit/php-code-coverage/src/Data/RawCodeCoverageData.php, line 65

Class

RawCodeCoverageData
@internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage

Namespace

SebastianBergmann\CodeCoverage\Data

Code

public static function fromXdebugWithPathCoverage(array $rawCoverage) : self {
    $lineCoverage = [];
    $functionCoverage = [];
    foreach ($rawCoverage as $file => $fileCoverageData) {
        // Xdebug annotates the function name of traits, strip that off
        foreach ($fileCoverageData['functions'] as $existingKey => $data) {
            if (str_ends_with($existingKey, '}') && !str_starts_with($existingKey, '{')) {
                // don't want to catch {main}
                $newKey = preg_replace('/\\{.*}$/', '', $existingKey);
                $fileCoverageData['functions'][$newKey] = $data;
                unset($fileCoverageData['functions'][$existingKey]);
            }
        }
        $lineCoverage[$file] = $fileCoverageData['lines'];
        $functionCoverage[$file] = $fileCoverageData['functions'];
    }
    return new self($lineCoverage, $functionCoverage);
}
RSS feed
Powered by Drupal