| 1: | <?php declare(strict_types = 1); |
| 2: | |
| 3: | namespace PHPStan\PhpDocParser\Ast\PhpDoc; |
| 4: | |
| 5: | use PHPStan\PhpDocParser\Ast\NodeAttributes; |
| 6: | use PHPStan\PhpDocParser\Ast\Type\TypeNode; |
| 7: | use function implode; |
| 8: | |
| 9: | class MethodTagValueNode implements PhpDocTagValueNode |
| 10: | { |
| 11: | |
| 12: | use NodeAttributes; |
| 13: | |
| 14: | |
| 15: | public $isStatic; |
| 16: | |
| 17: | |
| 18: | public $returnType; |
| 19: | |
| 20: | |
| 21: | public $methodName; |
| 22: | |
| 23: | |
| 24: | public $parameters; |
| 25: | |
| 26: | |
| 27: | public $description; |
| 28: | |
| 29: | public function __construct(bool $isStatic, ?TypeNode $returnType, string $methodName, array $parameters, string $description) |
| 30: | { |
| 31: | $this->isStatic = $isStatic; |
| 32: | $this->returnType = $returnType; |
| 33: | $this->methodName = $methodName; |
| 34: | $this->parameters = $parameters; |
| 35: | $this->description = $description; |
| 36: | } |
| 37: | |
| 38: | |
| 39: | public function __toString(): string |
| 40: | { |
| 41: | $static = $this->isStatic ? 'static ' : ''; |
| 42: | $returnType = $this->returnType !== null ? "{$this->returnType} " : ''; |
| 43: | $parameters = implode(', ', $this->parameters); |
| 44: | $description = $this->description !== '' ? " {$this->description}" : ''; |
| 45: | return "{$static}{$returnType}{$this->methodName}({$parameters}){$description}"; |
| 46: | } |
| 47: | |
| 48: | } |
| 49: | |