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: | |
8: | class CallableTypeParameterNode implements Node |
9: | { |
10: | |
11: | use NodeAttributes; |
12: | |
13: | |
14: | public $type; |
15: | |
16: | |
17: | public $isReference; |
18: | |
19: | |
20: | public $isVariadic; |
21: | |
22: | |
23: | public $parameterName; |
24: | |
25: | |
26: | public $isOptional; |
27: | |
28: | public function __construct(TypeNode $type, bool $isReference, bool $isVariadic, string $parameterName, bool $isOptional) |
29: | { |
30: | $this->type = $type; |
31: | $this->isReference = $isReference; |
32: | $this->isVariadic = $isVariadic; |
33: | $this->parameterName = $parameterName; |
34: | $this->isOptional = $isOptional; |
35: | } |
36: | |
37: | |
38: | public function __toString(): string |
39: | { |
40: | $type = "{$this->type} "; |
41: | $isReference = $this->isReference ? '&' : ''; |
42: | $isVariadic = $this->isVariadic ? '...' : ''; |
43: | $default = $this->isOptional ? ' = default' : ''; |
44: | return "{$type}{$isReference}{$isVariadic}{$this->parameterName}{$default}"; |
45: | } |
46: | |
47: | } |
48: | |