mirror of
https://github.com/linuxserver/Heimdall.git
synced 2025-12-10 08:53:57 +09:00
Updates to vendors etc
This commit is contained in:
70
vendor/symfony/http-foundation/ParameterBag.php
vendored
70
vendor/symfony/http-foundation/ParameterBag.php
vendored
@@ -23,20 +23,17 @@ use Symfony\Component\HttpFoundation\Exception\UnexpectedValueException;
|
||||
*/
|
||||
class ParameterBag implements \IteratorAggregate, \Countable
|
||||
{
|
||||
/**
|
||||
* Parameter storage.
|
||||
*/
|
||||
protected $parameters;
|
||||
|
||||
public function __construct(array $parameters = [])
|
||||
{
|
||||
$this->parameters = $parameters;
|
||||
public function __construct(
|
||||
protected array $parameters = [],
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parameters.
|
||||
*
|
||||
* @param string|null $key The name of the parameter to return or null to get them all
|
||||
*
|
||||
* @throws BadRequestException if the value is not an array
|
||||
*/
|
||||
public function all(?string $key = null): array
|
||||
{
|
||||
@@ -45,7 +42,7 @@ class ParameterBag implements \IteratorAggregate, \Countable
|
||||
}
|
||||
|
||||
if (!\is_array($value = $this->parameters[$key] ?? [])) {
|
||||
throw new BadRequestException(sprintf('Unexpected value for parameter "%s": expecting "array", got "%s".', $key, get_debug_type($value)));
|
||||
throw new BadRequestException(\sprintf('Unexpected value for parameter "%s": expecting "array", got "%s".', $key, get_debug_type($value)));
|
||||
}
|
||||
|
||||
return $value;
|
||||
@@ -61,20 +58,16 @@ class ParameterBag implements \IteratorAggregate, \Countable
|
||||
|
||||
/**
|
||||
* Replaces the current parameters by a new set.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function replace(array $parameters = [])
|
||||
public function replace(array $parameters = []): void
|
||||
{
|
||||
$this->parameters = $parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds parameters.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function add(array $parameters = [])
|
||||
public function add(array $parameters = []): void
|
||||
{
|
||||
$this->parameters = array_replace($this->parameters, $parameters);
|
||||
}
|
||||
@@ -84,10 +77,7 @@ class ParameterBag implements \IteratorAggregate, \Countable
|
||||
return \array_key_exists($key, $this->parameters) ? $this->parameters[$key] : $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function set(string $key, mixed $value)
|
||||
public function set(string $key, mixed $value): void
|
||||
{
|
||||
$this->parameters[$key] = $value;
|
||||
}
|
||||
@@ -102,16 +92,16 @@ class ParameterBag implements \IteratorAggregate, \Countable
|
||||
|
||||
/**
|
||||
* Removes a parameter.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function remove(string $key)
|
||||
public function remove(string $key): void
|
||||
{
|
||||
unset($this->parameters[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the alphabetic characters of the parameter value.
|
||||
*
|
||||
* @throws UnexpectedValueException if the value cannot be converted to string
|
||||
*/
|
||||
public function getAlpha(string $key, string $default = ''): string
|
||||
{
|
||||
@@ -120,6 +110,8 @@ class ParameterBag implements \IteratorAggregate, \Countable
|
||||
|
||||
/**
|
||||
* Returns the alphabetic characters and digits of the parameter value.
|
||||
*
|
||||
* @throws UnexpectedValueException if the value cannot be converted to string
|
||||
*/
|
||||
public function getAlnum(string $key, string $default = ''): string
|
||||
{
|
||||
@@ -128,6 +120,8 @@ class ParameterBag implements \IteratorAggregate, \Countable
|
||||
|
||||
/**
|
||||
* Returns the digits of the parameter value.
|
||||
*
|
||||
* @throws UnexpectedValueException if the value cannot be converted to string
|
||||
*/
|
||||
public function getDigits(string $key, string $default = ''): string
|
||||
{
|
||||
@@ -136,12 +130,14 @@ class ParameterBag implements \IteratorAggregate, \Countable
|
||||
|
||||
/**
|
||||
* Returns the parameter as string.
|
||||
*
|
||||
* @throws UnexpectedValueException if the value cannot be converted to string
|
||||
*/
|
||||
public function getString(string $key, string $default = ''): string
|
||||
{
|
||||
$value = $this->get($key, $default);
|
||||
if (!\is_scalar($value) && !$value instanceof \Stringable) {
|
||||
throw new UnexpectedValueException(sprintf('Parameter value "%s" cannot be converted to "string".', $key));
|
||||
throw new UnexpectedValueException(\sprintf('Parameter value "%s" cannot be converted to "string".', $key));
|
||||
}
|
||||
|
||||
return (string) $value;
|
||||
@@ -149,15 +145,18 @@ class ParameterBag implements \IteratorAggregate, \Countable
|
||||
|
||||
/**
|
||||
* Returns the parameter value converted to integer.
|
||||
*
|
||||
* @throws UnexpectedValueException if the value cannot be converted to integer
|
||||
*/
|
||||
public function getInt(string $key, int $default = 0): int
|
||||
{
|
||||
// In 7.0 remove the fallback to 0, in case of failure an exception will be thrown
|
||||
return $this->filter($key, $default, \FILTER_VALIDATE_INT, ['flags' => \FILTER_REQUIRE_SCALAR]) ?: 0;
|
||||
return $this->filter($key, $default, \FILTER_VALIDATE_INT, ['flags' => \FILTER_REQUIRE_SCALAR]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parameter value converted to boolean.
|
||||
*
|
||||
* @throws UnexpectedValueException if the value cannot be converted to a boolean
|
||||
*/
|
||||
public function getBoolean(string $key, bool $default = false): bool
|
||||
{
|
||||
@@ -173,6 +172,10 @@ class ParameterBag implements \IteratorAggregate, \Countable
|
||||
* @param ?T $default
|
||||
*
|
||||
* @return ?T
|
||||
*
|
||||
* @psalm-return ($default is null ? T|null : T)
|
||||
*
|
||||
* @throws UnexpectedValueException if the parameter value cannot be converted to an enum
|
||||
*/
|
||||
public function getEnum(string $key, string $class, ?\BackedEnum $default = null): ?\BackedEnum
|
||||
{
|
||||
@@ -185,7 +188,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: %s.', $key, $e->getMessage()), $e->getCode(), $e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,6 +199,9 @@ class ParameterBag implements \IteratorAggregate, \Countable
|
||||
* @param int|array{flags?: int, options?: array} $options Flags from FILTER_* constants
|
||||
*
|
||||
* @see https://php.net/filter-var
|
||||
*
|
||||
* @throws UnexpectedValueException if the parameter value is a non-stringable object
|
||||
* @throws UnexpectedValueException if the parameter value is invalid and \FILTER_NULL_ON_FAILURE is not set
|
||||
*/
|
||||
public function filter(string $key, mixed $default = null, int $filter = \FILTER_DEFAULT, mixed $options = []): mixed
|
||||
{
|
||||
@@ -212,11 +218,11 @@ class ParameterBag implements \IteratorAggregate, \Countable
|
||||
}
|
||||
|
||||
if (\is_object($value) && !$value instanceof \Stringable) {
|
||||
throw new UnexpectedValueException(sprintf('Parameter value "%s" cannot be filtered.', $key));
|
||||
throw new UnexpectedValueException(\sprintf('Parameter value "%s" cannot be filtered.', $key));
|
||||
}
|
||||
|
||||
if ((\FILTER_CALLBACK & $filter) && !(($options['options'] ?? null) instanceof \Closure)) {
|
||||
throw new \InvalidArgumentException(sprintf('A Closure must be passed to "%s()" when FILTER_CALLBACK is used, "%s" given.', __METHOD__, get_debug_type($options['options'] ?? null)));
|
||||
throw new \InvalidArgumentException(\sprintf('A Closure must be passed to "%s()" when FILTER_CALLBACK is used, "%s" given.', __METHOD__, get_debug_type($options['options'] ?? null)));
|
||||
}
|
||||
|
||||
$options['flags'] ??= 0;
|
||||
@@ -229,13 +235,7 @@ class ParameterBag implements \IteratorAggregate, \Countable
|
||||
return $value;
|
||||
}
|
||||
|
||||
$method = debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS | \DEBUG_BACKTRACE_PROVIDE_OBJECT, 2)[1];
|
||||
$method = ($method['object'] ?? null) === $this ? $method['function'] : 'filter';
|
||||
$hint = 'filter' === $method ? 'pass' : 'use method "filter()" with';
|
||||
|
||||
trigger_deprecation('symfony/http-foundation', '6.3', 'Ignoring invalid values when using "%s::%s(\'%s\')" is deprecated and will throw an "%s" in 7.0; '.$hint.' flag "FILTER_NULL_ON_FAILURE" to keep ignoring them.', $this::class, $method, $key, UnexpectedValueException::class);
|
||||
|
||||
return false;
|
||||
throw new \UnexpectedValueException(\sprintf('Parameter value "%s" is invalid and flag "FILTER_NULL_ON_FAILURE" was not set.', $key));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user