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