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: /** @var TypeNode */
15: public $type;
16:
17: /** @var bool */
18: public $isReference;
19:
20: /** @var bool */
21: public $isVariadic;
22:
23: /** @var string (may be empty) */
24: public $parameterName;
25:
26: /** @var bool */
27: public $isOptional;
28:
29: public function __construct(TypeNode $type, bool $isReference, bool $isVariadic, string $parameterName, bool $isOptional)
30: {
31: $this->type = $type;
32: $this->isReference = $isReference;
33: $this->isVariadic = $isVariadic;
34: $this->parameterName = $parameterName;
35: $this->isOptional = $isOptional;
36: }
37:
38:
39: public function __toString(): string
40: {
41: $type = "{$this->type} ";
42: $isReference = $this->isReference ? '&' : '';
43: $isVariadic = $this->isVariadic ? '...' : '';
44: $default = $this->isOptional ? ' = default' : '';
45: return trim("{$type}{$isReference}{$isVariadic}{$this->parameterName}") . $default;
46: }
47:
48: }
49: