1: <?php declare(strict_types = 1);
2:
3: namespace PHPStan\PhpDocParser\Ast\Type;
4:
5: use InvalidArgumentException;
6: use function sprintf;
7: use function strpos;
8:
9: /**
10: * A class-like name like Bar or Foo\Bar that resolves against the namespace
11: * and uses of the place it is written in.
12: */
13: class RelativeNameNode implements NameNode
14: {
15:
16: use NameNodeTrait;
17:
18: public function __construct(string $name)
19: {
20: if (strpos($name, '\\') === 0) {
21: throw new InvalidArgumentException(sprintf('Name %s is fully qualified, use FullyQualifiedNameNode.', $name));
22: }
23:
24: $this->name = $name;
25: }
26:
27: public function toCodeString(): string
28: {
29: return $this->name;
30: }
31:
32: public function isFullyQualified(): bool
33: {
34: return false;
35: }
36:
37: }
38: