1: <?php declare(strict_types = 1);
2:
3: namespace PHPStan\PhpDocParser\Ast\ConstExpr;
4:
5: use PHPStan\PhpDocParser\Ast\NodeAttributes;
6:
7: class ConstFetchNode implements ConstExprNode
8: {
9:
10: use NodeAttributes;
11:
12: /** @var string class name for class constants or empty string for non-class constants */
13: public string $className;
14:
15: public string $name;
16:
17: public function __construct(string $className, string $name)
18: {
19: $this->className = $className;
20: $this->name = $name;
21: }
22:
23: public function __toString(): string
24: {
25: if ($this->className === '') {
26: return $this->name;
27:
28: }
29:
30: return "{$this->className}::{$this->name}";
31: }
32:
33: /**
34: * @param array<string, mixed> $properties
35: */
36: public static function __set_state(array $properties): self
37: {
38: $instance = new self($properties['className'], $properties['name']);
39: if (isset($properties['attributes'])) {
40: foreach ($properties['attributes'] as $key => $value) {
41: $instance->setAttribute($key, $value);
42: }
43: }
44: return $instance;
45: }
46:
47: }
48: