diff options
Diffstat (limited to 'vendor/ramsey/collection/src/Map/TypedMap.php')
-rw-r--r-- | vendor/ramsey/collection/src/Map/TypedMap.php | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/vendor/ramsey/collection/src/Map/TypedMap.php b/vendor/ramsey/collection/src/Map/TypedMap.php index f914d9c70..2e796377a 100644 --- a/vendor/ramsey/collection/src/Map/TypedMap.php +++ b/vendor/ramsey/collection/src/Map/TypedMap.php @@ -14,11 +14,13 @@ declare(strict_types=1); namespace Ramsey\Collection\Map; +use Ramsey\Collection\Tool\TypeTrait; + /** * A `TypedMap` represents a map of elements where key and value are typed. * * Each element is identified by a key with defined type and a value of defined - * type. The keys of the map must be unique. The values on the map can be + * type. The keys of the map must be unique. The values on the map can be= * repeated but each with its own different key. * * The most common case is to use a string type key, but it's not limited to @@ -78,12 +80,34 @@ namespace Ramsey\Collection\Map; * } * ``` * - * @template K of array-key + * @template K * @template T * @extends AbstractTypedMap<K, T> */ class TypedMap extends AbstractTypedMap { + use TypeTrait; + + /** + * The data type of keys stored in this collection. + * + * A map key's type is immutable once it is set. For this reason, this + * property is set private. + * + * @var string data type of the map key. + */ + private $keyType; + + /** + * The data type of values stored in this collection. + * + * A map value's type is immutable once it is set. For this reason, this + * property is set private. + * + * @var string data type of the map value. + */ + private $valueType; + /** * Constructs a map object of the specified key and value types, * optionally with the specified data. @@ -92,11 +116,12 @@ class TypedMap extends AbstractTypedMap * @param string $valueType The data type of the map's values. * @param array<K, T> $data The initial data to set for this map. */ - public function __construct( - private readonly string $keyType, - private readonly string $valueType, - array $data = [], - ) { + public function __construct(string $keyType, string $valueType, array $data = []) + { + $this->keyType = $keyType; + $this->valueType = $valueType; + + /** @psalm-suppress MixedArgumentTypeCoercion */ parent::__construct($data); } |