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 count;
8: use function implode;
9:
10: class MethodTagValueNode implements PhpDocTagValueNode
11: {
12:
13: use NodeAttributes;
14:
15: /** @var bool */
16: public $isStatic;
17:
18: /** @var TypeNode|null */
19: public $returnType;
20:
21: /** @var string */
22: public $methodName;
23:
24: /** @var TemplateTagValueNode[] */
25: public $templateTypes;
26:
27: /** @var MethodTagValueParameterNode[] */
28: public $parameters;
29:
30: /** @var string (may be empty) */
31: public $description;
32:
33: public function __construct(bool $isStatic, ?TypeNode $returnType, string $methodName, array $parameters, string $description, array $templateTypes = [])
34: {
35: $this->isStatic = $isStatic;
36: $this->returnType = $returnType;
37: $this->methodName = $methodName;
38: $this->parameters = $parameters;
39: $this->description = $description;
40: $this->templateTypes = $templateTypes;
41: }
42:
43:
44: public function __toString(): string
45: {
46: $static = $this->isStatic ? 'static ' : '';
47: $returnType = $this->returnType !== null ? "{$this->returnType} " : '';
48: $parameters = implode(', ', $this->parameters);
49: $description = $this->description !== '' ? " {$this->description}" : '';
50: $templateTypes = count($this->templateTypes) > 0 ? '<' . implode(', ', $this->templateTypes) . '>' : '';
51: return "{$static}{$returnType}{$this->methodName}{$templateTypes}({$parameters}){$description}";
52: }
53:
54: }
55: