| 1: | <?php declare(strict_types = 1); |
| 2: | |
| 3: | namespace PHPStan\PhpDocParser\Ast\Type; |
| 4: | |
| 5: | use function ltrim; |
| 6: | |
| 7: | /** |
| 8: | * A fully qualified class-like name like \Foo\Bar. |
| 9: | * It means the same class in every namespace. |
| 10: | */ |
| 11: | class FullyQualifiedNameNode implements NameNode |
| 12: | { |
| 13: | |
| 14: | use NameNodeTrait; |
| 15: | |
| 16: | /** |
| 17: | * @param string $name with or without a leading backslash |
| 18: | */ |
| 19: | public function __construct(string $name) |
| 20: | { |
| 21: | $this->name = ltrim($name, '\\'); |
| 22: | } |
| 23: | |
| 24: | public function toCodeString(): string |
| 25: | { |
| 26: | return '\\' . $this->name; |
| 27: | } |
| 28: | |
| 29: | public function isFullyQualified(): bool |
| 30: | { |
| 31: | return true; |
| 32: | } |
| 33: | |
| 34: | } |
| 35: |