🔧
This commit is contained in:
@@ -160,7 +160,7 @@ final class CodeCoverage
|
||||
$this->tests = $tests;
|
||||
}
|
||||
|
||||
public function start(string $id, TestSize $size = null, bool $clear = false): void
|
||||
public function start(string $id, ?TestSize $size = null, bool $clear = false): void
|
||||
{
|
||||
if ($clear) {
|
||||
$this->clear();
|
||||
@@ -177,13 +177,13 @@ final class CodeCoverage
|
||||
/**
|
||||
* @psalm-param array<string,list<int>> $linesToBeIgnored
|
||||
*/
|
||||
public function stop(bool $append = true, TestStatus $status = null, array|false $linesToBeCovered = [], array $linesToBeUsed = [], array $linesToBeIgnored = []): RawCodeCoverageData
|
||||
public function stop(bool $append = true, ?TestStatus $status = null, array|false $linesToBeCovered = [], array $linesToBeUsed = [], array $linesToBeIgnored = []): RawCodeCoverageData
|
||||
{
|
||||
$data = $this->driver->stop();
|
||||
|
||||
$this->linesToBeIgnored = array_merge_recursive(
|
||||
$this->linesToBeIgnored,
|
||||
$linesToBeIgnored
|
||||
$linesToBeIgnored,
|
||||
);
|
||||
|
||||
$this->append($data, null, $append, $status, $linesToBeCovered, $linesToBeUsed, $linesToBeIgnored);
|
||||
@@ -202,7 +202,7 @@ final class CodeCoverage
|
||||
* @throws TestIdMissingException
|
||||
* @throws UnintentionallyCoveredCodeException
|
||||
*/
|
||||
public function append(RawCodeCoverageData $rawData, string $id = null, bool $append = true, TestStatus $status = null, array|false $linesToBeCovered = [], array $linesToBeUsed = [], array $linesToBeIgnored = []): void
|
||||
public function append(RawCodeCoverageData $rawData, ?string $id = null, bool $append = true, ?TestStatus $status = null, array|false $linesToBeCovered = [], array $linesToBeUsed = [], array $linesToBeIgnored = []): void
|
||||
{
|
||||
if ($id === null) {
|
||||
$id = $this->currentId;
|
||||
@@ -246,7 +246,7 @@ final class CodeCoverage
|
||||
$rawData,
|
||||
$linesToBeCovered,
|
||||
$linesToBeUsed,
|
||||
$size
|
||||
$size,
|
||||
);
|
||||
|
||||
if (empty($rawData->lineCoverage())) {
|
||||
@@ -267,7 +267,7 @@ final class CodeCoverage
|
||||
public function merge(self $that): void
|
||||
{
|
||||
$this->filter->includeFiles(
|
||||
$that->filter()->files()
|
||||
$that->filter()->files(),
|
||||
);
|
||||
|
||||
$this->data->merge($that->data);
|
||||
@@ -342,7 +342,7 @@ final class CodeCoverage
|
||||
{
|
||||
if (!$this->cachesStaticAnalysis()) {
|
||||
throw new StaticAnalysisCacheNotConfiguredException(
|
||||
'The static analysis cache is not configured'
|
||||
'The static analysis cache is not configured',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -436,12 +436,12 @@ final class CodeCoverage
|
||||
|
||||
$data->keepLineCoverageDataOnlyForLines(
|
||||
$filename,
|
||||
array_keys($linesToBranchMap)
|
||||
array_keys($linesToBranchMap),
|
||||
);
|
||||
|
||||
$data->markExecutableLineByBranch(
|
||||
$filename,
|
||||
$linesToBranchMap
|
||||
$linesToBranchMap,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -459,13 +459,13 @@ final class CodeCoverage
|
||||
if (isset($linesToBeIgnored[$filename])) {
|
||||
$data->removeCoverageDataForLines(
|
||||
$filename,
|
||||
$linesToBeIgnored[$filename]
|
||||
$linesToBeIgnored[$filename],
|
||||
);
|
||||
}
|
||||
|
||||
$data->removeCoverageDataForLines(
|
||||
$filename,
|
||||
$this->analyser()->ignoredLinesFor($filename)
|
||||
$this->analyser()->ignoredLinesFor($filename),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -477,7 +477,7 @@ final class CodeCoverage
|
||||
{
|
||||
$uncoveredFiles = array_diff(
|
||||
$this->filter->files(),
|
||||
$this->data->coveredFiles()
|
||||
$this->data->coveredFiles(),
|
||||
);
|
||||
|
||||
foreach ($uncoveredFiles as $uncoveredFile) {
|
||||
@@ -485,10 +485,10 @@ final class CodeCoverage
|
||||
$this->append(
|
||||
RawCodeCoverageData::fromUncoveredFile(
|
||||
$uncoveredFile,
|
||||
$this->analyser()
|
||||
$this->analyser(),
|
||||
),
|
||||
self::UNCOVERED_FILES,
|
||||
linesToBeIgnored: $this->linesToBeIgnored
|
||||
linesToBeIgnored: $this->linesToBeIgnored,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -502,7 +502,7 @@ final class CodeCoverage
|
||||
{
|
||||
$allowedLines = $this->getAllowedLines(
|
||||
$linesToBeCovered,
|
||||
$linesToBeUsed
|
||||
$linesToBeUsed,
|
||||
);
|
||||
|
||||
$unintentionallyCoveredUnits = [];
|
||||
@@ -519,7 +519,7 @@ final class CodeCoverage
|
||||
|
||||
if (!empty($unintentionallyCoveredUnits)) {
|
||||
throw new UnintentionallyCoveredCodeException(
|
||||
$unintentionallyCoveredUnits
|
||||
$unintentionallyCoveredUnits,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -535,7 +535,7 @@ final class CodeCoverage
|
||||
|
||||
$allowedLines[$file] = array_merge(
|
||||
$allowedLines[$file],
|
||||
$linesToBeCovered[$file]
|
||||
$linesToBeCovered[$file],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -546,13 +546,13 @@ final class CodeCoverage
|
||||
|
||||
$allowedLines[$file] = array_merge(
|
||||
$allowedLines[$file],
|
||||
$linesToBeUsed[$file]
|
||||
$linesToBeUsed[$file],
|
||||
);
|
||||
}
|
||||
|
||||
foreach (array_keys($allowedLines) as $file) {
|
||||
$allowedLines[$file] = array_flip(
|
||||
array_unique($allowedLines[$file])
|
||||
array_unique($allowedLines[$file]),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -592,7 +592,7 @@ final class CodeCoverage
|
||||
throw new ReflectionException(
|
||||
$e->getMessage(),
|
||||
$e->getCode(),
|
||||
$e
|
||||
$e,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -614,7 +614,7 @@ final class CodeCoverage
|
||||
|
||||
$this->analyser = new ParsingFileAnalyser(
|
||||
$this->useAnnotationsForIgnoringCode,
|
||||
$this->ignoreDeprecatedCode
|
||||
$this->ignoreDeprecatedCode,
|
||||
);
|
||||
|
||||
if ($this->cachesStaticAnalysis()) {
|
||||
@@ -622,7 +622,7 @@ final class CodeCoverage
|
||||
$this->cacheDirectory,
|
||||
$this->analyser,
|
||||
$this->useAnnotationsForIgnoringCode,
|
||||
$this->ignoreDeprecatedCode
|
||||
$this->ignoreDeprecatedCode,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -164,8 +164,8 @@ final class ProcessedCodeCoverageData
|
||||
$compareLineNumbers = array_unique(
|
||||
array_merge(
|
||||
array_keys($this->lineCoverage[$file]),
|
||||
array_keys($newData->lineCoverage[$file])
|
||||
)
|
||||
array_keys($newData->lineCoverage[$file]),
|
||||
),
|
||||
);
|
||||
|
||||
foreach ($compareLineNumbers as $line) {
|
||||
@@ -176,7 +176,7 @@ final class ProcessedCodeCoverageData
|
||||
$this->lineCoverage[$file][$line] = $newData->lineCoverage[$file][$line];
|
||||
} elseif ($thatPriority === $thisPriority && is_array($this->lineCoverage[$file][$line])) {
|
||||
$this->lineCoverage[$file][$line] = array_unique(
|
||||
array_merge($this->lineCoverage[$file][$line], $newData->lineCoverage[$file][$line])
|
||||
array_merge($this->lineCoverage[$file][$line], $newData->lineCoverage[$file][$line]),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ final class RawCodeCoverageData
|
||||
|
||||
$this->lineCoverage[$filename] = array_intersect_key(
|
||||
$this->lineCoverage[$filename],
|
||||
array_flip($lines)
|
||||
array_flip($lines),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -223,7 +223,7 @@ final class RawCodeCoverageData
|
||||
|
||||
$this->lineCoverage[$filename] = array_diff_key(
|
||||
$this->lineCoverage[$filename],
|
||||
array_flip($lines)
|
||||
array_flip($lines),
|
||||
);
|
||||
|
||||
if (isset($this->functionCoverage[$filename])) {
|
||||
|
||||
@@ -75,8 +75,8 @@ abstract class Driver
|
||||
throw new BranchAndPathCoverageNotSupportedException(
|
||||
sprintf(
|
||||
'%s does not support branch and path coverage',
|
||||
$this->nameAndVersion()
|
||||
)
|
||||
$this->nameAndVersion(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -107,8 +107,8 @@ abstract class Driver
|
||||
throw new DeadCodeDetectionNotSupportedException(
|
||||
sprintf(
|
||||
'%s does not support dead code detection',
|
||||
$this->nameAndVersion()
|
||||
)
|
||||
$this->nameAndVersion(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ final class XdebugDriver extends Driver
|
||||
xdebug_set_filter(
|
||||
XDEBUG_FILTER_CODE_COVERAGE,
|
||||
XDEBUG_PATH_INCLUDE,
|
||||
$filter->files()
|
||||
$filter->files(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,6 @@ final class XdebugNotEnabledException extends RuntimeException implements Except
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('XDEBUG_MODE=coverage or xdebug.mode=coverage has to be set');
|
||||
parent::__construct('XDEBUG_MODE=coverage (environment variable) or xdebug.mode=coverage (PHP configuration setting) has to be set');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ abstract class AbstractNode implements Countable
|
||||
private readonly ?AbstractNode $parent;
|
||||
private string $id;
|
||||
|
||||
public function __construct(string $name, self $parent = null)
|
||||
public function __construct(string $name, ?self $parent = null)
|
||||
{
|
||||
if (str_ends_with($name, DIRECTORY_SEPARATOR)) {
|
||||
$name = substr($name, 0, -1);
|
||||
@@ -131,7 +131,7 @@ abstract class AbstractNode implements Countable
|
||||
{
|
||||
return Percentage::fromFractionAndTotal(
|
||||
$this->numberOfExecutedBranches(),
|
||||
$this->numberOfExecutableBranches()
|
||||
$this->numberOfExecutableBranches(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ abstract class AbstractNode implements Countable
|
||||
{
|
||||
return Percentage::fromFractionAndTotal(
|
||||
$this->numberOfExecutedPaths(),
|
||||
$this->numberOfExecutablePaths()
|
||||
$this->numberOfExecutablePaths(),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -45,13 +45,13 @@ final class Builder
|
||||
$commonPath = $this->reducePaths($data);
|
||||
$root = new Directory(
|
||||
$commonPath,
|
||||
null
|
||||
null,
|
||||
);
|
||||
|
||||
$this->addItems(
|
||||
$root,
|
||||
$this->buildDirectoryStructure($data),
|
||||
$coverage->getTests()
|
||||
$coverage->getTests(),
|
||||
);
|
||||
|
||||
return $root;
|
||||
@@ -80,8 +80,8 @@ final class Builder
|
||||
$this->analyser->classesIn($filename),
|
||||
$this->analyser->traitsIn($filename),
|
||||
$this->analyser->functionsIn($filename),
|
||||
$this->analyser->linesOfCodeFor($filename)
|
||||
)
|
||||
$this->analyser->linesOfCodeFor($filename),
|
||||
),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -37,7 +37,7 @@ final class CrapIndex
|
||||
|
||||
return sprintf(
|
||||
'%01.2F',
|
||||
$this->cyclomaticComplexity ** 2 * (1 - $this->codeCoverage / 100) ** 3 + $this->cyclomaticComplexity
|
||||
$this->cyclomaticComplexity ** 2 * (1 - $this->codeCoverage / 100) ** 3 + $this->cyclomaticComplexity,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ final class Directory extends AbstractNode implements IteratorAggregate
|
||||
{
|
||||
return new RecursiveIteratorIterator(
|
||||
new Iterator($this),
|
||||
RecursiveIteratorIterator::SELF_FIRST
|
||||
RecursiveIteratorIterator::SELF_FIRST,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ final class Directory extends AbstractNode implements IteratorAggregate
|
||||
foreach ($this->children as $child) {
|
||||
$this->classes = array_merge(
|
||||
$this->classes,
|
||||
$child->classes()
|
||||
$child->classes(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -138,7 +138,7 @@ final class Directory extends AbstractNode implements IteratorAggregate
|
||||
foreach ($this->children as $child) {
|
||||
$this->traits = array_merge(
|
||||
$this->traits,
|
||||
$child->traits()
|
||||
$child->traits(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -154,7 +154,7 @@ final class Directory extends AbstractNode implements IteratorAggregate
|
||||
foreach ($this->children as $child) {
|
||||
$this->functions = array_merge(
|
||||
$this->functions,
|
||||
$child->functions()
|
||||
$child->functions(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -177,8 +177,8 @@ final class Directory extends AbstractNode implements IteratorAggregate
|
||||
foreach ($this->children as $child) {
|
||||
$childLinesOfCode = $child->linesOfCode();
|
||||
|
||||
$this->linesOfCode['linesOfCode'] += $childLinesOfCode['linesOfCode'];
|
||||
$this->linesOfCode['commentLinesOfCode'] += $childLinesOfCode['commentLinesOfCode'];
|
||||
$this->linesOfCode['linesOfCode'] += $childLinesOfCode['linesOfCode'];
|
||||
$this->linesOfCode['commentLinesOfCode'] += $childLinesOfCode['commentLinesOfCode'];
|
||||
$this->linesOfCode['nonCommentLinesOfCode'] += $childLinesOfCode['nonCommentLinesOfCode'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -487,14 +487,14 @@ final class File extends AbstractNode
|
||||
$this->classes[$className]['methods'][$methodName] = $methodData;
|
||||
|
||||
$this->classes[$className]['executableBranches'] += $methodData['executableBranches'];
|
||||
$this->classes[$className]['executedBranches'] += $methodData['executedBranches'];
|
||||
$this->classes[$className]['executablePaths'] += $methodData['executablePaths'];
|
||||
$this->classes[$className]['executedPaths'] += $methodData['executedPaths'];
|
||||
$this->classes[$className]['executedBranches'] += $methodData['executedBranches'];
|
||||
$this->classes[$className]['executablePaths'] += $methodData['executablePaths'];
|
||||
$this->classes[$className]['executedPaths'] += $methodData['executedPaths'];
|
||||
|
||||
$this->numExecutableBranches += $methodData['executableBranches'];
|
||||
$this->numExecutedBranches += $methodData['executedBranches'];
|
||||
$this->numExecutablePaths += $methodData['executablePaths'];
|
||||
$this->numExecutedPaths += $methodData['executedPaths'];
|
||||
$this->numExecutedBranches += $methodData['executedBranches'];
|
||||
$this->numExecutablePaths += $methodData['executablePaths'];
|
||||
$this->numExecutedPaths += $methodData['executedPaths'];
|
||||
|
||||
foreach (range($method['startLine'], $method['endLine']) as $lineNumber) {
|
||||
$this->codeUnitsByLine[$lineNumber] = [
|
||||
@@ -536,14 +536,14 @@ final class File extends AbstractNode
|
||||
$this->traits[$traitName]['methods'][$methodName] = $methodData;
|
||||
|
||||
$this->traits[$traitName]['executableBranches'] += $methodData['executableBranches'];
|
||||
$this->traits[$traitName]['executedBranches'] += $methodData['executedBranches'];
|
||||
$this->traits[$traitName]['executablePaths'] += $methodData['executablePaths'];
|
||||
$this->traits[$traitName]['executedPaths'] += $methodData['executedPaths'];
|
||||
$this->traits[$traitName]['executedBranches'] += $methodData['executedBranches'];
|
||||
$this->traits[$traitName]['executablePaths'] += $methodData['executablePaths'];
|
||||
$this->traits[$traitName]['executedPaths'] += $methodData['executedPaths'];
|
||||
|
||||
$this->numExecutableBranches += $methodData['executableBranches'];
|
||||
$this->numExecutedBranches += $methodData['executedBranches'];
|
||||
$this->numExecutablePaths += $methodData['executablePaths'];
|
||||
$this->numExecutedPaths += $methodData['executedPaths'];
|
||||
$this->numExecutedBranches += $methodData['executedBranches'];
|
||||
$this->numExecutablePaths += $methodData['executablePaths'];
|
||||
$this->numExecutedPaths += $methodData['executedPaths'];
|
||||
|
||||
foreach (range($method['startLine'], $method['endLine']) as $lineNumber) {
|
||||
$this->codeUnitsByLine[$lineNumber] = [
|
||||
@@ -587,7 +587,7 @@ final class File extends AbstractNode
|
||||
|
||||
if (isset($this->functionCoverageData[$functionName]['branches'])) {
|
||||
$this->functions[$functionName]['executableBranches'] = count(
|
||||
$this->functionCoverageData[$functionName]['branches']
|
||||
$this->functionCoverageData[$functionName]['branches'],
|
||||
);
|
||||
|
||||
$this->functions[$functionName]['executedBranches'] = count(
|
||||
@@ -596,14 +596,14 @@ final class File extends AbstractNode
|
||||
static function (array $branch)
|
||||
{
|
||||
return (bool) $branch['hit'];
|
||||
}
|
||||
)
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($this->functionCoverageData[$functionName]['paths'])) {
|
||||
$this->functions[$functionName]['executablePaths'] = count(
|
||||
$this->functionCoverageData[$functionName]['paths']
|
||||
$this->functionCoverageData[$functionName]['paths'],
|
||||
);
|
||||
|
||||
$this->functions[$functionName]['executedPaths'] = count(
|
||||
@@ -612,15 +612,15 @@ final class File extends AbstractNode
|
||||
static function (array $path)
|
||||
{
|
||||
return (bool) $path['hit'];
|
||||
}
|
||||
)
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
$this->numExecutableBranches += $this->functions[$functionName]['executableBranches'];
|
||||
$this->numExecutedBranches += $this->functions[$functionName]['executedBranches'];
|
||||
$this->numExecutablePaths += $this->functions[$functionName]['executablePaths'];
|
||||
$this->numExecutedPaths += $this->functions[$functionName]['executedPaths'];
|
||||
$this->numExecutedBranches += $this->functions[$functionName]['executedBranches'];
|
||||
$this->numExecutablePaths += $this->functions[$functionName]['executablePaths'];
|
||||
$this->numExecutedPaths += $this->functions[$functionName]['executedPaths'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -653,7 +653,7 @@ final class File extends AbstractNode
|
||||
|
||||
if (isset($this->functionCoverageData[$key]['branches'])) {
|
||||
$methodData['executableBranches'] = count(
|
||||
$this->functionCoverageData[$key]['branches']
|
||||
$this->functionCoverageData[$key]['branches'],
|
||||
);
|
||||
|
||||
$methodData['executedBranches'] = count(
|
||||
@@ -662,14 +662,14 @@ final class File extends AbstractNode
|
||||
static function (array $branch)
|
||||
{
|
||||
return (bool) $branch['hit'];
|
||||
}
|
||||
)
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($this->functionCoverageData[$key]['paths'])) {
|
||||
$methodData['executablePaths'] = count(
|
||||
$this->functionCoverageData[$key]['paths']
|
||||
$this->functionCoverageData[$key]['paths'],
|
||||
);
|
||||
|
||||
$methodData['executedPaths'] = count(
|
||||
@@ -678,8 +678,8 @@ final class File extends AbstractNode
|
||||
static function (array $path)
|
||||
{
|
||||
return (bool) $path['hit'];
|
||||
}
|
||||
)
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ use function is_string;
|
||||
use function ksort;
|
||||
use function max;
|
||||
use function range;
|
||||
use function strpos;
|
||||
use function str_contains;
|
||||
use function time;
|
||||
use DOMDocument;
|
||||
use SebastianBergmann\CodeCoverage\CodeCoverage;
|
||||
@@ -79,7 +79,7 @@ final class Clover
|
||||
}
|
||||
|
||||
$classMethods++;
|
||||
$classStatements += $method['executableLines'];
|
||||
$classStatements += $method['executableLines'];
|
||||
$coveredClassStatements += $method['executedLines'];
|
||||
|
||||
if ($method['coverage'] == 100) {
|
||||
@@ -115,28 +115,28 @@ final class Clover
|
||||
if (!empty($class['package']['fullPackage'])) {
|
||||
$xmlClass->setAttribute(
|
||||
'fullPackage',
|
||||
$class['package']['fullPackage']
|
||||
$class['package']['fullPackage'],
|
||||
);
|
||||
}
|
||||
|
||||
if (!empty($class['package']['category'])) {
|
||||
$xmlClass->setAttribute(
|
||||
'category',
|
||||
$class['package']['category']
|
||||
$class['package']['category'],
|
||||
);
|
||||
}
|
||||
|
||||
if (!empty($class['package']['package'])) {
|
||||
$xmlClass->setAttribute(
|
||||
'package',
|
||||
$class['package']['package']
|
||||
$class['package']['package'],
|
||||
);
|
||||
}
|
||||
|
||||
if (!empty($class['package']['subpackage'])) {
|
||||
$xmlClass->setAttribute(
|
||||
'subpackage',
|
||||
$class['package']['subpackage']
|
||||
$class['package']['subpackage'],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ final class Clover
|
||||
} else {
|
||||
if (!isset($packages[$namespace])) {
|
||||
$packages[$namespace] = $xmlDocument->createElement(
|
||||
'package'
|
||||
'package',
|
||||
);
|
||||
|
||||
$packages[$namespace]->setAttribute('name', $namespace);
|
||||
@@ -244,7 +244,7 @@ final class Clover
|
||||
$buffer = $xmlDocument->saveXML();
|
||||
|
||||
if ($target !== null) {
|
||||
if (!strpos($target, '://') !== false) {
|
||||
if (!str_contains($target, '://')) {
|
||||
Filesystem::createDirectory(dirname($target));
|
||||
}
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@ use function dirname;
|
||||
use function file_put_contents;
|
||||
use function preg_match;
|
||||
use function range;
|
||||
use function str_contains;
|
||||
use function str_replace;
|
||||
use function strpos;
|
||||
use function time;
|
||||
use DOMImplementation;
|
||||
use SebastianBergmann\CodeCoverage\CodeCoverage;
|
||||
@@ -40,7 +40,7 @@ final class Cobertura
|
||||
$documentType = $implementation->createDocumentType(
|
||||
'coverage',
|
||||
'',
|
||||
'http://cobertura.sourceforge.net/xml/coverage-04.dtd'
|
||||
'http://cobertura.sourceforge.net/xml/coverage-04.dtd',
|
||||
);
|
||||
|
||||
$document = $implementation->createDocument('', '', $documentType);
|
||||
@@ -114,7 +114,7 @@ final class Cobertura
|
||||
$coverageData = $item->lineCoverageData();
|
||||
|
||||
foreach ($classes as $className => $class) {
|
||||
$complexity += $class['ccn'];
|
||||
$complexity += $class['ccn'];
|
||||
$packageComplexity += $class['ccn'];
|
||||
|
||||
if (!empty($class['package']['namespace'])) {
|
||||
@@ -225,22 +225,22 @@ final class Cobertura
|
||||
continue;
|
||||
}
|
||||
|
||||
$complexity += $function['ccn'];
|
||||
$packageComplexity += $function['ccn'];
|
||||
$complexity += $function['ccn'];
|
||||
$packageComplexity += $function['ccn'];
|
||||
$functionsComplexity += $function['ccn'];
|
||||
|
||||
$linesValid = $function['executableLines'];
|
||||
$linesCovered = $function['executedLines'];
|
||||
$lineRate = $linesValid === 0 ? 0 : ($linesCovered / $linesValid);
|
||||
|
||||
$functionsLinesValid += $linesValid;
|
||||
$functionsLinesValid += $linesValid;
|
||||
$functionsLinesCovered += $linesCovered;
|
||||
|
||||
$branchesValid = $function['executableBranches'];
|
||||
$branchesCovered = $function['executedBranches'];
|
||||
$branchRate = $branchesValid === 0 ? 0 : ($branchesCovered / $branchesValid);
|
||||
|
||||
$functionsBranchesValid += $branchesValid;
|
||||
$functionsBranchesValid += $branchesValid;
|
||||
$functionsBranchesCovered += $branchesValid;
|
||||
|
||||
$methodElement = $document->createElement('method');
|
||||
@@ -295,7 +295,7 @@ final class Cobertura
|
||||
$buffer = $document->saveXML();
|
||||
|
||||
if ($target !== null) {
|
||||
if (!strpos($target, '://') !== false) {
|
||||
if (!str_contains($target, '://')) {
|
||||
Filesystem::createDirectory(dirname($target));
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ use function file_put_contents;
|
||||
use function htmlspecialchars;
|
||||
use function is_string;
|
||||
use function round;
|
||||
use function strpos;
|
||||
use function str_contains;
|
||||
use DOMDocument;
|
||||
use SebastianBergmann\CodeCoverage\CodeCoverage;
|
||||
use SebastianBergmann\CodeCoverage\Driver\WriteOperationFailedException;
|
||||
@@ -73,7 +73,7 @@ final class Crap4j
|
||||
foreach ($class['methods'] as $methodName => $method) {
|
||||
$crapLoad = $this->crapLoad((float) $method['crap'], $method['ccn'], $method['coverage']);
|
||||
|
||||
$fullCrap += $method['crap'];
|
||||
$fullCrap += $method['crap'];
|
||||
$fullCrapLoad += $crapLoad;
|
||||
$fullMethodCount++;
|
||||
|
||||
@@ -122,7 +122,7 @@ final class Crap4j
|
||||
$buffer = $document->saveXML();
|
||||
|
||||
if ($target !== null) {
|
||||
if (!strpos($target, '://') !== false) {
|
||||
if (!str_contains($target, '://')) {
|
||||
Filesystem::createDirectory(dirname($target));
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ final class CustomCssFile
|
||||
{
|
||||
if (!is_file($path)) {
|
||||
throw new InvalidArgumentException(
|
||||
'$path does not exist'
|
||||
'$path does not exist',
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ final class Facade
|
||||
$this->generator,
|
||||
$date,
|
||||
$this->thresholds,
|
||||
$coverage->collectsBranchAndPathCoverage()
|
||||
$coverage->collectsBranchAndPathCoverage(),
|
||||
);
|
||||
|
||||
$directory = new Directory(
|
||||
@@ -58,7 +58,7 @@ final class Facade
|
||||
$this->generator,
|
||||
$date,
|
||||
$this->thresholds,
|
||||
$coverage->collectsBranchAndPathCoverage()
|
||||
$coverage->collectsBranchAndPathCoverage(),
|
||||
);
|
||||
|
||||
$file = new File(
|
||||
@@ -66,7 +66,7 @@ final class Facade
|
||||
$this->generator,
|
||||
$date,
|
||||
$this->thresholds,
|
||||
$coverage->collectsBranchAndPathCoverage()
|
||||
$coverage->collectsBranchAndPathCoverage(),
|
||||
);
|
||||
|
||||
$directory->render($report, $target . 'index.html');
|
||||
@@ -126,7 +126,7 @@ final class Facade
|
||||
'success-high' => $this->colors->successHigh(),
|
||||
'warning' => $this->colors->warning(),
|
||||
'danger' => $this->colors->danger(),
|
||||
]
|
||||
],
|
||||
);
|
||||
|
||||
try {
|
||||
@@ -135,7 +135,7 @@ final class Facade
|
||||
throw new FileCouldNotBeWrittenException(
|
||||
$e->getMessage(),
|
||||
$e->getCode(),
|
||||
$e
|
||||
$e,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ abstract class Renderer
|
||||
$data['numClasses'];
|
||||
|
||||
$classesBar = $this->coverageBar(
|
||||
$data['testedClassesPercent']
|
||||
$data['testedClassesPercent'],
|
||||
);
|
||||
} else {
|
||||
$classesLevel = '';
|
||||
@@ -71,7 +71,7 @@ abstract class Renderer
|
||||
$data['numMethods'];
|
||||
|
||||
$methodsBar = $this->coverageBar(
|
||||
$data['testedMethodsPercent']
|
||||
$data['testedMethodsPercent'],
|
||||
);
|
||||
} else {
|
||||
$methodsLevel = '';
|
||||
@@ -87,7 +87,7 @@ abstract class Renderer
|
||||
$data['numExecutableLines'];
|
||||
|
||||
$linesBar = $this->coverageBar(
|
||||
$data['linesExecutedPercent']
|
||||
$data['linesExecutedPercent'],
|
||||
);
|
||||
} else {
|
||||
$linesLevel = '';
|
||||
@@ -103,7 +103,7 @@ abstract class Renderer
|
||||
$data['numExecutablePaths'];
|
||||
|
||||
$pathsBar = $this->coverageBar(
|
||||
$data['pathsExecutedPercent']
|
||||
$data['pathsExecutedPercent'],
|
||||
);
|
||||
} else {
|
||||
$pathsLevel = '';
|
||||
@@ -119,7 +119,7 @@ abstract class Renderer
|
||||
$data['numExecutableBranches'];
|
||||
|
||||
$branchesBar = $this->coverageBar(
|
||||
$data['branchesExecutedPercent']
|
||||
$data['branchesExecutedPercent'],
|
||||
);
|
||||
} else {
|
||||
$branchesLevel = '';
|
||||
@@ -153,7 +153,7 @@ abstract class Renderer
|
||||
'classes_tested_percent' => $data['testedClassesPercentAsString'] ?? '',
|
||||
'classes_level' => $classesLevel,
|
||||
'classes_number' => $classesNumber,
|
||||
]
|
||||
],
|
||||
);
|
||||
|
||||
return $template->render();
|
||||
@@ -173,7 +173,7 @@ abstract class Renderer
|
||||
'generator' => $this->generator,
|
||||
'low_upper_bound' => $this->thresholds->lowUpperBound(),
|
||||
'high_lower_bound' => $this->thresholds->highLowerBound(),
|
||||
]
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ abstract class Renderer
|
||||
if ($step !== $node) {
|
||||
$breadcrumbs .= $this->inactiveBreadcrumb(
|
||||
$step,
|
||||
array_pop($pathToRoot)
|
||||
array_pop($pathToRoot),
|
||||
);
|
||||
} else {
|
||||
$breadcrumbs .= $this->activeBreadcrumb($step);
|
||||
@@ -210,7 +210,7 @@ abstract class Renderer
|
||||
{
|
||||
$buffer = sprintf(
|
||||
' <li class="breadcrumb-item active">%s</li>' . "\n",
|
||||
$node->name()
|
||||
$node->name(),
|
||||
);
|
||||
|
||||
if ($node instanceof DirectoryNode) {
|
||||
@@ -225,7 +225,7 @@ abstract class Renderer
|
||||
return sprintf(
|
||||
' <li class="breadcrumb-item"><a href="%sindex.html">%s</a></li>' . "\n",
|
||||
$pathToRoot,
|
||||
$node->name()
|
||||
$node->name(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -250,7 +250,7 @@ abstract class Renderer
|
||||
$template = new Template(
|
||||
$templateName,
|
||||
'{{',
|
||||
'}}'
|
||||
'}}',
|
||||
);
|
||||
|
||||
$template->setVar(['level' => $level, 'percent' => sprintf('%.2F', $percent)]);
|
||||
@@ -280,7 +280,7 @@ abstract class Renderer
|
||||
'<a href="%s" target="_top">%s %s</a>',
|
||||
$runtime->getVendorUrl(),
|
||||
$runtime->getName(),
|
||||
$runtime->getVersion()
|
||||
$runtime->getVersion(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ final class Dashboard extends Renderer
|
||||
$template = new Template(
|
||||
$templateName,
|
||||
'{{',
|
||||
'}}'
|
||||
'}}',
|
||||
);
|
||||
|
||||
$this->setCommonTemplateVariables($template, $node);
|
||||
@@ -57,7 +57,7 @@ final class Dashboard extends Renderer
|
||||
'complexity_method' => $complexity['method'],
|
||||
'class_coverage_distribution' => $coverageDistribution['class'],
|
||||
'method_coverage_distribution' => $coverageDistribution['method'],
|
||||
]
|
||||
],
|
||||
);
|
||||
|
||||
try {
|
||||
@@ -66,7 +66,7 @@ final class Dashboard extends Renderer
|
||||
throw new FileCouldNotBeWrittenException(
|
||||
$e->getMessage(),
|
||||
$e->getCode(),
|
||||
$e
|
||||
$e,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -76,7 +76,7 @@ final class Dashboard extends Renderer
|
||||
return sprintf(
|
||||
' <li class="breadcrumb-item"><a href="index.html">%s</a></li>' . "\n" .
|
||||
' <li class="breadcrumb-item active">(Dashboard)</li>' . "\n",
|
||||
$node->name()
|
||||
$node->name(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ final class Dashboard extends Renderer
|
||||
sprintf(
|
||||
'<a href="%s">%s</a>',
|
||||
str_replace($baseLink, '', $method['link']),
|
||||
$methodName
|
||||
$methodName,
|
||||
),
|
||||
];
|
||||
}
|
||||
@@ -110,7 +110,7 @@ final class Dashboard extends Renderer
|
||||
sprintf(
|
||||
'<a href="%s">%s</a>',
|
||||
str_replace($baseLink, '', $class['link']),
|
||||
$className
|
||||
$className,
|
||||
),
|
||||
];
|
||||
}
|
||||
@@ -222,7 +222,7 @@ final class Dashboard extends Renderer
|
||||
' <tr><td><a href="%s">%s</a></td><td class="text-right">%d%%</td></tr>' . "\n",
|
||||
str_replace($baseLink, '', $classes[$className]['link']),
|
||||
$className,
|
||||
$coverage
|
||||
$coverage,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -234,7 +234,7 @@ final class Dashboard extends Renderer
|
||||
str_replace($baseLink, '', $classes[$class]['methods'][$method]['link']),
|
||||
$methodName,
|
||||
$method,
|
||||
$coverage
|
||||
$coverage,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -277,7 +277,7 @@ final class Dashboard extends Renderer
|
||||
' <tr><td><a href="%s">%s</a></td><td class="text-right">%d</td></tr>' . "\n",
|
||||
str_replace($baseLink, '', $classes[$className]['link']),
|
||||
$className,
|
||||
$crap
|
||||
$crap,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -289,7 +289,7 @@ final class Dashboard extends Renderer
|
||||
str_replace($baseLink, '', $classes[$class]['methods'][$method]['link']),
|
||||
$methodName,
|
||||
$method,
|
||||
$crap
|
||||
$crap,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ final class Directory extends Renderer
|
||||
[
|
||||
'id' => $node->id(),
|
||||
'items' => $items,
|
||||
]
|
||||
],
|
||||
);
|
||||
|
||||
try {
|
||||
@@ -53,7 +53,7 @@ final class Directory extends Renderer
|
||||
throw new FileCouldNotBeWrittenException(
|
||||
$e->getMessage(),
|
||||
$e->getCode(),
|
||||
$e
|
||||
$e,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -93,7 +93,7 @@ final class Directory extends Renderer
|
||||
$data['name'] = sprintf(
|
||||
'<a href="%s/index.html">%s</a>',
|
||||
$node->name(),
|
||||
$node->name()
|
||||
$node->name(),
|
||||
);
|
||||
$data['icon'] = sprintf('<img src="%s_icons/file-directory.svg" class="octicon" />', $up);
|
||||
} elseif ($this->hasBranchCoverage) {
|
||||
@@ -102,13 +102,13 @@ final class Directory extends Renderer
|
||||
$node->name(),
|
||||
$node->name(),
|
||||
$node->name(),
|
||||
$node->name()
|
||||
$node->name(),
|
||||
);
|
||||
} else {
|
||||
$data['name'] = sprintf(
|
||||
'<a href="%s.html">%s</a>',
|
||||
$node->name(),
|
||||
$node->name()
|
||||
$node->name(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -117,7 +117,7 @@ final class Directory extends Renderer
|
||||
|
||||
return $this->renderItemTemplate(
|
||||
new Template($templateName, '{{', '}}'),
|
||||
$data
|
||||
$data,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ final class File extends Renderer
|
||||
'lines' => $this->renderSourceWithLineCoverage($node),
|
||||
'legend' => '<p><span class="legend covered-by-small-tests">Covered by small (and larger) tests</span><span class="legend covered-by-medium-tests">Covered by medium (and large) tests</span><span class="legend covered-by-large-tests">Covered by large tests (and tests of unknown size)</span><span class="legend not-covered">Not covered</span><span class="legend not-coverable">Not coverable</span></p>',
|
||||
'structure' => '',
|
||||
]
|
||||
],
|
||||
);
|
||||
|
||||
try {
|
||||
@@ -205,7 +205,7 @@ final class File extends Renderer
|
||||
throw new FileCouldNotBeWrittenException(
|
||||
$e->getMessage(),
|
||||
$e->getCode(),
|
||||
$e
|
||||
$e,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -216,7 +216,7 @@ final class File extends Renderer
|
||||
'lines' => $this->renderSourceWithBranchCoverage($node),
|
||||
'legend' => '<p><span class="success"><strong>Fully covered</strong></span><span class="warning"><strong>Partially covered</strong></span><span class="danger"><strong>Not covered</strong></span></p>',
|
||||
'structure' => $this->renderBranchStructure($node),
|
||||
]
|
||||
],
|
||||
);
|
||||
|
||||
try {
|
||||
@@ -225,7 +225,7 @@ final class File extends Renderer
|
||||
throw new FileCouldNotBeWrittenException(
|
||||
$e->getMessage(),
|
||||
$e->getCode(),
|
||||
$e
|
||||
$e,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ final class File extends Renderer
|
||||
'lines' => $this->renderSourceWithPathCoverage($node),
|
||||
'legend' => '<p><span class="success"><strong>Fully covered</strong></span><span class="warning"><strong>Partially covered</strong></span><span class="danger"><strong>Not covered</strong></span></p>',
|
||||
'structure' => $this->renderPathStructure($node),
|
||||
]
|
||||
],
|
||||
);
|
||||
|
||||
try {
|
||||
@@ -244,7 +244,7 @@ final class File extends Renderer
|
||||
throw new FileCouldNotBeWrittenException(
|
||||
$e->getMessage(),
|
||||
$e->getCode(),
|
||||
$e
|
||||
$e,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -259,7 +259,7 @@ final class File extends Renderer
|
||||
$methodItemTemplate = new Template(
|
||||
$methodTemplateName,
|
||||
'{{',
|
||||
'}}'
|
||||
'}}',
|
||||
);
|
||||
|
||||
$items = $this->renderItemTemplate(
|
||||
@@ -287,24 +287,24 @@ final class File extends Renderer
|
||||
'testedClassesPercent' => $node->percentageOfTestedClassesAndTraits()->asFloat(),
|
||||
'testedClassesPercentAsString' => $node->percentageOfTestedClassesAndTraits()->asString(),
|
||||
'crap' => '<abbr title="Change Risk Anti-Patterns (CRAP) Index">CRAP</abbr>',
|
||||
]
|
||||
],
|
||||
);
|
||||
|
||||
$items .= $this->renderFunctionItems(
|
||||
$node->functions(),
|
||||
$methodItemTemplate
|
||||
$methodItemTemplate,
|
||||
);
|
||||
|
||||
$items .= $this->renderTraitOrClassItems(
|
||||
$node->traits(),
|
||||
$template,
|
||||
$methodItemTemplate
|
||||
$methodItemTemplate,
|
||||
);
|
||||
|
||||
$items .= $this->renderTraitOrClassItems(
|
||||
$node->classes(),
|
||||
$template,
|
||||
$methodItemTemplate
|
||||
$methodItemTemplate,
|
||||
);
|
||||
|
||||
return $items;
|
||||
@@ -337,15 +337,15 @@ final class File extends Renderer
|
||||
$numTestedClasses = $numTestedMethods === $numMethods ? 1 : 0;
|
||||
$linesExecutedPercentAsString = Percentage::fromFractionAndTotal(
|
||||
$item['executedLines'],
|
||||
$item['executableLines']
|
||||
$item['executableLines'],
|
||||
)->asString();
|
||||
$branchesExecutedPercentAsString = Percentage::fromFractionAndTotal(
|
||||
$item['executedBranches'],
|
||||
$item['executableBranches']
|
||||
$item['executableBranches'],
|
||||
)->asString();
|
||||
$pathsExecutedPercentAsString = Percentage::fromFractionAndTotal(
|
||||
$item['executedPaths'],
|
||||
$item['executablePaths']
|
||||
$item['executablePaths'],
|
||||
)->asString();
|
||||
} else {
|
||||
$numClasses = 0;
|
||||
@@ -357,12 +357,12 @@ final class File extends Renderer
|
||||
|
||||
$testedMethodsPercentage = Percentage::fromFractionAndTotal(
|
||||
$numTestedMethods,
|
||||
$numMethods
|
||||
$numMethods,
|
||||
);
|
||||
|
||||
$testedClassesPercentage = Percentage::fromFractionAndTotal(
|
||||
$numTestedMethods === $numMethods ? 1 : 0,
|
||||
1
|
||||
1,
|
||||
);
|
||||
|
||||
$buffer .= $this->renderItemTemplate(
|
||||
@@ -389,7 +389,7 @@ final class File extends Renderer
|
||||
'numExecutableBranches' => $item['executableBranches'],
|
||||
'pathsExecutedPercent' => Percentage::fromFractionAndTotal(
|
||||
$item['executedPaths'],
|
||||
$item['executablePaths']
|
||||
$item['executablePaths'],
|
||||
)->asFloat(),
|
||||
'pathsExecutedPercentAsString' => $pathsExecutedPercentAsString,
|
||||
'numExecutedPaths' => $item['executedPaths'],
|
||||
@@ -399,14 +399,14 @@ final class File extends Renderer
|
||||
'testedClassesPercent' => $testedClassesPercentage->asFloat(),
|
||||
'testedClassesPercentAsString' => $testedClassesPercentage->asString(),
|
||||
'crap' => $item['crap'],
|
||||
]
|
||||
],
|
||||
);
|
||||
|
||||
foreach ($item['methods'] as $method) {
|
||||
$buffer .= $this->renderFunctionOrMethodItem(
|
||||
$methodItemTemplate,
|
||||
$method,
|
||||
' '
|
||||
' ',
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -425,7 +425,7 @@ final class File extends Renderer
|
||||
foreach ($functions as $function) {
|
||||
$buffer .= $this->renderFunctionOrMethodItem(
|
||||
$template,
|
||||
$function
|
||||
$function,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -447,22 +447,22 @@ final class File extends Renderer
|
||||
|
||||
$executedLinesPercentage = Percentage::fromFractionAndTotal(
|
||||
$item['executedLines'],
|
||||
$item['executableLines']
|
||||
$item['executableLines'],
|
||||
);
|
||||
|
||||
$executedBranchesPercentage = Percentage::fromFractionAndTotal(
|
||||
$item['executedBranches'],
|
||||
$item['executableBranches']
|
||||
$item['executableBranches'],
|
||||
);
|
||||
|
||||
$executedPathsPercentage = Percentage::fromFractionAndTotal(
|
||||
$item['executedPaths'],
|
||||
$item['executablePaths']
|
||||
$item['executablePaths'],
|
||||
);
|
||||
|
||||
$testedMethodsPercentage = Percentage::fromFractionAndTotal(
|
||||
$numTestedMethods,
|
||||
1
|
||||
1,
|
||||
);
|
||||
|
||||
return $this->renderItemTemplate(
|
||||
@@ -473,7 +473,7 @@ final class File extends Renderer
|
||||
$indent,
|
||||
$item['startLine'],
|
||||
htmlspecialchars($item['signature'], $this->htmlSpecialCharsFlags),
|
||||
$item['functionName'] ?? $item['methodName']
|
||||
$item['functionName'] ?? $item['methodName'],
|
||||
),
|
||||
'numMethods' => $numMethods,
|
||||
'numTestedMethods' => $numTestedMethods,
|
||||
@@ -492,7 +492,7 @@ final class File extends Renderer
|
||||
'testedMethodsPercent' => $testedMethodsPercentage->asFloat(),
|
||||
'testedMethodsPercentAsString' => $testedMethodsPercentage->asString(),
|
||||
'crap' => $item['crap'],
|
||||
]
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -550,7 +550,7 @@ final class File extends Renderer
|
||||
$popover = sprintf(
|
||||
' data-title="%s" data-content="%s" data-placement="top" data-html="true"',
|
||||
$popoverTitle,
|
||||
htmlspecialchars($popoverContent, $this->htmlSpecialCharsFlags)
|
||||
htmlspecialchars($popoverContent, $this->htmlSpecialCharsFlags),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -637,7 +637,7 @@ final class File extends Renderer
|
||||
$popover = sprintf(
|
||||
' data-title="%s" data-content="%s" data-placement="top" data-html="true"',
|
||||
$popoverTitle,
|
||||
htmlspecialchars($popoverContent, $this->htmlSpecialCharsFlags)
|
||||
htmlspecialchars($popoverContent, $this->htmlSpecialCharsFlags),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -727,7 +727,7 @@ final class File extends Renderer
|
||||
$popover = sprintf(
|
||||
' data-title="%s" data-content="%s" data-placement="top" data-html="true"',
|
||||
$popoverTitle,
|
||||
htmlspecialchars($popoverContent, $this->htmlSpecialCharsFlags)
|
||||
htmlspecialchars($popoverContent, $this->htmlSpecialCharsFlags),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -825,7 +825,7 @@ final class File extends Renderer
|
||||
$popover = sprintf(
|
||||
' data-title="%s" data-content="%s" data-placement="top" data-html="true"',
|
||||
$popoverTitle,
|
||||
htmlspecialchars($popoverContent, $this->htmlSpecialCharsFlags)
|
||||
htmlspecialchars($popoverContent, $this->htmlSpecialCharsFlags),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -940,7 +940,7 @@ final class File extends Renderer
|
||||
$popover = sprintf(
|
||||
' data-title="%s" data-content="%s" data-placement="top" data-html="true"',
|
||||
$popoverTitle,
|
||||
htmlspecialchars($popoverContent, $this->htmlSpecialCharsFlags)
|
||||
htmlspecialchars($popoverContent, $this->htmlSpecialCharsFlags),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -965,7 +965,7 @@ final class File extends Renderer
|
||||
'lineContent' => $lineContent,
|
||||
'class' => $class,
|
||||
'popover' => $popover,
|
||||
]
|
||||
],
|
||||
);
|
||||
|
||||
return $template->render();
|
||||
@@ -991,14 +991,14 @@ final class File extends Renderer
|
||||
if ($token === '"' && $tokens[$j - 1] !== '\\') {
|
||||
$result[$i] .= sprintf(
|
||||
'<span class="string">%s</span>',
|
||||
htmlspecialchars($token, $this->htmlSpecialCharsFlags)
|
||||
htmlspecialchars($token, $this->htmlSpecialCharsFlags),
|
||||
);
|
||||
|
||||
$stringFlag = !$stringFlag;
|
||||
} else {
|
||||
$result[$i] .= sprintf(
|
||||
'<span class="keyword">%s</span>',
|
||||
htmlspecialchars($token, $this->htmlSpecialCharsFlags)
|
||||
htmlspecialchars($token, $this->htmlSpecialCharsFlags),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1010,7 +1010,7 @@ final class File extends Renderer
|
||||
$value = str_replace(
|
||||
["\t", ' '],
|
||||
[' ', ' '],
|
||||
htmlspecialchars($value, $this->htmlSpecialCharsFlags)
|
||||
htmlspecialchars($value, $this->htmlSpecialCharsFlags),
|
||||
);
|
||||
|
||||
if ($value === "\n") {
|
||||
@@ -1039,7 +1039,7 @@ final class File extends Renderer
|
||||
$result[$i] .= sprintf(
|
||||
'<span class="%s">%s</span>',
|
||||
$colour,
|
||||
$line
|
||||
$line,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1067,7 +1067,7 @@ final class File extends Renderer
|
||||
$className = sprintf(
|
||||
'<abbr title="%s">%s</abbr>',
|
||||
$className,
|
||||
array_pop($tmp)
|
||||
array_pop($tmp),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1109,7 +1109,7 @@ final class File extends Renderer
|
||||
return sprintf(
|
||||
'<li%s>%s</li>',
|
||||
$testCSS,
|
||||
htmlspecialchars($test, $this->htmlSpecialCharsFlags)
|
||||
htmlspecialchars($test, $this->htmlSpecialCharsFlags),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace SebastianBergmann\CodeCoverage\Report;
|
||||
use function dirname;
|
||||
use function file_put_contents;
|
||||
use function serialize;
|
||||
use function strpos;
|
||||
use function str_contains;
|
||||
use SebastianBergmann\CodeCoverage\CodeCoverage;
|
||||
use SebastianBergmann\CodeCoverage\Driver\WriteOperationFailedException;
|
||||
use SebastianBergmann\CodeCoverage\Util\Filesystem;
|
||||
@@ -27,7 +27,7 @@ final class PHP
|
||||
return \unserialize(<<<'END_OF_COVERAGE_SERIALIZATION'" . PHP_EOL . serialize($coverage) . PHP_EOL . 'END_OF_COVERAGE_SERIALIZATION' . PHP_EOL . ');';
|
||||
|
||||
if ($target !== null) {
|
||||
if (!strpos($target, '://') !== false) {
|
||||
if (!str_contains($target, '://')) {
|
||||
Filesystem::createDirectory(dirname($target));
|
||||
}
|
||||
|
||||
|
||||
@@ -78,27 +78,27 @@ final class Text
|
||||
if ($showColors) {
|
||||
$colors['classes'] = $this->coverageColor(
|
||||
$report->numberOfTestedClassesAndTraits(),
|
||||
$report->numberOfClassesAndTraits()
|
||||
$report->numberOfClassesAndTraits(),
|
||||
);
|
||||
|
||||
$colors['methods'] = $this->coverageColor(
|
||||
$report->numberOfTestedMethods(),
|
||||
$report->numberOfMethods()
|
||||
$report->numberOfMethods(),
|
||||
);
|
||||
|
||||
$colors['lines'] = $this->coverageColor(
|
||||
$report->numberOfExecutedLines(),
|
||||
$report->numberOfExecutableLines()
|
||||
$report->numberOfExecutableLines(),
|
||||
);
|
||||
|
||||
$colors['branches'] = $this->coverageColor(
|
||||
$report->numberOfExecutedBranches(),
|
||||
$report->numberOfExecutableBranches()
|
||||
$report->numberOfExecutableBranches(),
|
||||
);
|
||||
|
||||
$colors['paths'] = $this->coverageColor(
|
||||
$report->numberOfExecutedPaths(),
|
||||
$report->numberOfExecutablePaths()
|
||||
$report->numberOfExecutablePaths(),
|
||||
);
|
||||
|
||||
$colors['reset'] = self::COLOR_RESET;
|
||||
@@ -109,10 +109,10 @@ final class Text
|
||||
' Classes: %6s (%d/%d)',
|
||||
Percentage::fromFractionAndTotal(
|
||||
$report->numberOfTestedClassesAndTraits(),
|
||||
$report->numberOfClassesAndTraits()
|
||||
$report->numberOfClassesAndTraits(),
|
||||
)->asString(),
|
||||
$report->numberOfTestedClassesAndTraits(),
|
||||
$report->numberOfClassesAndTraits()
|
||||
$report->numberOfClassesAndTraits(),
|
||||
);
|
||||
|
||||
$methods = sprintf(
|
||||
@@ -122,7 +122,7 @@ final class Text
|
||||
$report->numberOfMethods(),
|
||||
)->asString(),
|
||||
$report->numberOfTestedMethods(),
|
||||
$report->numberOfMethods()
|
||||
$report->numberOfMethods(),
|
||||
);
|
||||
|
||||
$paths = '';
|
||||
@@ -136,7 +136,7 @@ final class Text
|
||||
$report->numberOfExecutablePaths(),
|
||||
)->asString(),
|
||||
$report->numberOfExecutedPaths(),
|
||||
$report->numberOfExecutablePaths()
|
||||
$report->numberOfExecutablePaths(),
|
||||
);
|
||||
|
||||
$branches = sprintf(
|
||||
@@ -146,7 +146,7 @@ final class Text
|
||||
$report->numberOfExecutableBranches(),
|
||||
)->asString(),
|
||||
$report->numberOfExecutedBranches(),
|
||||
$report->numberOfExecutableBranches()
|
||||
$report->numberOfExecutableBranches(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ final class Text
|
||||
$report->numberOfExecutableLines(),
|
||||
)->asString(),
|
||||
$report->numberOfExecutedLines(),
|
||||
$report->numberOfExecutableLines()
|
||||
$report->numberOfExecutableLines(),
|
||||
);
|
||||
|
||||
$padding = max(array_map('strlen', [$classes, $methods, $lines]));
|
||||
@@ -215,12 +215,12 @@ final class Text
|
||||
}
|
||||
|
||||
$classMethods++;
|
||||
$classExecutableLines += $method['executableLines'];
|
||||
$classExecutedLines += $method['executedLines'];
|
||||
$classExecutableLines += $method['executableLines'];
|
||||
$classExecutedLines += $method['executedLines'];
|
||||
$classExecutableBranches += $method['executableBranches'];
|
||||
$classExecutedBranches += $method['executedBranches'];
|
||||
$classExecutablePaths += $method['executablePaths'];
|
||||
$classExecutedPaths += $method['executedPaths'];
|
||||
$classExecutedBranches += $method['executedBranches'];
|
||||
$classExecutablePaths += $method['executablePaths'];
|
||||
$classExecutedPaths += $method['executedPaths'];
|
||||
|
||||
if ($method['coverage'] == 100) {
|
||||
$coveredMethods++;
|
||||
@@ -278,7 +278,7 @@ final class Text
|
||||
{
|
||||
$coverage = Percentage::fromFractionAndTotal(
|
||||
$numberOfCoveredElements,
|
||||
$totalNumberOfElements
|
||||
$totalNumberOfElements,
|
||||
);
|
||||
|
||||
if ($coverage->asFloat() >= $this->thresholds->highLowerBound()) {
|
||||
@@ -298,16 +298,18 @@ final class Text
|
||||
|
||||
return Percentage::fromFractionAndTotal(
|
||||
$numberOfCoveredElements,
|
||||
$totalNumberOfElements
|
||||
$totalNumberOfElements,
|
||||
)->asFixedWidthString() .
|
||||
' (' . sprintf($format, $numberOfCoveredElements) . '/' .
|
||||
sprintf($format, $totalNumberOfElements) . ')';
|
||||
}
|
||||
|
||||
private function format(string $color, int $padding, string|false $string): string
|
||||
private function format(string $color, int $padding, false|string $string): string
|
||||
{
|
||||
$reset = $color ? self::COLOR_RESET : '';
|
||||
if ($color === '') {
|
||||
return (string) $string . PHP_EOL;
|
||||
}
|
||||
|
||||
return $color . str_pad((string) $string, $padding) . $reset . PHP_EOL;
|
||||
return $color . str_pad((string) $string, $padding) . self::COLOR_RESET . PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ final class Thresholds
|
||||
{
|
||||
if ($lowUpperBound > $highLowerBound) {
|
||||
throw new InvalidArgumentException(
|
||||
'$lowUpperBound must not be larger than $highLowerBound'
|
||||
'$lowUpperBound must not be larger than $highLowerBound',
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -62,15 +62,15 @@ final class BuildInformation
|
||||
{
|
||||
$node = $this->contextNode->getElementsByTagNameNS(
|
||||
'https://schema.phpunit.de/coverage/1.0',
|
||||
$name
|
||||
$name,
|
||||
)->item(0);
|
||||
|
||||
if (!$node) {
|
||||
$node = $this->contextNode->appendChild(
|
||||
$this->contextNode->ownerDocument->createElementNS(
|
||||
'https://schema.phpunit.de/coverage/1.0',
|
||||
$name
|
||||
)
|
||||
$name,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ final class Coverage
|
||||
|
||||
$this->contextNode->parentNode->replaceChild(
|
||||
$fragment,
|
||||
$this->contextNode
|
||||
$this->contextNode,
|
||||
);
|
||||
|
||||
$this->finalized = true;
|
||||
|
||||
@@ -64,7 +64,7 @@ final class Facade
|
||||
$report = $coverage->getReport();
|
||||
|
||||
$this->project = new Project(
|
||||
$coverage->getReport()->name()
|
||||
$coverage->getReport()->name(),
|
||||
);
|
||||
|
||||
$this->setBuildInformation();
|
||||
@@ -132,14 +132,14 @@ final class Facade
|
||||
{
|
||||
$fileObject = $context->addFile(
|
||||
$file->name(),
|
||||
$file->id() . '.xml'
|
||||
$file->id() . '.xml',
|
||||
);
|
||||
|
||||
$this->setTotals($file, $fileObject->totals());
|
||||
|
||||
$path = substr(
|
||||
$file->pathAsString(),
|
||||
strlen($this->project->projectSourceDirectory())
|
||||
strlen($this->project->projectSourceDirectory()),
|
||||
);
|
||||
|
||||
$fileReport = new Report($path);
|
||||
@@ -169,7 +169,7 @@ final class Facade
|
||||
}
|
||||
|
||||
$fileReport->source()->setSourceCode(
|
||||
file_get_contents($file->pathAsString())
|
||||
file_get_contents($file->pathAsString()),
|
||||
);
|
||||
|
||||
$this->saveDocument($fileReport->asDom(), $file->id());
|
||||
@@ -186,7 +186,7 @@ final class Facade
|
||||
$unitObject->setLines(
|
||||
$unit['startLine'],
|
||||
$unit['executableLines'],
|
||||
$unit['executedLines']
|
||||
$unit['executedLines'],
|
||||
);
|
||||
|
||||
$unitObject->setCrap((float) $unit['crap']);
|
||||
@@ -200,7 +200,7 @@ final class Facade
|
||||
$methodObject->setTotals(
|
||||
(string) $method['executableLines'],
|
||||
(string) $method['executedLines'],
|
||||
(string) $method['coverage']
|
||||
(string) $method['coverage'],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -233,27 +233,27 @@ final class Facade
|
||||
$loc['commentLinesOfCode'],
|
||||
$loc['nonCommentLinesOfCode'],
|
||||
$node->numberOfExecutableLines(),
|
||||
$node->numberOfExecutedLines()
|
||||
$node->numberOfExecutedLines(),
|
||||
);
|
||||
|
||||
$totals->setNumClasses(
|
||||
$node->numberOfClasses(),
|
||||
$node->numberOfTestedClasses()
|
||||
$node->numberOfTestedClasses(),
|
||||
);
|
||||
|
||||
$totals->setNumTraits(
|
||||
$node->numberOfTraits(),
|
||||
$node->numberOfTestedTraits()
|
||||
$node->numberOfTestedTraits(),
|
||||
);
|
||||
|
||||
$totals->setNumMethods(
|
||||
$node->numberOfMethods(),
|
||||
$node->numberOfTestedMethods()
|
||||
$node->numberOfTestedMethods(),
|
||||
);
|
||||
|
||||
$totals->setNumFunctions(
|
||||
$node->numberOfFunctions(),
|
||||
$node->numberOfTestedFunctions()
|
||||
$node->numberOfTestedFunctions(),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,8 +34,8 @@ class File
|
||||
$totalsContainer = $this->contextNode->appendChild(
|
||||
$this->dom->createElementNS(
|
||||
'https://schema.phpunit.de/coverage/1.0',
|
||||
'totals'
|
||||
)
|
||||
'totals',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -46,23 +46,23 @@ class File
|
||||
{
|
||||
$coverage = $this->contextNode->getElementsByTagNameNS(
|
||||
'https://schema.phpunit.de/coverage/1.0',
|
||||
'coverage'
|
||||
'coverage',
|
||||
)->item(0);
|
||||
|
||||
if (!$coverage) {
|
||||
$coverage = $this->contextNode->appendChild(
|
||||
$this->dom->createElementNS(
|
||||
'https://schema.phpunit.de/coverage/1.0',
|
||||
'coverage'
|
||||
)
|
||||
'coverage',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
$lineNode = $coverage->appendChild(
|
||||
$this->dom->createElementNS(
|
||||
'https://schema.phpunit.de/coverage/1.0',
|
||||
'line'
|
||||
)
|
||||
'line',
|
||||
),
|
||||
);
|
||||
|
||||
return new Coverage($lineNode, $line);
|
||||
|
||||
@@ -38,8 +38,8 @@ abstract class Node
|
||||
$totalsContainer = $this->contextNode()->appendChild(
|
||||
$this->dom->createElementNS(
|
||||
'https://schema.phpunit.de/coverage/1.0',
|
||||
'totals'
|
||||
)
|
||||
'totals',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ abstract class Node
|
||||
{
|
||||
$dirNode = $this->dom()->createElementNS(
|
||||
'https://schema.phpunit.de/coverage/1.0',
|
||||
'directory'
|
||||
'directory',
|
||||
);
|
||||
|
||||
$dirNode->setAttribute('name', $name);
|
||||
@@ -63,7 +63,7 @@ abstract class Node
|
||||
{
|
||||
$fileNode = $this->dom()->createElementNS(
|
||||
'https://schema.phpunit.de/coverage/1.0',
|
||||
'file'
|
||||
'file',
|
||||
);
|
||||
|
||||
$fileNode->setAttribute('name', $name);
|
||||
|
||||
@@ -31,15 +31,15 @@ final class Project extends Node
|
||||
{
|
||||
$buildNode = $this->dom()->getElementsByTagNameNS(
|
||||
'https://schema.phpunit.de/coverage/1.0',
|
||||
'build'
|
||||
'build',
|
||||
)->item(0);
|
||||
|
||||
if (!$buildNode) {
|
||||
$buildNode = $this->dom()->documentElement->appendChild(
|
||||
$this->dom()->createElementNS(
|
||||
'https://schema.phpunit.de/coverage/1.0',
|
||||
'build'
|
||||
)
|
||||
'build',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -50,15 +50,15 @@ final class Project extends Node
|
||||
{
|
||||
$testsNode = $this->contextNode()->getElementsByTagNameNS(
|
||||
'https://schema.phpunit.de/coverage/1.0',
|
||||
'tests'
|
||||
'tests',
|
||||
)->item(0);
|
||||
|
||||
if (!$testsNode) {
|
||||
$testsNode = $this->contextNode()->appendChild(
|
||||
$this->dom()->createElementNS(
|
||||
'https://schema.phpunit.de/coverage/1.0',
|
||||
'tests'
|
||||
)
|
||||
'tests',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -78,8 +78,8 @@ final class Project extends Node
|
||||
$this->setContextNode(
|
||||
$dom->getElementsByTagNameNS(
|
||||
'https://schema.phpunit.de/coverage/1.0',
|
||||
'project'
|
||||
)->item(0)
|
||||
'project',
|
||||
)->item(0),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ final class Report extends File
|
||||
|
||||
$contextNode = $dom->getElementsByTagNameNS(
|
||||
'https://schema.phpunit.de/coverage/1.0',
|
||||
'file'
|
||||
'file',
|
||||
)->item(0);
|
||||
|
||||
parent::__construct($contextNode);
|
||||
@@ -43,8 +43,8 @@ final class Report extends File
|
||||
$node = $this->contextNode()->appendChild(
|
||||
$this->dom()->createElementNS(
|
||||
'https://schema.phpunit.de/coverage/1.0',
|
||||
'function'
|
||||
)
|
||||
'function',
|
||||
),
|
||||
);
|
||||
|
||||
return new Method($node, $name);
|
||||
@@ -64,15 +64,15 @@ final class Report extends File
|
||||
{
|
||||
$source = $this->contextNode()->getElementsByTagNameNS(
|
||||
'https://schema.phpunit.de/coverage/1.0',
|
||||
'source'
|
||||
'source',
|
||||
)->item(0);
|
||||
|
||||
if (!$source) {
|
||||
$source = $this->contextNode()->appendChild(
|
||||
$this->dom()->createElementNS(
|
||||
'https://schema.phpunit.de/coverage/1.0',
|
||||
'source'
|
||||
)
|
||||
'source',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -90,8 +90,8 @@ final class Report extends File
|
||||
$node = $this->contextNode()->appendChild(
|
||||
$this->dom()->createElementNS(
|
||||
'https://schema.phpunit.de/coverage/1.0',
|
||||
$tagName
|
||||
)
|
||||
$tagName,
|
||||
),
|
||||
);
|
||||
|
||||
return new Unit($node, $name);
|
||||
|
||||
@@ -35,7 +35,7 @@ final class Source
|
||||
|
||||
$context->parentNode->replaceChild(
|
||||
$context->ownerDocument->importNode($srcDom->documentElement, true),
|
||||
$context
|
||||
$context,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,8 +33,8 @@ final class Tests
|
||||
$node = $this->contextNode->appendChild(
|
||||
$this->contextNode->ownerDocument->createElementNS(
|
||||
'https://schema.phpunit.de/coverage/1.0',
|
||||
'test'
|
||||
)
|
||||
'test',
|
||||
),
|
||||
);
|
||||
|
||||
$node->setAttribute('name', $test);
|
||||
|
||||
@@ -33,27 +33,27 @@ final class Totals
|
||||
|
||||
$this->linesNode = $dom->createElementNS(
|
||||
'https://schema.phpunit.de/coverage/1.0',
|
||||
'lines'
|
||||
'lines',
|
||||
);
|
||||
|
||||
$this->methodsNode = $dom->createElementNS(
|
||||
'https://schema.phpunit.de/coverage/1.0',
|
||||
'methods'
|
||||
'methods',
|
||||
);
|
||||
|
||||
$this->functionsNode = $dom->createElementNS(
|
||||
'https://schema.phpunit.de/coverage/1.0',
|
||||
'functions'
|
||||
'functions',
|
||||
);
|
||||
|
||||
$this->classesNode = $dom->createElementNS(
|
||||
'https://schema.phpunit.de/coverage/1.0',
|
||||
'classes'
|
||||
'classes',
|
||||
);
|
||||
|
||||
$this->traitsNode = $dom->createElementNS(
|
||||
'https://schema.phpunit.de/coverage/1.0',
|
||||
'traits'
|
||||
'traits',
|
||||
);
|
||||
|
||||
$container->appendChild($this->linesNode);
|
||||
@@ -77,7 +77,7 @@ final class Totals
|
||||
$this->linesNode->setAttribute('executed', (string) $executed);
|
||||
$this->linesNode->setAttribute(
|
||||
'percent',
|
||||
$executable === 0 ? '0' : sprintf('%01.2F', Percentage::fromFractionAndTotal($executed, $executable)->asFloat())
|
||||
$executable === 0 ? '0' : sprintf('%01.2F', Percentage::fromFractionAndTotal($executed, $executable)->asFloat()),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ final class Totals
|
||||
$this->classesNode->setAttribute('tested', (string) $tested);
|
||||
$this->classesNode->setAttribute(
|
||||
'percent',
|
||||
$count === 0 ? '0' : sprintf('%01.2F', Percentage::fromFractionAndTotal($tested, $count)->asFloat())
|
||||
$count === 0 ? '0' : sprintf('%01.2F', Percentage::fromFractionAndTotal($tested, $count)->asFloat()),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ final class Totals
|
||||
$this->traitsNode->setAttribute('tested', (string) $tested);
|
||||
$this->traitsNode->setAttribute(
|
||||
'percent',
|
||||
$count === 0 ? '0' : sprintf('%01.2F', Percentage::fromFractionAndTotal($tested, $count)->asFloat())
|
||||
$count === 0 ? '0' : sprintf('%01.2F', Percentage::fromFractionAndTotal($tested, $count)->asFloat()),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ final class Totals
|
||||
$this->methodsNode->setAttribute('tested', (string) $tested);
|
||||
$this->methodsNode->setAttribute(
|
||||
'percent',
|
||||
$count === 0 ? '0' : sprintf('%01.2F', Percentage::fromFractionAndTotal($tested, $count)->asFloat())
|
||||
$count === 0 ? '0' : sprintf('%01.2F', Percentage::fromFractionAndTotal($tested, $count)->asFloat()),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ final class Totals
|
||||
$this->functionsNode->setAttribute('tested', (string) $tested);
|
||||
$this->functionsNode->setAttribute(
|
||||
'percent',
|
||||
$count === 0 ? '0' : sprintf('%01.2F', Percentage::fromFractionAndTotal($tested, $count)->asFloat())
|
||||
$count === 0 ? '0' : sprintf('%01.2F', Percentage::fromFractionAndTotal($tested, $count)->asFloat()),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,15 +41,15 @@ final class Unit
|
||||
{
|
||||
$node = $this->contextNode->getElementsByTagNameNS(
|
||||
'https://schema.phpunit.de/coverage/1.0',
|
||||
'namespace'
|
||||
'namespace',
|
||||
)->item(0);
|
||||
|
||||
if (!$node) {
|
||||
$node = $this->contextNode->appendChild(
|
||||
$this->contextNode->ownerDocument->createElementNS(
|
||||
'https://schema.phpunit.de/coverage/1.0',
|
||||
'namespace'
|
||||
)
|
||||
'namespace',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -61,8 +61,8 @@ final class Unit
|
||||
$node = $this->contextNode->appendChild(
|
||||
$this->contextNode->ownerDocument->createElementNS(
|
||||
'https://schema.phpunit.de/coverage/1.0',
|
||||
'method'
|
||||
)
|
||||
'method',
|
||||
),
|
||||
);
|
||||
|
||||
return new Method($node, $name);
|
||||
|
||||
@@ -19,7 +19,7 @@ final class CacheWarmer
|
||||
$cacheDirectory,
|
||||
new ParsingFileAnalyser(
|
||||
$useAnnotationsForIgnoringCode,
|
||||
$ignoreDeprecatedCode
|
||||
$ignoreDeprecatedCode,
|
||||
),
|
||||
$useAnnotationsForIgnoringCode,
|
||||
$ignoreDeprecatedCode,
|
||||
|
||||
@@ -132,7 +132,7 @@ final class CachingFileAnalyser implements FileAnalyser
|
||||
|
||||
return unserialize(
|
||||
file_get_contents($cacheFile),
|
||||
['allowed_classes' => false]
|
||||
['allowed_classes' => false],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ final class CachingFileAnalyser implements FileAnalyser
|
||||
{
|
||||
file_put_contents(
|
||||
$this->cacheFile($filename),
|
||||
serialize($data)
|
||||
serialize($data),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -155,8 +155,8 @@ final class CachingFileAnalyser implements FileAnalyser
|
||||
self::cacheVersion(),
|
||||
$this->useAnnotationsForIgnoringCode,
|
||||
$this->ignoreDeprecatedCode,
|
||||
]
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
return $this->directory . DIRECTORY_SEPARATOR . $cacheKey;
|
||||
|
||||
@@ -193,7 +193,7 @@ final class CodeUnitFindingVisitor extends NodeVisitorAbstract
|
||||
return $signature;
|
||||
}
|
||||
|
||||
private function type(Identifier|Name|ComplexType $type): string
|
||||
private function type(ComplexType|Identifier|Name $type): string
|
||||
{
|
||||
if ($type instanceof NullableType) {
|
||||
return '?' . $type->type;
|
||||
|
||||
@@ -105,7 +105,6 @@ final class ExecutableLinesFindingVisitor extends NodeVisitorAbstract
|
||||
$node instanceof Node\Stmt\Use_ ||
|
||||
$node instanceof Node\Stmt\UseUse ||
|
||||
$node instanceof Node\Expr\ConstFetch ||
|
||||
$node instanceof Node\Expr\Match_ ||
|
||||
$node instanceof Node\Expr\Variable ||
|
||||
$node instanceof Node\Expr\Throw_ ||
|
||||
$node instanceof Node\ComplexType ||
|
||||
@@ -117,6 +116,18 @@ final class ExecutableLinesFindingVisitor extends NodeVisitorAbstract
|
||||
return;
|
||||
}
|
||||
|
||||
if ($node instanceof Node\Expr\Match_) {
|
||||
foreach ($node->arms as $arm) {
|
||||
$this->setLineBranch(
|
||||
$arm->body->getStartLine(),
|
||||
$arm->body->getEndLine(),
|
||||
++$this->nextBranch,
|
||||
);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* nikic/php-parser ^4.18 represents <code>throw</code> statements
|
||||
* as <code>Stmt\Throw_</code> objects
|
||||
@@ -206,7 +217,7 @@ final class ExecutableLinesFindingVisitor extends NodeVisitorAbstract
|
||||
if ($node instanceof Node\Expr\ArrowFunction) {
|
||||
$startLine = max(
|
||||
$node->getStartLine() + 1,
|
||||
$node->expr->getStartLine()
|
||||
$node->expr->getStartLine(),
|
||||
);
|
||||
|
||||
$endLine = $node->expr->getEndLine();
|
||||
@@ -251,7 +262,7 @@ final class ExecutableLinesFindingVisitor extends NodeVisitorAbstract
|
||||
$this->setLineBranch(
|
||||
$node->cond->getStartLine(),
|
||||
$node->cond->getStartLine(),
|
||||
++$this->nextBranch
|
||||
++$this->nextBranch,
|
||||
);
|
||||
|
||||
return;
|
||||
@@ -302,7 +313,7 @@ final class ExecutableLinesFindingVisitor extends NodeVisitorAbstract
|
||||
$this->setLineBranch(
|
||||
$startLine,
|
||||
$endLine,
|
||||
++$this->nextBranch
|
||||
++$this->nextBranch,
|
||||
);
|
||||
|
||||
return;
|
||||
@@ -312,7 +323,7 @@ final class ExecutableLinesFindingVisitor extends NodeVisitorAbstract
|
||||
$this->setLineBranch(
|
||||
$node->expr->getStartLine(),
|
||||
$node->valueVar->getEndLine(),
|
||||
++$this->nextBranch
|
||||
++$this->nextBranch,
|
||||
);
|
||||
|
||||
return;
|
||||
@@ -323,7 +334,7 @@ final class ExecutableLinesFindingVisitor extends NodeVisitorAbstract
|
||||
$this->setLineBranch(
|
||||
$node->cond->getStartLine(),
|
||||
$node->cond->getEndLine(),
|
||||
++$this->nextBranch
|
||||
++$this->nextBranch,
|
||||
);
|
||||
|
||||
return;
|
||||
@@ -338,7 +349,7 @@ final class ExecutableLinesFindingVisitor extends NodeVisitorAbstract
|
||||
$this->setLineBranch(
|
||||
$startLine,
|
||||
$endLine,
|
||||
++$this->nextBranch
|
||||
++$this->nextBranch,
|
||||
);
|
||||
|
||||
return;
|
||||
@@ -381,7 +392,7 @@ final class ExecutableLinesFindingVisitor extends NodeVisitorAbstract
|
||||
|
||||
$this->executableLinesGroupedByBranch = array_diff_key(
|
||||
$this->executableLinesGroupedByBranch,
|
||||
$this->unsets
|
||||
$this->unsets,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ use PhpParser\Node;
|
||||
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_;
|
||||
@@ -43,6 +44,7 @@ final class IgnoredLinesFindingVisitor extends NodeVisitorAbstract
|
||||
if (!$node instanceof Class_ &&
|
||||
!$node instanceof Trait_ &&
|
||||
!$node instanceof Interface_ &&
|
||||
!$node instanceof Enum_ &&
|
||||
!$node instanceof ClassMethod &&
|
||||
!$node instanceof Function_ &&
|
||||
!$node instanceof Attribute) {
|
||||
|
||||
@@ -167,10 +167,10 @@ final class ParsingFileAnalyser implements FileAnalyser
|
||||
sprintf(
|
||||
'Cannot parse %s: %s',
|
||||
$filename,
|
||||
$error->getMessage()
|
||||
$error->getMessage(),
|
||||
),
|
||||
$error->getCode(),
|
||||
$error
|
||||
$error,
|
||||
);
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
@@ -186,8 +186,8 @@ final class ParsingFileAnalyser implements FileAnalyser
|
||||
$this->ignoredLines[$filename] = array_unique(
|
||||
array_merge(
|
||||
$this->ignoredLines[$filename],
|
||||
$ignoredLinesFindingVisitor->ignoredLines()
|
||||
)
|
||||
$ignoredLinesFindingVisitor->ignoredLines(),
|
||||
),
|
||||
);
|
||||
|
||||
sort($this->ignoredLines[$filename]);
|
||||
@@ -239,7 +239,7 @@ final class ParsingFileAnalyser implements FileAnalyser
|
||||
|
||||
$this->ignoredLines[$filename] = array_merge(
|
||||
$this->ignoredLines[$filename],
|
||||
range($start, $token[2])
|
||||
range($start, $token[2]),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,14 +23,14 @@ final class Filesystem
|
||||
*/
|
||||
public static function createDirectory(string $directory): void
|
||||
{
|
||||
$success = !(!is_dir($directory) && !@mkdir($directory, 0777, true) && !is_dir($directory));
|
||||
$success = !(!is_dir($directory) && !@mkdir($directory, 0o777, true) && !is_dir($directory));
|
||||
|
||||
if (!$success) {
|
||||
throw new DirectoryCouldNotBeCreatedException(
|
||||
sprintf(
|
||||
'Directory "%s" could not be created',
|
||||
$directory
|
||||
)
|
||||
$directory,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ final class Version
|
||||
public static function id(): string
|
||||
{
|
||||
if (self::$version === '') {
|
||||
self::$version = (new VersionId('10.1.11', dirname(__DIR__)))->asString();
|
||||
self::$version = (new VersionId('10.1.16', dirname(__DIR__)))->asString();
|
||||
}
|
||||
|
||||
return self::$version;
|
||||
|
||||
Reference in New Issue
Block a user