1: <?php declare(strict_types = 1);
2:
3: namespace PHPStan\PhpDocParser\Ast\PhpDoc\Doctrine;
4:
5: use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprNode;
6: use PHPStan\PhpDocParser\Ast\Node;
7: use PHPStan\PhpDocParser\Ast\NodeAttributes;
8: use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
9:
10: /**
11: * @phpstan-type ValueType = DoctrineAnnotation|IdentifierTypeNode|DoctrineArray|ConstExprNode
12: */
13: class DoctrineArgument implements Node
14: {
15:
16: use NodeAttributes;
17:
18: /** @var IdentifierTypeNode|null */
19: public $key;
20:
21: /** @var ValueType */
22: public $value;
23:
24: /**
25: * @param ValueType $value
26: */
27: public function __construct(?IdentifierTypeNode $key, $value)
28: {
29: $this->key = $key;
30: $this->value = $value;
31: }
32:
33:
34: public function __toString(): string
35: {
36: if ($this->key === null) {
37: return (string) $this->value;
38: }
39:
40: return $this->key . '=' . $this->value;
41: }
42:
43: }
44: