| 1: | <?php declare(strict_types = 1); |
| 2: | |
| 3: | namespace PHPStan\PhpDocParser\Ast\Type; |
| 4: | |
| 5: | use PHPStan\PhpDocParser\Ast\Node; |
| 6: | use PHPStan\PhpDocParser\Ast\NodeAttributes; |
| 7: | use function sprintf; |
| 8: | |
| 9: | class ArrayShapeUnsealedTypeNode implements Node |
| 10: | { |
| 11: | |
| 12: | use NodeAttributes; |
| 13: | |
| 14: | public TypeNode $valueType; |
| 15: | |
| 16: | public ?TypeNode $keyType = null; |
| 17: | |
| 18: | public function __construct(TypeNode $valueType, ?TypeNode $keyType) |
| 19: | { |
| 20: | $this->valueType = $valueType; |
| 21: | $this->keyType = $keyType; |
| 22: | } |
| 23: | |
| 24: | public function __toString(): string |
| 25: | { |
| 26: | if ($this->keyType !== null) { |
| 27: | return sprintf('<%s, %s>', $this->keyType, $this->valueType); |
| 28: | } |
| 29: | return sprintf('<%s>', $this->valueType); |
| 30: | } |
| 31: | |
| 32: | |
| 33: | |
| 34: | |
| 35: | public static function __set_state(array $properties): self |
| 36: | { |
| 37: | $instance = new self($properties['valueType'], $properties['keyType']); |
| 38: | if (isset($properties['attributes'])) { |
| 39: | foreach ($properties['attributes'] as $key => $value) { |
| 40: | $instance->setAttribute($key, $value); |
| 41: | } |
| 42: | } |
| 43: | return $instance; |
| 44: | } |
| 45: | |
| 46: | } |
| 47: | |