1: | <?php declare(strict_types = 1); |
2: | |
3: | namespace PHPStan\Node; |
4: | |
5: | use PhpParser\Node; |
6: | use PhpParser\NodeAbstract; |
7: | use PHPStan\Collectors\CollectedData; |
8: | use PHPStan\Collectors\Collector; |
9: | use function array_key_exists; |
10: | |
11: | |
12: | |
13: | |
14: | |
15: | class CollectedDataNode extends NodeAbstract |
16: | { |
17: | |
18: | |
19: | |
20: | |
21: | public function __construct(private array $collectedData, private bool $onlyFiles) |
22: | { |
23: | parent::__construct([]); |
24: | } |
25: | |
26: | |
27: | |
28: | |
29: | |
30: | |
31: | |
32: | public function get(string $collectorType): array |
33: | { |
34: | $result = []; |
35: | foreach ($this->collectedData as $collectedData) { |
36: | if ($collectedData->getCollectorType() !== $collectorType) { |
37: | continue; |
38: | } |
39: | |
40: | $filePath = $collectedData->getFilePath(); |
41: | if (!array_key_exists($filePath, $result)) { |
42: | $result[$filePath] = []; |
43: | } |
44: | |
45: | $result[$filePath][] = $collectedData->getData(); |
46: | } |
47: | |
48: | return $result; |
49: | } |
50: | |
51: | |
52: | |
53: | |
54: | |
55: | |
56: | public function isOnlyFilesAnalysis(): bool |
57: | { |
58: | return $this->onlyFiles; |
59: | } |
60: | |
61: | public function getType(): string |
62: | { |
63: | return 'PHPStan_Node_CollectedDataNode'; |
64: | } |
65: | |
66: | |
67: | |
68: | |
69: | public function getSubNodeNames(): array |
70: | { |
71: | return []; |
72: | } |
73: | |
74: | } |
75: | |