| 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, private bool $onlyFiles) |
| 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: | |
| 49: | |
| 50: | |
| 51: | |
| 52: | |
| 53: | public function isOnlyFilesAnalysis(): bool |
| 54: | { |
| 55: | return $this->onlyFiles; |
| 56: | } |
| 57: | |
| 58: | public function getType(): string |
| 59: | { |
| 60: | return 'PHPStan_Node_CollectedDataNode'; |
| 61: | } |
| 62: | |
| 63: | |
| 64: | |
| 65: | |
| 66: | public function getSubNodeNames(): array |
| 67: | { |
| 68: | return []; |
| 69: | } |
| 70: | |
| 71: | } |
| 72: | |