diff options
Diffstat (limited to 'vendor/ramsey/collection/src/Map/AbstractTypedMap.php')
-rw-r--r-- | vendor/ramsey/collection/src/Map/AbstractTypedMap.php | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/vendor/ramsey/collection/src/Map/AbstractTypedMap.php b/vendor/ramsey/collection/src/Map/AbstractTypedMap.php index 80cec2e22..ff9f69177 100644 --- a/vendor/ramsey/collection/src/Map/AbstractTypedMap.php +++ b/vendor/ramsey/collection/src/Map/AbstractTypedMap.php @@ -21,6 +21,12 @@ use Ramsey\Collection\Tool\ValueToStringTrait; /** * This class provides a basic implementation of `TypedMapInterface`, to * minimize the effort required to implement this interface. + * + * @phpstan-ignore-next-line + * @template K as array-key + * @template T + * @template-extends AbstractMap<T> + * @template-implements TypedMapInterface<T> */ abstract class AbstractTypedMap extends AbstractMap implements TypedMapInterface { @@ -28,16 +34,22 @@ abstract class AbstractTypedMap extends AbstractMap implements TypedMapInterface use ValueToStringTrait; /** - * Sets the given value to the given offset in the map. + * @param K|null $offset + * @param T $value * - * @param mixed $offset The offset to set. - * @param mixed $value The value to set at the given offset. + * @inheritDoc * - * @throws InvalidArgumentException if the offset or value do not match the - * expected types. + * @psalm-suppress MoreSpecificImplementedParamType */ public function offsetSet($offset, $value): void { + if ($offset === null) { + throw new InvalidArgumentException( + 'Map elements are key/value pairs; a key must be provided for ' + . 'value ' . var_export($value, true) + ); + } + if ($this->checkType($this->getKeyType(), $offset) === false) { throw new InvalidArgumentException( 'Key must be of type ' . $this->getKeyType() . '; key is ' |