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