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: | final class CollectedDataNode extends NodeAbstract implements VirtualNode |
15: | { |
16: | |
17: | |
18: | |
19: | |
20: | public function __construct(private array $collectedData, private bool $onlyFiles) |
21: | { |
22: | parent::__construct([]); |
23: | } |
24: | |
25: | |
26: | |
27: | |
28: | |
29: | |
30: | |
31: | public function get(string $collectorType): array |
32: | { |
33: | $result = []; |
34: | foreach ($this->collectedData as $collectedData) { |
35: | if ($collectedData->getCollectorType() !== $collectorType) { |
36: | continue; |
37: | } |
38: | |
39: | $filePath = $collectedData->getFilePath(); |
40: | if (!array_key_exists($filePath, $result)) { |
41: | $result[$filePath] = []; |
42: | } |
43: | |
44: | $result[$filePath][] = $collectedData->getData(); |
45: | } |
46: | |
47: | return $result; |
48: | } |
49: | |
50: | |
51: | |
52: | |
53: | |
54: | |
55: | public function isOnlyFilesAnalysis(): bool |
56: | { |
57: | return $this->onlyFiles; |
58: | } |
59: | |
60: | public function getType(): string |
61: | { |
62: | return 'PHPStan_Node_CollectedDataNode'; |
63: | } |
64: | |
65: | |
66: | |
67: | |
68: | public function getSubNodeNames(): array |
69: | { |
70: | return []; |
71: | } |
72: | |
73: | } |
74: | |