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