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