| 1: | <?php declare(strict_types = 1); |
| 2: | |
| 3: | namespace ApiGen\Info; |
| 4: | |
| 5: | use ApiGen\Index\Index; |
| 6: | use PHPStan\PhpDocParser\Ast\Type\TypeNode; |
| 7: | |
| 8: | use function strtolower; |
| 9: | |
| 10: | |
| 11: | class ClassLikeReferenceInfo |
| 12: | { |
| 13: | |
| 14: | public string $full; |
| 15: | |
| 16: | |
| 17: | public string $fullLower; |
| 18: | |
| 19: | |
| 20: | public array $genericArgs = []; |
| 21: | |
| 22: | |
| 23: | public function __construct(string $full, ?string $fullLower = null) |
| 24: | { |
| 25: | $this->full = $full; |
| 26: | $this->fullLower = $fullLower ?? strtolower($full); |
| 27: | } |
| 28: | |
| 29: | |
| 30: | public function resolve(Index $index, ?ClassLikeInfo $scope = null): ?ClassLikeInfo |
| 31: | { |
| 32: | if ($this->fullLower === 'self' || $this->fullLower === 'static') { |
| 33: | return $scope; |
| 34: | } |
| 35: | |
| 36: | if ($this->fullLower === 'parent' && $scope instanceof ClassInfo && $scope->extends !== null) { |
| 37: | return $index->classLike[$scope->extends->fullLower] ?? null; |
| 38: | } |
| 39: | |
| 40: | return $index->classLike[$this->fullLower] ?? null; |
| 41: | } |
| 42: | } |
| 43: | |