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: // declared in the order of the source, the format-preserving printer reprints the subnodes in this order
15: public ?TypeNode $keyType = null;
16:
17: public TypeNode $valueType;
18:
19: public function __construct(TypeNode $valueType, ?TypeNode $keyType)
20: {
21: $this->valueType = $valueType;
22: $this->keyType = $keyType;
23: }
24:
25: public function __toString(): string
26: {
27: if ($this->keyType !== null) {
28: return sprintf('<%s, %s>', $this->keyType, $this->valueType);
29: }
30: return sprintf('<%s>', $this->valueType);
31: }
32:
33: /**
34: * @param array<string, mixed> $properties
35: */
36: public static function __set_state(array $properties): self
37: {
38: $instance = new self($properties['valueType'], $properties['keyType']);
39: if (isset($properties['attributes'])) {
40: foreach ($properties['attributes'] as $key => $value) {
41: $instance->setAttribute($key, $value);
42: }
43: }
44: return $instance;
45: }
46:
47: }
48: