Aggiornato Composer
This commit is contained in:
@@ -20,6 +20,7 @@ use Ramsey\Collection\Exception\InvalidArgumentException;
|
||||
use function array_key_exists;
|
||||
use function array_keys;
|
||||
use function in_array;
|
||||
use function var_export;
|
||||
|
||||
/**
|
||||
* This class provides a basic implementation of `MapInterface`, to minimize the
|
||||
@@ -39,7 +40,7 @@ abstract class AbstractMap extends AbstractArray implements MapInterface
|
||||
if ($offset === null) {
|
||||
throw new InvalidArgumentException(
|
||||
'Map elements are key/value pairs; a key must be provided for '
|
||||
. 'value ' . var_export($value, true)
|
||||
. 'value ' . var_export($value, true),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,11 +18,13 @@ use Ramsey\Collection\Exception\InvalidArgumentException;
|
||||
use Ramsey\Collection\Tool\TypeTrait;
|
||||
use Ramsey\Collection\Tool\ValueToStringTrait;
|
||||
|
||||
use function var_export;
|
||||
|
||||
/**
|
||||
* This class provides a basic implementation of `TypedMapInterface`, to
|
||||
* minimize the effort required to implement this interface.
|
||||
*
|
||||
* @template K
|
||||
* @template K of array-key
|
||||
* @template T
|
||||
* @extends AbstractMap<T>
|
||||
* @implements TypedMapInterface<T>
|
||||
@@ -37,33 +39,30 @@ abstract class AbstractTypedMap extends AbstractMap implements TypedMapInterface
|
||||
* @param T $value
|
||||
*
|
||||
* @inheritDoc
|
||||
*
|
||||
* @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)
|
||||
. 'value ' . var_export($value, true),
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->checkType($this->getKeyType(), $offset) === false) {
|
||||
throw new InvalidArgumentException(
|
||||
'Key must be of type ' . $this->getKeyType() . '; key is '
|
||||
. $this->toolValueToString($offset)
|
||||
. $this->toolValueToString($offset),
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->checkType($this->getValueType(), $value) === false) {
|
||||
throw new InvalidArgumentException(
|
||||
'Value must be of type ' . $this->getValueType() . '; value is '
|
||||
. $this->toolValueToString($value)
|
||||
. $this->toolValueToString($value),
|
||||
);
|
||||
}
|
||||
|
||||
/** @psalm-suppress MixedArgumentTypeCoercion */
|
||||
parent::offsetSet($offset, $value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ use Ramsey\Collection\Tool\ValueToStringTrait;
|
||||
use function array_combine;
|
||||
use function array_key_exists;
|
||||
use function is_int;
|
||||
use function var_export;
|
||||
|
||||
/**
|
||||
* `NamedParameterMap` represents a mapping of values to a set of named keys
|
||||
@@ -38,7 +39,7 @@ class NamedParameterMap extends AbstractMap
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
protected $namedParameters;
|
||||
protected array $namedParameters;
|
||||
|
||||
/**
|
||||
* Constructs a new `NamedParameterMap`.
|
||||
@@ -70,14 +71,14 @@ class NamedParameterMap extends AbstractMap
|
||||
if ($offset === null) {
|
||||
throw new InvalidArgumentException(
|
||||
'Map elements are key/value pairs; a key must be provided for '
|
||||
. 'value ' . var_export($value, true)
|
||||
. 'value ' . var_export($value, true),
|
||||
);
|
||||
}
|
||||
|
||||
if (!array_key_exists($offset, $this->namedParameters)) {
|
||||
throw new InvalidArgumentException(
|
||||
'Attempting to set value for unconfigured parameter \''
|
||||
. $offset . '\''
|
||||
. $offset . '\'',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -85,7 +86,7 @@ class NamedParameterMap extends AbstractMap
|
||||
throw new InvalidArgumentException(
|
||||
'Value for \'' . $offset . '\' must be of type '
|
||||
. $this->namedParameters[$offset] . '; value is '
|
||||
. $this->toolValueToString($value)
|
||||
. $this->toolValueToString($value),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
13
vendor/ramsey/collection/src/Map/TypedMap.php
vendored
13
vendor/ramsey/collection/src/Map/TypedMap.php
vendored
@@ -20,7 +20,7 @@ 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
|
||||
@@ -80,7 +80,7 @@ use Ramsey\Collection\Tool\TypeTrait;
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @template K
|
||||
* @template K of array-key
|
||||
* @template T
|
||||
* @extends AbstractTypedMap<K, T>
|
||||
*/
|
||||
@@ -93,20 +93,16 @@ class TypedMap extends AbstractTypedMap
|
||||
*
|
||||
* 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;
|
||||
private string $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;
|
||||
private string $valueType;
|
||||
|
||||
/**
|
||||
* Constructs a map object of the specified key and value types,
|
||||
@@ -121,7 +117,6 @@ class TypedMap extends AbstractTypedMap
|
||||
$this->keyType = $keyType;
|
||||
$this->valueType = $valueType;
|
||||
|
||||
/** @psalm-suppress MixedArgumentTypeCoercion */
|
||||
parent::__construct($data);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user