From bdce6e7c6e668b4116260df9833f28abef75e8ad Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Mon, 9 Dec 2024 10:24:00 +0100 Subject: [PATCH 1/2] Fix wrong type in ProcessedCodeCoverageData --- src/Data/ProcessedCodeCoverageData.php | 40 ++++++++++++++------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/src/Data/ProcessedCodeCoverageData.php b/src/Data/ProcessedCodeCoverageData.php index 7bdf3426..8aaaf531 100644 --- a/src/Data/ProcessedCodeCoverageData.php +++ b/src/Data/ProcessedCodeCoverageData.php @@ -25,6 +25,25 @@ * @phpstan-import-type XdebugFunctionCoverageType from XdebugDriver * * @phpstan-type TestIdType = string + * + * @phpstan-type FunctionCoverageDataType array{ + * branches: array, + * out: array, + * out_hit: array, + * }>, + * paths: array, + * hit: list, + * }>, + * hit: list + * } + * + * @phpstan-type FunctionCoverageType array> */ final class ProcessedCodeCoverageData { @@ -41,22 +60,7 @@ final class ProcessedCodeCoverageData * Maintains base format of raw data (@see https://xdebug.org/docs/code_coverage), but each 'hit' entry is an array * of testcase ids. * - * @var array, - * out: array, - * out_hit: array, - * }>, - * paths: array, - * hit: list, - * }>, - * hit: list - * }>> + * @var FunctionCoverageType */ private array $functionCoverage = []; @@ -238,7 +242,7 @@ private function priorityForLine(array $data, int $line): int /** * For a function we have never seen before, copy all data over and simply init the 'hit' array. * - * @param XdebugFunctionCoverageType $functionData + * @param XdebugFunctionCoverageType|FunctionCoverageDataType $functionData */ private function initPreviouslyUnseenFunction(string $file, string $functionName, array $functionData): void { @@ -258,7 +262,7 @@ private function initPreviouslyUnseenFunction(string $file, string $functionName * Techniques such as mocking and where the contents of a file are different vary during tests (e.g. compiling * containers) mean that the functions inside a file cannot be relied upon to be static. * - * @param XdebugFunctionCoverageType $functionData + * @param XdebugFunctionCoverageType|FunctionCoverageDataType $functionData */ private function initPreviouslySeenFunction(string $file, string $functionName, array $functionData): void { From 142c2fc5a06815318a5a729f36a7210e32db51e8 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Mon, 9 Dec 2024 10:26:13 +0100 Subject: [PATCH 2/2] fix CS --- src/Data/ProcessedCodeCoverageData.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Data/ProcessedCodeCoverageData.php b/src/Data/ProcessedCodeCoverageData.php index 8aaaf531..af5d059f 100644 --- a/src/Data/ProcessedCodeCoverageData.php +++ b/src/Data/ProcessedCodeCoverageData.php @@ -25,7 +25,6 @@ * @phpstan-import-type XdebugFunctionCoverageType from XdebugDriver * * @phpstan-type TestIdType = string - * * @phpstan-type FunctionCoverageDataType array{ * branches: array, * hit: list * } - * * @phpstan-type FunctionCoverageType array> */ final class ProcessedCodeCoverageData @@ -242,7 +240,7 @@ private function priorityForLine(array $data, int $line): int /** * For a function we have never seen before, copy all data over and simply init the 'hit' array. * - * @param XdebugFunctionCoverageType|FunctionCoverageDataType $functionData + * @param FunctionCoverageDataType|XdebugFunctionCoverageType $functionData */ private function initPreviouslyUnseenFunction(string $file, string $functionName, array $functionData): void { @@ -262,7 +260,7 @@ private function initPreviouslyUnseenFunction(string $file, string $functionName * Techniques such as mocking and where the contents of a file are different vary during tests (e.g. compiling * containers) mean that the functions inside a file cannot be relied upon to be static. * - * @param XdebugFunctionCoverageType|FunctionCoverageDataType $functionData + * @param FunctionCoverageDataType|XdebugFunctionCoverageType $functionData */ private function initPreviouslySeenFunction(string $file, string $functionName, array $functionData): void {