mirror of
https://github.com/itflow-org/itflow
synced 2026-08-22 07:25:12 +00:00
Allow PHP-8.2 and up Compatibility instead of just PHP-8.4
This commit is contained in:
@@ -23,6 +23,9 @@ use Symfony\Component\HttpFoundation\Exception\UnexpectedValueException;
|
||||
*/
|
||||
class ParameterBag implements \IteratorAggregate, \Countable
|
||||
{
|
||||
/**
|
||||
* @param array<string, mixed> $parameters
|
||||
*/
|
||||
public function __construct(
|
||||
protected array $parameters = [],
|
||||
) {
|
||||
@@ -31,7 +34,11 @@ class ParameterBag implements \IteratorAggregate, \Countable
|
||||
/**
|
||||
* Returns the parameters.
|
||||
*
|
||||
* @param string|null $key The name of the parameter to return or null to get them all
|
||||
* @template TKey of string|null
|
||||
*
|
||||
* @param TKey $key The name of the parameter to return or null to get them all
|
||||
*
|
||||
* @return (TKey is null ? array<string, mixed> : array<mixed>)
|
||||
*
|
||||
* @throws BadRequestException if the value is not an array
|
||||
*/
|
||||
@@ -50,6 +57,8 @@ class ParameterBag implements \IteratorAggregate, \Countable
|
||||
|
||||
/**
|
||||
* Returns the parameter keys.
|
||||
*
|
||||
* @return list<string>
|
||||
*/
|
||||
public function keys(): array
|
||||
{
|
||||
@@ -58,6 +67,8 @@ class ParameterBag implements \IteratorAggregate, \Countable
|
||||
|
||||
/**
|
||||
* Replaces the current parameters by a new set.
|
||||
*
|
||||
* @param array<string, mixed> $parameters
|
||||
*/
|
||||
public function replace(array $parameters = []): void
|
||||
{
|
||||
@@ -66,6 +77,8 @@ class ParameterBag implements \IteratorAggregate, \Countable
|
||||
|
||||
/**
|
||||
* Adds parameters.
|
||||
*
|
||||
* @param array<string, mixed> $parameters
|
||||
*/
|
||||
public function add(array $parameters = []): void
|
||||
{
|
||||
@@ -188,7 +201,7 @@ class ParameterBag implements \IteratorAggregate, \Countable
|
||||
try {
|
||||
return $class::from($value);
|
||||
} catch (\ValueError|\TypeError $e) {
|
||||
throw new UnexpectedValueException(\sprintf('Parameter "%s" cannot be converted to enum: %s.', $key, $e->getMessage()), $e->getCode(), $e);
|
||||
throw new UnexpectedValueException(\sprintf('Parameter "%s" cannot be converted to enum: ', $key).$e->getMessage().'.', $e->getCode(), $e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user