1: <?php declare(strict_types = 1);
2:
3: namespace PHPStan\PhpDocParser\Ast\PhpDoc;
4:
5: use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprNode;
6: use PHPStan\PhpDocParser\Ast\Node;
7: use PHPStan\PhpDocParser\Ast\NodeAttributes;
8: use PHPStan\PhpDocParser\Ast\Type\TypeNode;
9:
10: class MethodTagValueParameterNode implements Node
11: {
12:
13: use NodeAttributes;
14:
15: public ?TypeNode $type = null;
16:
17: public bool $isReference;
18:
19: public bool $isVariadic;
20:
21: public string $parameterName;
22:
23: public ?ConstExprNode $defaultValue = null;
24:
25: public function __construct(?TypeNode $type, bool $isReference, bool $isVariadic, string $parameterName, ?ConstExprNode $defaultValue)
26: {
27: $this->type = $type;
28: $this->isReference = $isReference;
29: $this->isVariadic = $isVariadic;
30: $this->parameterName = $parameterName;
31: $this->defaultValue = $defaultValue;
32: }
33:
34: public function __toString(): string
35: {
36: $type = $this->type !== null ? "{$this->type} " : '';
37: $isReference = $this->isReference ? '&' : '';
38: $isVariadic = $this->isVariadic ? '...' : '';
39: $default = $this->defaultValue !== null ? " = {$this->defaultValue}" : '';
40: return "{$type}{$isReference}{$isVariadic}{$this->parameterName}{$default}";
41: }
42:
43: /**
44: * @param array<string, mixed> $properties
45: */
46: public static function __set_state(array $properties): self
47: {
48: $instance = new self($properties['type'], $properties['isReference'], $properties['isVariadic'], $properties['parameterName'], $properties['defaultValue']);
49: if (isset($properties['attributes'])) {
50: foreach ($properties['attributes'] as $key => $value) {
51: $instance->setAttribute($key, $value);
52: }
53: }
54: return $instance;
55: }
56:
57: }
58: