aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/ramsey/collection/src/Map
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/ramsey/collection/src/Map')
-rw-r--r--vendor/ramsey/collection/src/Map/AbstractMap.php96
-rw-r--r--vendor/ramsey/collection/src/Map/AbstractTypedMap.php22
-rw-r--r--vendor/ramsey/collection/src/Map/AssociativeArrayMap.php3
-rw-r--r--vendor/ramsey/collection/src/Map/MapInterface.php55
-rw-r--r--vendor/ramsey/collection/src/Map/NamedParameterMap.php34
-rw-r--r--vendor/ramsey/collection/src/Map/TypedMap.php15
-rw-r--r--vendor/ramsey/collection/src/Map/TypedMapInterface.php3
7 files changed, 97 insertions, 131 deletions
diff --git a/vendor/ramsey/collection/src/Map/AbstractMap.php b/vendor/ramsey/collection/src/Map/AbstractMap.php
index 6b2e97a08..70f71160c 100644
--- a/vendor/ramsey/collection/src/Map/AbstractMap.php
+++ b/vendor/ramsey/collection/src/Map/AbstractMap.php
@@ -24,23 +24,22 @@ use function in_array;
/**
* This class provides a basic implementation of `MapInterface`, to minimize the
* effort required to implement this interface.
+ *
+ * @template T
+ * @template-extends AbstractArray<T>
+ * @template-implements MapInterface<T>
*/
abstract class AbstractMap extends AbstractArray implements MapInterface
{
/**
- * Sets the given value to the given offset in the map.
- *
- * @param mixed $offset The offset to set.
- * @param mixed $value The value to set at the given offset.
- *
- * @throws InvalidArgumentException if the offset provided is `null`.
+ * @inheritDoc
*/
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 ' . $value
+ . 'value ' . var_export($value, true)
);
}
@@ -48,9 +47,7 @@ abstract class AbstractMap extends AbstractArray implements MapInterface
}
/**
- * Returns `true` if this map contains a mapping for the specified key.
- *
- * @param mixed $key The key to check in the map.
+ * @inheritDoc
*/
public function containsKey($key): bool
{
@@ -58,11 +55,7 @@ abstract class AbstractMap extends AbstractArray implements MapInterface
}
/**
- * Returns `true` if this map maps one or more keys to the specified value.
- *
- * This performs a strict type check on the value.
- *
- * @param mixed $value The value to check in the map.
+ * @inheritDoc
*/
public function containsValue($value): bool
{
@@ -70,9 +63,7 @@ abstract class AbstractMap extends AbstractArray implements MapInterface
}
/**
- * Return an array of the keys contained in this map.
- *
- * @return mixed[]
+ * @inheritDoc
*/
public function keys(): array
{
@@ -80,14 +71,7 @@ abstract class AbstractMap extends AbstractArray implements MapInterface
}
/**
- * Returns the value to which the specified key is mapped, `null` if this
- * map contains no mapping for the key, or (optionally) `$defaultValue` if
- * this map contains no mapping for the key.
- *
- * @param mixed $key The key to return from the map.
- * @param mixed $defaultValue The default value to use if `$key` is not found.
- *
- * @return mixed|null the value or `null` if the key could not be found.
+ * @inheritDoc
*/
public function get($key, $defaultValue = null)
{
@@ -99,16 +83,7 @@ abstract class AbstractMap extends AbstractArray implements MapInterface
}
/**
- * Associates the specified value with the specified key in this map.
- *
- * If the map previously contained a mapping for the key, the old value is
- * replaced by the specified value.
- *
- * @param mixed $key The key to put or replace in the map.
- * @param mixed $value The value to store at `$key`.
- *
- * @return mixed|null the previous value associated with key, or `null` if
- * there was no mapping for `$key`.
+ * @inheritDoc
*/
public function put($key, $value)
{
@@ -119,17 +94,7 @@ abstract class AbstractMap extends AbstractArray implements MapInterface
}
/**
- * Associates the specified value with the specified key in this map only if
- * it is not already set.
- *
- * If there is already a value associated with `$key`, this returns that
- * value without replacing it.
- *
- * @param mixed $key The key to put in the map.
- * @param mixed $value The value to store at `$key`.
- *
- * @return mixed|null the previous value associated with key, or `null` if
- * there was no mapping for `$key`.
+ * @inheritDoc
*/
public function putIfAbsent($key, $value)
{
@@ -143,12 +108,7 @@ abstract class AbstractMap extends AbstractArray implements MapInterface
}
/**
- * Removes the mapping for a key from this map if it is present.
- *
- * @param mixed $key The key to remove from the map.
- *
- * @return mixed|null the previous value associated with key, or `null` if
- * there was no mapping for `$key`.
+ * @inheritDoc
*/
public function remove($key)
{
@@ -159,15 +119,7 @@ abstract class AbstractMap extends AbstractArray implements MapInterface
}
/**
- * Removes the entry for the specified key only if it is currently mapped to
- * the specified value.
- *
- * This performs a strict type check on the value.
- *
- * @param mixed $key The key to remove from the map.
- * @param mixed $value The value to match.
- *
- * @return bool true if the value was removed.
+ * @inheritDoc
*/
public function removeIf($key, $value): bool
{
@@ -181,14 +133,7 @@ abstract class AbstractMap extends AbstractArray implements MapInterface
}
/**
- * Replaces the entry for the specified key only if it is currently mapped
- * to some value.
- *
- * @param mixed $key The key to replace.
- * @param mixed $value The value to set at `$key`.
- *
- * @return mixed|null the previous value associated with key, or `null` if
- * there was no mapping for `$key`.
+ * @inheritDoc
*/
public function replace($key, $value)
{
@@ -202,16 +147,7 @@ abstract class AbstractMap extends AbstractArray implements MapInterface
}
/**
- * Replaces the entry for the specified key only if currently mapped to the
- * specified value.
- *
- * This performs a strict type check on the value.
- *
- * @param mixed $key The key to remove from the map.
- * @param mixed $oldValue The value to match.
- * @param mixed $newValue The value to use as a replacement.
- *
- * @return bool true if the value was replaced.
+ * @inheritDoc
*/
public function replaceIf($key, $oldValue, $newValue): bool
{
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 '
diff --git a/vendor/ramsey/collection/src/Map/AssociativeArrayMap.php b/vendor/ramsey/collection/src/Map/AssociativeArrayMap.php
index f97e21728..3274dc9de 100644
--- a/vendor/ramsey/collection/src/Map/AssociativeArrayMap.php
+++ b/vendor/ramsey/collection/src/Map/AssociativeArrayMap.php
@@ -16,6 +16,9 @@ namespace Ramsey\Collection\Map;
/**
* `AssociativeArrayMap` represents a standard associative array object.
+ *
+ * @template T
+ * @template-extends AbstractMap<T>
*/
class AssociativeArrayMap extends AbstractMap
{
diff --git a/vendor/ramsey/collection/src/Map/MapInterface.php b/vendor/ramsey/collection/src/Map/MapInterface.php
index 500bdb2d0..04e52a238 100644
--- a/vendor/ramsey/collection/src/Map/MapInterface.php
+++ b/vendor/ramsey/collection/src/Map/MapInterface.php
@@ -20,13 +20,16 @@ use Ramsey\Collection\ArrayInterface;
* An object that maps keys to values.
*
* A map cannot contain duplicate keys; each key can map to at most one value.
+ *
+ * @template T
+ * @template-extends ArrayInterface<T>
*/
interface MapInterface extends ArrayInterface
{
/**
* Returns `true` if this map contains a mapping for the specified key.
*
- * @param mixed $key The key to check in the map.
+ * @param array-key $key The key to check in the map.
*/
public function containsKey($key): bool;
@@ -35,14 +38,15 @@ interface MapInterface extends ArrayInterface
*
* This performs a strict type check on the value.
*
- * @param mixed $value The value to check in the map.
+ * @param T $value The value to check in the map.
*/
+ // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
public function containsValue($value): bool;
/**
* Return an array of the keys contained in this map.
*
- * @return mixed[]
+ * @return list<array-key>
*/
public function keys(): array;
@@ -51,11 +55,12 @@ interface MapInterface extends ArrayInterface
* map contains no mapping for the key, or (optionally) `$defaultValue` if
* this map contains no mapping for the key.
*
- * @param mixed $key The key to return from the map.
- * @param mixed $defaultValue The default value to use if `$key` is not found.
+ * @param array-key $key The key to return from the map.
+ * @param T|null $defaultValue The default value to use if `$key` is not found.
*
- * @return mixed|null the value or `null` if the key could not be found.
+ * @return T|null the value or `null` if the key could not be found.
*/
+ // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
public function get($key, $defaultValue = null);
/**
@@ -64,12 +69,13 @@ interface MapInterface extends ArrayInterface
* If the map previously contained a mapping for the key, the old value is
* replaced by the specified value.
*
- * @param mixed $key The key to put or replace in the map.
- * @param mixed $value The value to store at `$key`.
+ * @param array-key $key The key to put or replace in the map.
+ * @param T $value The value to store at `$key`.
*
- * @return mixed|null the previous value associated with key, or `null` if
+ * @return T|null the previous value associated with key, or `null` if
* there was no mapping for `$key`.
*/
+ // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
public function put($key, $value);
/**
@@ -79,22 +85,24 @@ interface MapInterface extends ArrayInterface
* If there is already a value associated with `$key`, this returns that
* value without replacing it.
*
- * @param mixed $key The key to put in the map.
- * @param mixed $value The value to store at `$key`.
+ * @param array-key $key The key to put in the map.
+ * @param T $value The value to store at `$key`.
*
- * @return mixed|null the previous value associated with key, or `null` if
+ * @return T|null the previous value associated with key, or `null` if
* there was no mapping for `$key`.
*/
+ // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
public function putIfAbsent($key, $value);
/**
* Removes the mapping for a key from this map if it is present.
*
- * @param mixed $key The key to remove from the map.
+ * @param array-key $key The key to remove from the map.
*
- * @return mixed|null the previous value associated with key, or `null` if
+ * @return T|null the previous value associated with key, or `null` if
* there was no mapping for `$key`.
*/
+ // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
public function remove($key);
/**
@@ -103,23 +111,25 @@ interface MapInterface extends ArrayInterface
*
* This performs a strict type check on the value.
*
- * @param mixed $key The key to remove from the map.
- * @param mixed $value The value to match.
+ * @param array-key $key The key to remove from the map.
+ * @param T $value The value to match.
*
* @return bool true if the value was removed.
*/
+ // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
public function removeIf($key, $value): bool;
/**
* Replaces the entry for the specified key only if it is currently mapped
* to some value.
*
- * @param mixed $key The key to replace.
- * @param mixed $value The value to set at `$key`.
+ * @param array-key $key The key to replace.
+ * @param T $value The value to set at `$key`.
*
- * @return mixed|null the previous value associated with key, or `null` if
+ * @return T|null the previous value associated with key, or `null` if
* there was no mapping for `$key`.
*/
+ // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
public function replace($key, $value);
/**
@@ -128,11 +138,12 @@ interface MapInterface extends ArrayInterface
*
* This performs a strict type check on the value.
*
- * @param mixed $key The key to remove from the map.
- * @param mixed $oldValue The value to match.
- * @param mixed $newValue The value to use as a replacement.
+ * @param array-key $key The key to remove from the map.
+ * @param T $oldValue The value to match.
+ * @param T $newValue The value to use as a replacement.
*
* @return bool true if the value was replaced.
*/
+ // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
public function replaceIf($key, $oldValue, $newValue): bool;
}
diff --git a/vendor/ramsey/collection/src/Map/NamedParameterMap.php b/vendor/ramsey/collection/src/Map/NamedParameterMap.php
index 7adfa0afd..ecc52f73a 100644
--- a/vendor/ramsey/collection/src/Map/NamedParameterMap.php
+++ b/vendor/ramsey/collection/src/Map/NamedParameterMap.php
@@ -25,6 +25,8 @@ use function is_int;
/**
* `NamedParameterMap` represents a mapping of values to a set of named keys
* that may optionally be typed
+ *
+ * @template-extends AbstractMap<mixed>
*/
class NamedParameterMap extends AbstractMap
{
@@ -34,15 +36,15 @@ class NamedParameterMap extends AbstractMap
/**
* Named parameters defined for this map.
*
- * @var array<mixed, string>
+ * @var array<string, string>
*/
protected $namedParameters;
/**
* Constructs a new `NamedParameterMap`.
*
- * @param array<mixed, string> $namedParameters The named parameters defined for this map.
- * @param mixed[] $data An initial set of data to set on this map.
+ * @param array<array-key, string> $namedParameters The named parameters defined for this map.
+ * @param array<array-key, mixed> $data An initial set of data to set on this map.
*/
public function __construct(array $namedParameters, array $data = [])
{
@@ -53,7 +55,7 @@ class NamedParameterMap extends AbstractMap
/**
* Returns named parameters set for this `NamedParameterMap`.
*
- * @return array<mixed, string>
+ * @return array<string, string>
*/
public function getNamedParameters(): array
{
@@ -61,17 +63,17 @@ class NamedParameterMap extends AbstractMap
}
/**
- * Sets the given value to the given offset in the map.
- *
- * @param mixed $offset The offset to set.
- * @param mixed $value The value to set at the given offset.
- *
- * @throws InvalidArgumentException if the offset provided is not a
- * defined named parameter, or if the value is not of the type defined
- * for the given named parameter.
+ * @inheritDoc
*/
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 (!array_key_exists($offset, $this->namedParameters)) {
throw new InvalidArgumentException(
'Attempting to set value for unconfigured parameter \''
@@ -94,9 +96,9 @@ class NamedParameterMap extends AbstractMap
* Given an array of named parameters, constructs a proper mapping of
* named parameters to types.
*
- * @param array<mixed, string> $namedParameters The named parameters to filter.
+ * @param array<array-key, string> $namedParameters The named parameters to filter.
*
- * @return array<mixed, string>
+ * @return array<string, string>
*/
protected function filterNamedParameters(array $namedParameters): array
{
@@ -105,11 +107,11 @@ class NamedParameterMap extends AbstractMap
foreach ($namedParameters as $key => $value) {
if (is_int($key)) {
- $names[] = (string) $value;
+ $names[] = $value;
$types[] = 'mixed';
} else {
$names[] = $key;
- $types[] = (string) $value;
+ $types[] = $value;
}
}
diff --git a/vendor/ramsey/collection/src/Map/TypedMap.php b/vendor/ramsey/collection/src/Map/TypedMap.php
index 84d075f80..752475fee 100644
--- a/vendor/ramsey/collection/src/Map/TypedMap.php
+++ b/vendor/ramsey/collection/src/Map/TypedMap.php
@@ -79,6 +79,11 @@ use Ramsey\Collection\Tool\TypeTrait;
* }
* }
* ```
+ *
+ * @phpstan-ignore-next-line
+ * @template K as array-key
+ * @template T
+ * @template-extends AbstractTypedMap<K, T>
*/
class TypedMap extends AbstractTypedMap
{
@@ -97,7 +102,7 @@ class TypedMap extends AbstractTypedMap
/**
* The data type of values stored in this collection.
*
- * A map values's type is immutable once it is set. For this reason, this
+ * 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.
@@ -110,7 +115,7 @@ class TypedMap extends AbstractTypedMap
*
* @param string $keyType The data type of the map's keys.
* @param string $valueType The data type of the map's values.
- * @param mixed[] $data The initial data to set for this map.
+ * @param array<K, T> $data The initial data to set for this map.
*/
public function __construct(string $keyType, string $valueType, array $data = [])
{
@@ -119,17 +124,11 @@ class TypedMap extends AbstractTypedMap
parent::__construct($data);
}
- /**
- * Return the type used on the key.
- */
public function getKeyType(): string
{
return $this->keyType;
}
- /**
- * Return the type forced on the values.
- */
public function getValueType(): string
{
return $this->valueType;
diff --git a/vendor/ramsey/collection/src/Map/TypedMapInterface.php b/vendor/ramsey/collection/src/Map/TypedMapInterface.php
index 54c783695..51b6a81a2 100644
--- a/vendor/ramsey/collection/src/Map/TypedMapInterface.php
+++ b/vendor/ramsey/collection/src/Map/TypedMapInterface.php
@@ -17,6 +17,9 @@ namespace Ramsey\Collection\Map;
/**
* A `TypedMapInterface` represents a map of elements where key and value are
* typed.
+ *
+ * @template T
+ * @template-extends MapInterface<T>
*/
interface TypedMapInterface extends MapInterface
{