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 AssertTagPropertyValueNode 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 $property;
22:
23: /** @var bool */
24: public $isNegated;
25:
26: /** @var bool */
27: public $isEquality;
28:
29: /** @var string (may be empty) */
30: public $description;
31:
32: public function __construct(TypeNode $type, string $parameter, string $property, bool $isNegated, string $description, bool $isEquality = false)
33: {
34: $this->type = $type;
35: $this->parameter = $parameter;
36: $this->property = $property;
37: $this->isNegated = $isNegated;
38: $this->isEquality = $isEquality;
39: $this->description = $description;
40: }
41:
42:
43: public function __toString(): string
44: {
45: $isNegated = $this->isNegated ? '!' : '';
46: $isEquality = $this->isEquality ? '=' : '';
47: return trim("{$isNegated}{$isEquality}{$this->type} {$this->parameter}->{$this->property} {$this->description}");
48: }
49:
50: }
51: