Skip to content

Commit 02fb800

Browse files
committed
Extract CollectorData virtual type
1 parent 97bc97f commit 02fb800

File tree

9 files changed

+34
-25
lines changed

9 files changed

+34
-25
lines changed

src/Analyser/Analyser.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
namespace PHPStan\Analyser;
44

55
use Closure;
6-
use PhpParser\Node;
7-
use PHPStan\Collectors\Collector;
6+
use PHPStan\Collectors\CollectedData;
87
use PHPStan\Collectors\Registry as CollectorRegistry;
98
use PHPStan\Rules\Registry as RuleRegistry;
109
use Throwable;
@@ -13,6 +12,9 @@
1312
use function count;
1413
use function memory_get_peak_usage;
1514

15+
/**
16+
* @phpstan-import-type CollectorData from CollectedData
17+
*/
1618
final class Analyser
1719
{
1820

@@ -60,7 +62,7 @@ public function analyse(
6062
$linesToIgnore = [];
6163
$unmatchedLineIgnores = [];
6264

63-
/** @var array<string, array<class-string<Collector<Node, mixed>>, list<mixed>>> $collectedData */
65+
/** @var CollectorData $collectedData */
6466
$collectedData = [];
6567

6668
$internalErrorsCount = 0;

src/Analyser/AnalyserResult.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
namespace PHPStan\Analyser;
44

5-
use PhpParser\Node;
6-
use PHPStan\Collectors\Collector;
5+
use PHPStan\Collectors\CollectedData;
76
use PHPStan\Dependency\RootExportedNode;
87
use function usort;
98

109
/**
1110
* @phpstan-import-type LinesToIgnore from FileAnalyserResult
11+
* @phpstan-import-type CollectorData from CollectedData
1212
*/
1313
final class AnalyserResult
1414
{
@@ -23,7 +23,7 @@ final class AnalyserResult
2323
* @param list<Error> $locallyIgnoredErrors
2424
* @param array<string, LinesToIgnore> $linesToIgnore
2525
* @param array<string, LinesToIgnore> $unmatchedLineIgnores
26-
* @param array<string, array<class-string<Collector<Node, mixed>>, list<mixed>>> $collectedData
26+
* @param CollectorData $collectedData
2727
* @param list<InternalError> $internalErrors
2828
* @param array<string, array<string>>|null $dependencies
2929
* @param array<string, array<RootExportedNode>> $exportedNodes
@@ -126,7 +126,7 @@ public function getInternalErrors(): array
126126
}
127127

128128
/**
129-
* @return array<string, array<class-string<Collector<Node, mixed>>, list<mixed>>>
129+
* @return CollectorData
130130
*/
131131
public function getCollectedData(): array
132132
{

src/Analyser/FileAnalyser.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use PHPStan\BetterReflection\NodeCompiler\Exception\UnableToCompileNode;
88
use PHPStan\BetterReflection\Reflection\Exception\CircularReference;
99
use PHPStan\BetterReflection\Reflector\Exception\IdentifierNotFound;
10-
use PHPStan\Collectors\Collector;
10+
use PHPStan\Collectors\CollectedData;
1111
use PHPStan\Collectors\Registry as CollectorRegistry;
1212
use PHPStan\Dependency\DependencyResolver;
1313
use PHPStan\Node\FileNode;
@@ -37,6 +37,9 @@
3737
use const E_USER_WARNING;
3838
use const E_WARNING;
3939

40+
/**
41+
* @phpstan-import-type CollectorData from CollectedData
42+
*/
4043
final class FileAnalyser
4144
{
4245

@@ -76,7 +79,7 @@ public function analyseFile(
7679
/** @var list<Error> $locallyIgnoredErrors */
7780
$locallyIgnoredErrors = [];
7881

79-
/** @var array<string, array<class-string<Collector<Node, mixed>>, list<mixed>>> $fileCollectedData */
82+
/** @var CollectorData $fileCollectedData */
8083
$fileCollectedData = [];
8184

8285
$fileDependencies = [];

src/Analyser/FileAnalyserResult.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
namespace PHPStan\Analyser;
44

5-
use PhpParser\Node;
6-
use PHPStan\Collectors\Collector;
5+
use PHPStan\Collectors\CollectedData;
76
use PHPStan\Dependency\RootExportedNode;
87

98
/**
109
* @phpstan-type LinesToIgnore = array<string, array<int, non-empty-list<string>|null>>
10+
* @phpstan-import-type CollectorData from CollectedData
1111
*/
1212
final class FileAnalyserResult
1313
{
@@ -17,7 +17,7 @@ final class FileAnalyserResult
1717
* @param list<Error> $filteredPhpErrors
1818
* @param list<Error> $allPhpErrors
1919
* @param list<Error> $locallyIgnoredErrors
20-
* @param array<string, array<class-string<Collector<Node, mixed>>, list<mixed>>> $collectedData
20+
* @param CollectorData $collectedData
2121
* @param list<string> $dependencies
2222
* @param list<RootExportedNode> $exportedNodes
2323
* @param LinesToIgnore $linesToIgnore
@@ -70,7 +70,7 @@ public function getLocallyIgnoredErrors(): array
7070
}
7171

7272
/**
73-
* @return array<string, array<class-string<Collector<Node, mixed>>, list<mixed>>>
73+
* @return CollectorData
7474
*/
7575
public function getCollectedData(): array
7676
{

src/Analyser/ResultCache/ResultCache.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
namespace PHPStan\Analyser\ResultCache;
44

5-
use PhpParser\Node;
65
use PHPStan\Analyser\Error;
76
use PHPStan\Analyser\FileAnalyserResult;
8-
use PHPStan\Collectors\Collector;
7+
use PHPStan\Collectors\CollectedData;
98
use PHPStan\Dependency\RootExportedNode;
109

1110
/**
1211
* @phpstan-import-type LinesToIgnore from FileAnalyserResult
12+
* @phpstan-import-type CollectorData from CollectedData
1313
*/
1414
final class ResultCache
1515
{
@@ -21,7 +21,7 @@ final class ResultCache
2121
* @param array<string, list<Error>> $locallyIgnoredErrors
2222
* @param array<string, LinesToIgnore> $linesToIgnore
2323
* @param array<string, LinesToIgnore> $unmatchedLineIgnores
24-
* @param array<string, array<class-string<Collector<Node, mixed>>, list<mixed>>> $collectedData
24+
* @param CollectorData $collectedData
2525
* @param array<string, array<string>> $dependencies
2626
* @param array<string, array<RootExportedNode>> $exportedNodes
2727
* @param array<string, array{string, bool, string}> $projectExtensionFiles
@@ -102,7 +102,7 @@ public function getUnmatchedLineIgnores(): array
102102
}
103103

104104
/**
105-
* @return array<string, array<class-string<Collector<Node, mixed>>, list<mixed>>>
105+
* @return CollectorData
106106
*/
107107
public function getCollectedData(): array
108108
{

src/Analyser/ResultCache/ResultCacheManager.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@
33
namespace PHPStan\Analyser\ResultCache;
44

55
use Nette\Neon\Neon;
6-
use PhpParser\Node;
76
use PHPStan\Analyser\AnalyserResult;
87
use PHPStan\Analyser\Error;
98
use PHPStan\Analyser\FileAnalyserResult;
109
use PHPStan\Collectors\CollectedData;
11-
use PHPStan\Collectors\Collector;
1210
use PHPStan\Command\Output;
1311
use PHPStan\Dependency\ExportedNodeFetcher;
1412
use PHPStan\Dependency\RootExportedNode;
@@ -51,6 +49,7 @@
5149

5250
/**
5351
* @phpstan-import-type LinesToIgnore from FileAnalyserResult
52+
* @phpstan-import-type CollectorData from CollectedData
5453
*/
5554
final class ResultCacheManager
5655
{
@@ -576,8 +575,8 @@ private function mergeLocallyIgnoredErrors(ResultCache $resultCache, array $fres
576575
}
577576

578577
/**
579-
* @param array<string, array<class-string<Collector<Node, mixed>>, list<mixed>>> $freshCollectedDataByFile
580-
* @return array<string, array<class-string<Collector<Node, mixed>>, list<mixed>>>
578+
* @param CollectorData $freshCollectedDataByFile
579+
* @return CollectorData
581580
*/
582581
private function mergeCollectedData(ResultCache $resultCache, array $freshCollectedDataByFile): array
583582
{

src/Collectors/CollectedData.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
/**
1010
* @api
11+
*
12+
* @phpstan-type CollectorData = array<string, array<class-string<Collector<Node, mixed>>, list<mixed>>>
1113
*/
1214
final class CollectedData implements JsonSerializable
1315
{

src/Command/AnalyseApplication.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@
22

33
namespace PHPStan\Command;
44

5-
use PhpParser\Node;
65
use PHPStan\Analyser\AnalyserResult;
76
use PHPStan\Analyser\AnalyserResultFinalizer;
87
use PHPStan\Analyser\Ignore\IgnoredErrorHelper;
98
use PHPStan\Analyser\ResultCache\ResultCacheManagerFactory;
109
use PHPStan\Collectors\CollectedData;
11-
use PHPStan\Collectors\Collector;
1210
use PHPStan\Internal\BytesHelper;
1311
use PHPStan\PhpDoc\StubFilesProvider;
1412
use PHPStan\PhpDoc\StubValidator;
@@ -22,6 +20,9 @@
2220
use function sha1_file;
2321
use function sprintf;
2422

23+
/**
24+
* @phpstan-import-type CollectorData from CollectedData
25+
*/
2526
final class AnalyseApplication
2627
{
2728

@@ -164,7 +165,7 @@ public function analyse(
164165
}
165166

166167
/**
167-
* @param array<string, array<class-string<Collector<Node, mixed>>, list<mixed>>> $collectedData
168+
* @param CollectorData $collectedData
168169
*
169170
* @return list<CollectedData>
170171
*/

src/Node/CollectedDataNode.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@
44

55
use PhpParser\Node;
66
use PhpParser\NodeAbstract;
7+
use PHPStan\Collectors\CollectedData;
78
use PHPStan\Collectors\Collector;
89

910
/**
1011
* @api
12+
* @phpstan-import-type CollectorData from CollectedData
1113
*/
1214
final class CollectedDataNode extends NodeAbstract implements VirtualNode
1315
{
1416

1517
/**
16-
* @param array<string, array<class-string<Collector<Node, mixed>>, list<mixed>>> $collectedData
18+
* @param CollectorData $collectedData
1719
*/
1820
public function __construct(private array $collectedData, private bool $onlyFiles)
1921
{

0 commit comments

Comments
 (0)