mirror of
https://github.com/Dannecron/coverage-merger.git
synced 2025-12-25 15:52:34 +03:00
internal: fix phpstan errors
This commit is contained in:
@@ -14,6 +14,9 @@ class ClassDto
|
|||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
public function getProperties(): array
|
public function getProperties(): array
|
||||||
{
|
{
|
||||||
return $this->properties;
|
return $this->properties;
|
||||||
|
|||||||
@@ -22,6 +22,9 @@ class LineDto
|
|||||||
return $this->count;
|
return $this->count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
public function getProperties(): array
|
public function getProperties(): array
|
||||||
{
|
{
|
||||||
return $this->properties;
|
return $this->properties;
|
||||||
|
|||||||
@@ -57,6 +57,10 @@ class Parser implements ElementsDictionary
|
|||||||
return new LineDto($properties, (int) $count);
|
return new LineDto($properties, (int) $count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \SimpleXMLElement $xml
|
||||||
|
* @return array<array-key, \SimpleXMLElement>
|
||||||
|
*/
|
||||||
public function getAttributes(\SimpleXMLElement $xml): array
|
public function getAttributes(\SimpleXMLElement $xml): array
|
||||||
{
|
{
|
||||||
return ((array) $xml->attributes())['@attributes'] ?? [];
|
return ((array) $xml->attributes())['@attributes'] ?? [];
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class Renderer
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param Accumulator $accumulator
|
* @param Accumulator $accumulator
|
||||||
* @return array
|
* @return array{0: string, 1: Metrics}
|
||||||
* @throws \DOMException
|
* @throws \DOMException
|
||||||
*/
|
*/
|
||||||
public function renderAccumulator(Accumulator $accumulator): array
|
public function renderAccumulator(Accumulator $accumulator): array
|
||||||
@@ -71,7 +71,7 @@ class Renderer
|
|||||||
|
|
||||||
$xmlProject->appendChild($this->renderMetricsProject($xmlDocument, $projectMetrics));
|
$xmlProject->appendChild($this->renderMetricsProject($xmlDocument, $projectMetrics));
|
||||||
|
|
||||||
return [$xmlDocument->saveXML(), $projectMetrics];
|
return [(string) $xmlDocument->saveXML(), $projectMetrics];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -56,6 +56,11 @@ final class CloverMergeCommand extends CliCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param array<array-key, string> $files
|
||||||
|
* @param string $output
|
||||||
|
* @param string|null $workdir
|
||||||
|
* @param bool $stats
|
||||||
|
* @return int
|
||||||
* @throws ExecuteException
|
* @throws ExecuteException
|
||||||
*/
|
*/
|
||||||
public function execute(array $files, string $output, ?string $workdir, bool $stats): int
|
public function execute(array $files, string $output, ?string $workdir, bool $stats): int
|
||||||
|
|||||||
@@ -10,11 +10,11 @@ use Dannecron\CoverageMerger\Clover\Parser;
|
|||||||
\test('examples without files', function (string $exampleFilename): void {
|
\test('examples without files', function (string $exampleFilename): void {
|
||||||
$handler = new Handler(new Parser());
|
$handler = new Handler(new Parser());
|
||||||
|
|
||||||
$cloverContents = \file_get_contents(\getExamplePath($exampleFilename));
|
$cloverContents = (string) \file_get_contents(\getExamplePath($exampleFilename));
|
||||||
|
/** @var \SimpleXMLElement $xml */
|
||||||
|
$xml = \simplexml_load_string($cloverContents);
|
||||||
|
|
||||||
$accumulator = $handler->handleSingleDocument(
|
$accumulator = $handler->handleSingleDocument($xml);
|
||||||
\simplexml_load_string($cloverContents),
|
|
||||||
);
|
|
||||||
|
|
||||||
$files = $accumulator->getFiles();
|
$files = $accumulator->getFiles();
|
||||||
\expect($files)->toHaveCount(0);
|
\expect($files)->toHaveCount(0);
|
||||||
@@ -34,11 +34,11 @@ use Dannecron\CoverageMerger\Clover\Parser;
|
|||||||
): void {
|
): void {
|
||||||
$handler = new Handler(new Parser());
|
$handler = new Handler(new Parser());
|
||||||
|
|
||||||
$cloverContents = \file_get_contents(\getExamplePath($exampleFilename));
|
$cloverContents = (string) \file_get_contents(\getExamplePath($exampleFilename));
|
||||||
|
/** @var \SimpleXMLElement $xml */
|
||||||
|
$xml = \simplexml_load_string($cloverContents);
|
||||||
|
|
||||||
$accumulator = $handler->handleSingleDocument(
|
$accumulator = $handler->handleSingleDocument($xml);
|
||||||
\simplexml_load_string($cloverContents),
|
|
||||||
);
|
|
||||||
|
|
||||||
$files = $accumulator->getFiles();
|
$files = $accumulator->getFiles();
|
||||||
\expect($files)->toHaveCount(1)->toHaveKey($expectedFilename);
|
\expect($files)->toHaveCount(1)->toHaveKey($expectedFilename);
|
||||||
@@ -62,11 +62,11 @@ use Dannecron\CoverageMerger\Clover\Parser;
|
|||||||
): void {
|
): void {
|
||||||
$handler = new Handler(new Parser());
|
$handler = new Handler(new Parser());
|
||||||
|
|
||||||
$cloverContents = \file_get_contents(\getExamplePath($exampleFilename));
|
$cloverContents = (string) \file_get_contents(\getExamplePath($exampleFilename));
|
||||||
|
/** @var \SimpleXMLElement $xml */
|
||||||
|
$xml = \simplexml_load_string($cloverContents);
|
||||||
|
|
||||||
$accumulator = $handler->handleSingleDocument(
|
$accumulator = $handler->handleSingleDocument($xml);
|
||||||
\simplexml_load_string($cloverContents),
|
|
||||||
);
|
|
||||||
|
|
||||||
$files = $accumulator->getFiles();
|
$files = $accumulator->getFiles();
|
||||||
\expect($files)->toHaveCount(2)
|
\expect($files)->toHaveCount(2)
|
||||||
@@ -81,12 +81,12 @@ use Dannecron\CoverageMerger\Clover\Parser;
|
|||||||
\test('examples with invalid structure', function (string $exampleFilename): void {
|
\test('examples with invalid structure', function (string $exampleFilename): void {
|
||||||
$handler = new Handler(new Parser());
|
$handler = new Handler(new Parser());
|
||||||
|
|
||||||
$cloverContents = \file_get_contents(\getExamplePath($exampleFilename));
|
$cloverContents = (string) \file_get_contents(\getExamplePath($exampleFilename));
|
||||||
|
/** @var \SimpleXMLElement $xml */
|
||||||
|
$xml = \simplexml_load_string($cloverContents);
|
||||||
|
|
||||||
$this->expectException(HandleException::class);
|
$this->expectException(HandleException::class);
|
||||||
$handler->handleSingleDocument(
|
$handler->handleSingleDocument($xml);
|
||||||
\simplexml_load_string($cloverContents),
|
|
||||||
);
|
|
||||||
})
|
})
|
||||||
->with([
|
->with([
|
||||||
'file-with-bad-line.xml',
|
'file-with-bad-line.xml',
|
||||||
|
|||||||
@@ -9,18 +9,27 @@ use Dannecron\CoverageMerger\Clover\Handler;
|
|||||||
use Dannecron\CoverageMerger\Clover\Parser;
|
use Dannecron\CoverageMerger\Clover\Parser;
|
||||||
|
|
||||||
\test('merge multiple valid files', function (): void {
|
\test('merge multiple valid files', function (): void {
|
||||||
$fileWithPackage = \file_get_contents(\getExamplePath('file-with-package.xml'));
|
$fileWithPackage = (string) \file_get_contents(\getExamplePath('file-with-package.xml'));
|
||||||
$fileWithoutPackage = \file_get_contents(\getExamplePath('file-without-package.xml'));
|
$fileWithoutPackage = (string) \file_get_contents(\getExamplePath('file-without-package.xml'));
|
||||||
$fileWithDifferences = \file_get_contents(\getExamplePath('file-with-differences.xml'));
|
$fileWithDifferences = (string) \file_get_contents(\getExamplePath('file-with-differences.xml'));
|
||||||
$metricsAndClasses = \file_get_contents(\getExamplePath('metrics-and-classes.xml'));
|
$metricsAndClasses = (string) \file_get_contents(\getExamplePath('metrics-and-classes.xml'));
|
||||||
|
|
||||||
$handler = new Handler(new Parser());
|
$handler = new Handler(new Parser());
|
||||||
|
|
||||||
|
/** @var \SimpleXMLElement $xmlFileWithPackage */
|
||||||
|
$xmlFileWithPackage = \simplexml_load_string($fileWithPackage);
|
||||||
|
/** @var \SimpleXMLElement $xmlFileWithoutPackage */
|
||||||
|
$xmlFileWithoutPackage = \simplexml_load_string($fileWithoutPackage);
|
||||||
|
/** @var \SimpleXMLElement $xmlFileWithDifferences */
|
||||||
|
$xmlFileWithDifferences = \simplexml_load_string($fileWithDifferences);
|
||||||
|
/** @var \SimpleXMLElement $xmlMetricsAndClasses */
|
||||||
|
$xmlMetricsAndClasses = \simplexml_load_string($metricsAndClasses);
|
||||||
|
|
||||||
$accumulator = $handler->handle(
|
$accumulator = $handler->handle(
|
||||||
\simplexml_load_string($fileWithPackage),
|
$xmlFileWithPackage,
|
||||||
\simplexml_load_string($fileWithoutPackage),
|
$xmlFileWithoutPackage,
|
||||||
\simplexml_load_string($fileWithDifferences),
|
$xmlFileWithDifferences,
|
||||||
\simplexml_load_string($metricsAndClasses),
|
$xmlMetricsAndClasses,
|
||||||
);
|
);
|
||||||
|
|
||||||
$files = $accumulator->getFiles();
|
$files = $accumulator->getFiles();
|
||||||
|
|||||||
Reference in New Issue
Block a user