Commaaa2
This commit is contained in:
@@ -21,6 +21,7 @@ use Ramsey\Collection\ArrayInterface;
|
||||
*
|
||||
* A map cannot contain duplicate keys; each key can map to at most one value.
|
||||
*
|
||||
* @template K of array-key
|
||||
* @template T
|
||||
* @extends ArrayInterface<T>
|
||||
*/
|
||||
@@ -29,9 +30,9 @@ interface MapInterface extends ArrayInterface
|
||||
/**
|
||||
* Returns `true` if this map contains a mapping for the specified key.
|
||||
*
|
||||
* @param array-key $key The key to check in the map.
|
||||
* @param K $key The key to check in the map.
|
||||
*/
|
||||
public function containsKey($key): bool;
|
||||
public function containsKey(int | string $key): bool;
|
||||
|
||||
/**
|
||||
* Returns `true` if this map maps one or more keys to the specified value.
|
||||
@@ -40,13 +41,12 @@ interface MapInterface extends ArrayInterface
|
||||
*
|
||||
* @param T $value The value to check in the map.
|
||||
*/
|
||||
// phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
|
||||
public function containsValue($value): bool;
|
||||
public function containsValue(mixed $value): bool;
|
||||
|
||||
/**
|
||||
* Return an array of the keys contained in this map.
|
||||
*
|
||||
* @return list<array-key>
|
||||
* @return list<K>
|
||||
*/
|
||||
public function keys(): array;
|
||||
|
||||
@@ -55,13 +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 array-key $key The key to return from the map.
|
||||
* @param T|null $defaultValue The default value to use if `$key` is not found.
|
||||
* @param K $key The key to return from the map.
|
||||
* @param T | null $defaultValue The default value to use if `$key` is not found.
|
||||
*
|
||||
* @return T|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);
|
||||
public function get(int | string $key, mixed $defaultValue = null): mixed;
|
||||
|
||||
/**
|
||||
* Associates the specified value with the specified key in this map.
|
||||
@@ -69,14 +68,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 array-key $key The key to put or replace in the map.
|
||||
* @param K $key The key to put or replace in the map.
|
||||
* @param T $value The value to store at `$key`.
|
||||
*
|
||||
* @return T|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);
|
||||
public function put(int | string $key, mixed $value): mixed;
|
||||
|
||||
/**
|
||||
* Associates the specified value with the specified key in this map only if
|
||||
@@ -85,25 +83,23 @@ interface MapInterface extends ArrayInterface
|
||||
* If there is already a value associated with `$key`, this returns that
|
||||
* value without replacing it.
|
||||
*
|
||||
* @param array-key $key The key to put in the map.
|
||||
* @param K $key The key to put in the map.
|
||||
* @param T $value The value to store at `$key`.
|
||||
*
|
||||
* @return T|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);
|
||||
public function putIfAbsent(int | string $key, mixed $value): mixed;
|
||||
|
||||
/**
|
||||
* Removes the mapping for a key from this map if it is present.
|
||||
*
|
||||
* @param array-key $key The key to remove from the map.
|
||||
* @param K $key The key to remove from the map.
|
||||
*
|
||||
* @return T|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);
|
||||
public function remove(int | string $key): mixed;
|
||||
|
||||
/**
|
||||
* Removes the entry for the specified key only if it is currently mapped to
|
||||
@@ -111,26 +107,24 @@ interface MapInterface extends ArrayInterface
|
||||
*
|
||||
* This performs a strict type check on the value.
|
||||
*
|
||||
* @param array-key $key The key to remove from the map.
|
||||
* @param K $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;
|
||||
public function removeIf(int | string $key, mixed $value): bool;
|
||||
|
||||
/**
|
||||
* Replaces the entry for the specified key only if it is currently mapped
|
||||
* to some value.
|
||||
*
|
||||
* @param array-key $key The key to replace.
|
||||
* @param K $key The key to replace.
|
||||
* @param T $value The value to set at `$key`.
|
||||
*
|
||||
* @return T|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);
|
||||
public function replace(int | string $key, mixed $value): mixed;
|
||||
|
||||
/**
|
||||
* Replaces the entry for the specified key only if currently mapped to the
|
||||
@@ -138,12 +132,11 @@ interface MapInterface extends ArrayInterface
|
||||
*
|
||||
* This performs a strict type check on the value.
|
||||
*
|
||||
* @param array-key $key The key to remove from the map.
|
||||
* @param K $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;
|
||||
public function replaceIf(int | string $key, mixed $oldValue, mixed $newValue): bool;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user