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 trim;
8:
9: class AssertTagMethodValueNode implements PhpDocTagValueNode
10: {
11:
12: use NodeAttributes;
13:
14: /** @var TypeNode */
15: public $type;
16:
17: /** @var string */
18: public $parameter;
19:
20: /** @var string */
21: public $method;
22:
23: /** @var bool */
24: public $isNegated;
25:
26: /** @var string (may be empty) */
27: public $description;
28:
29: public function __construct(TypeNode $type, string $parameter, string $method, bool $isNegated, string $description)
30: {
31: $this->type = $type;
32: $this->parameter = $parameter;
33: $this->method = $method;
34: $this->isNegated = $isNegated;
35: $this->description = $description;
36: }
37:
38:
39: public function __toString(): string
40: {
41: $isNegated = $this->isNegated ? '!' : '';
42: return trim("{$this->type} {$isNegated}{$this->parameter}->{$this->method}() {$this->description}");
43: }
44:
45: }
46: