Allow PHP-8.2 and up Compatibility instead of just PHP-8.4

This commit is contained in:
johnnyq
2026-06-12 17:06:10 -04:00
parent 2204bd52f4
commit d3a93652f3
220 changed files with 7198 additions and 2635 deletions

View File

@@ -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);
}
}