Skip to content

Commit

Permalink
Eliminate code duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Dec 7, 2024
1 parent 57d6d59 commit 9549d36
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/Target/MapBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
use SebastianBergmann\CodeCoverage\StaticAnalysis\FileAnalyser;

/**
* @phpstan-import-type TargetMap from Mapper
*
* @immutable
*
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for phpunit/php-code-coverage
Expand All @@ -27,7 +29,7 @@
final readonly class MapBuilder
{
/**
* @return array{namespaces: array<non-empty-string, list<positive-int>>, classes: array<non-empty-string, list<positive-int>>, classesThatExtendClass: array<non-empty-string, list<positive-int>>, classesThatImplementInterface: array<non-empty-string, list<positive-int>>, traits: array<non-empty-string, list<positive-int>>, methods: array<non-empty-string, list<positive-int>>, functions: array<non-empty-string, list<positive-int>>}
* @return TargetMap
*/
public function build(Filter $filter, FileAnalyser $analyser): array
{
Expand Down
6 changes: 4 additions & 2 deletions src/Target/Mapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
use SebastianBergmann\CodeCoverage\InvalidCodeCoverageTargetException;

/**
* @phpstan-type TargetMap = array{namespaces: array<non-empty-string, list<positive-int>>, classes: array<non-empty-string, list<positive-int>>, classesThatExtendClass: array<non-empty-string, list<positive-int>>, classesThatImplementInterface: array<non-empty-string, list<positive-int>>, traits: array<non-empty-string, list<positive-int>>, methods: array<non-empty-string, list<positive-int>>, functions: array<non-empty-string, list<positive-int>>}
*
* @immutable
*
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for phpunit/php-code-coverage
Expand All @@ -25,12 +27,12 @@
final readonly class Mapper
{
/**
* @var array{namespaces: array<non-empty-string, list<positive-int>>, classes: array<non-empty-string, list<positive-int>>, classesThatExtendClass: array<non-empty-string, list<positive-int>>, classesThatImplementInterface: array<non-empty-string, list<positive-int>>, traits: array<non-empty-string, list<positive-int>>, methods: array<non-empty-string, list<positive-int>>, functions: array<non-empty-string, list<positive-int>>}
* @var TargetMap
*/
private array $map;

/**
* @param array{namespaces: array<non-empty-string, list<positive-int>>, classes: array<non-empty-string, list<positive-int>>, classesThatExtendClass: array<non-empty-string, list<positive-int>>, classesThatImplementInterface: array<non-empty-string, list<positive-int>>, traits: array<non-empty-string, list<positive-int>>, methods: array<non-empty-string, list<positive-int>>, functions: array<non-empty-string, list<positive-int>>} $map
* @param TargetMap $map
*/
public function __construct(array $map)
{
Expand Down

0 comments on commit 9549d36

Please sign in to comment.