mirror of
https://github.com/linuxserver/Heimdall.git
synced 2025-12-12 09:53:49 +09:00
Updates to vendors etc
This commit is contained in:
30
vendor/symfony/http-foundation/InputBag.php
vendored
30
vendor/symfony/http-foundation/InputBag.php
vendored
@@ -25,17 +25,19 @@ final class InputBag extends ParameterBag
|
||||
* Returns a scalar input value by name.
|
||||
*
|
||||
* @param string|int|float|bool|null $default The default value if the input key does not exist
|
||||
*
|
||||
* @throws BadRequestException if the input contains a non-scalar value
|
||||
*/
|
||||
public function get(string $key, mixed $default = null): string|int|float|bool|null
|
||||
{
|
||||
if (null !== $default && !\is_scalar($default) && !$default instanceof \Stringable) {
|
||||
throw new \InvalidArgumentException(sprintf('Expected a scalar value as a 2nd argument to "%s()", "%s" given.', __METHOD__, get_debug_type($default)));
|
||||
throw new \InvalidArgumentException(\sprintf('Expected a scalar value as a 2nd argument to "%s()", "%s" given.', __METHOD__, get_debug_type($default)));
|
||||
}
|
||||
|
||||
$value = parent::get($key, $this);
|
||||
|
||||
if (null !== $value && $this !== $value && !\is_scalar($value) && !$value instanceof \Stringable) {
|
||||
throw new BadRequestException(sprintf('Input value "%s" contains a non-scalar value.', $key));
|
||||
throw new BadRequestException(\sprintf('Input value "%s" contains a non-scalar value.', $key));
|
||||
}
|
||||
|
||||
return $this === $value ? $default : $value;
|
||||
@@ -68,7 +70,7 @@ final class InputBag extends ParameterBag
|
||||
public function set(string $key, mixed $value): void
|
||||
{
|
||||
if (null !== $value && !\is_scalar($value) && !\is_array($value) && !$value instanceof \Stringable) {
|
||||
throw new \InvalidArgumentException(sprintf('Expected a scalar, or an array as a 2nd argument to "%s()", "%s" given.', __METHOD__, get_debug_type($value)));
|
||||
throw new \InvalidArgumentException(\sprintf('Expected a scalar, or an array as a 2nd argument to "%s()", "%s" given.', __METHOD__, get_debug_type($value)));
|
||||
}
|
||||
|
||||
$this->parameters[$key] = $value;
|
||||
@@ -83,6 +85,10 @@ final class InputBag extends ParameterBag
|
||||
* @param ?T $default
|
||||
*
|
||||
* @return ?T
|
||||
*
|
||||
* @psalm-return ($default is null ? T|null : T)
|
||||
*
|
||||
* @throws BadRequestException if the input cannot be converted to an enum
|
||||
*/
|
||||
public function getEnum(string $key, string $class, ?\BackedEnum $default = null): ?\BackedEnum
|
||||
{
|
||||
@@ -95,6 +101,8 @@ final class InputBag extends ParameterBag
|
||||
|
||||
/**
|
||||
* Returns the parameter value converted to string.
|
||||
*
|
||||
* @throws BadRequestException if the input contains a non-scalar value
|
||||
*/
|
||||
public function getString(string $key, string $default = ''): string
|
||||
{
|
||||
@@ -102,6 +110,10 @@ final class InputBag extends ParameterBag
|
||||
return (string) $this->get($key, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws BadRequestException if the input value is an array and \FILTER_REQUIRE_ARRAY or \FILTER_FORCE_ARRAY is not set
|
||||
* @throws BadRequestException if the input 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
|
||||
{
|
||||
$value = $this->has($key) ? $this->all()[$key] : $default;
|
||||
@@ -112,11 +124,11 @@ final class InputBag extends ParameterBag
|
||||
}
|
||||
|
||||
if (\is_array($value) && !(($options['flags'] ?? 0) & (\FILTER_REQUIRE_ARRAY | \FILTER_FORCE_ARRAY))) {
|
||||
throw new BadRequestException(sprintf('Input value "%s" contains an array, but "FILTER_REQUIRE_ARRAY" or "FILTER_FORCE_ARRAY" flags were not set.', $key));
|
||||
throw new BadRequestException(\sprintf('Input value "%s" contains an array, but "FILTER_REQUIRE_ARRAY" or "FILTER_FORCE_ARRAY" flags were not set.', $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;
|
||||
@@ -129,12 +141,6 @@ final class InputBag extends ParameterBag
|
||||
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 a "%s" in 7.0; '.$hint.' flag "FILTER_NULL_ON_FAILURE" to keep ignoring them.', $this::class, $method, $key, BadRequestException::class);
|
||||
|
||||
return false;
|
||||
throw new BadRequestException(\sprintf('Input value "%s" is invalid and flag "FILTER_NULL_ON_FAILURE" was not set.', $key));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user