1: <?php declare(strict_types = 1);
2:
3: namespace PHPStan\PhpDocParser\Ast\Type;
4:
5: use PHPStan\PhpDocParser\Ast\Node;
6: use PHPStan\PhpDocParser\Ast\NodeAttributes;
7: use function trim;
8:
9: class CallableTypeParameterNode implements Node
10: {
11:
12: use NodeAttributes;
13:
14: public TypeNode $type;
15:
16: public bool $isReference;
17:
18: public bool $isVariadic;
19:
20: /** @var string (may be empty) */
21: public string $parameterName;
22:
23: public bool $isOptional;
24:
25: public function __construct(TypeNode $type, bool $isReference, bool $isVariadic, string $parameterName, bool $isOptional)
26: {
27: $this->type = $type;
28: $this->isReference = $isReference;
29: $this->isVariadic = $isVariadic;
30: $this->parameterName = $parameterName;
31: $this->isOptional = $isOptional;
32: }
33:
34:
35: public function __toString(): string
36: {
37: $type = "{$this->type} ";
38: $isReference = $this->isReference ? '&' : '';
39: $isVariadic = $this->isVariadic ? '...' : '';
40: $isOptional = $this->isOptional ? '=' : '';
41: return trim("{$type}{$isReference}{$isVariadic}{$this->parameterName}") . $isOptional;
42: }
43:
44: }
45: