| 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: | |
| 14: | |
| 15: | |
| 16: | class DoctrineArrayItem implements Node |
| 17: | { |
| 18: | |
| 19: | use NodeAttributes; |
| 20: | |
| 21: | |
| 22: | public $key; |
| 23: | |
| 24: | |
| 25: | public $value; |
| 26: | |
| 27: | |
| 28: | |
| 29: | |
| 30: | |
| 31: | public function __construct($key, $value) |
| 32: | { |
| 33: | $this->key = $key; |
| 34: | $this->value = $value; |
| 35: | } |
| 36: | |
| 37: | public function __toString(): string |
| 38: | { |
| 39: | if ($this->key === null) { |
| 40: | return (string) $this->value; |
| 41: | } |
| 42: | |
| 43: | return $this->key . '=' . $this->value; |
| 44: | } |
| 45: | |
| 46: | |
| 47: | |
| 48: | |
| 49: | public static function __set_state(array $properties): self |
| 50: | { |
| 51: | $instance = new self($properties['key'], $properties['value']); |
| 52: | if (isset($properties['attributes'])) { |
| 53: | foreach ($properties['attributes'] as $key => $value) { |
| 54: | $instance->setAttribute($key, $value); |
| 55: | } |
| 56: | } |
| 57: | return $instance; |
| 58: | } |
| 59: | |
| 60: | } |
| 61: | |