mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-06 03:50:04 +02:00
Update composer
This commit is contained in:
parent
330cdbe615
commit
0c83c9a678
442 changed files with 9523 additions and 10793 deletions
87
vendor/symfony/http-foundation/InputBag.php
vendored
87
vendor/symfony/http-foundation/InputBag.php
vendored
|
@ -12,7 +12,6 @@
|
|||
namespace Symfony\Component\HttpFoundation;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Exception\BadRequestException;
|
||||
use Symfony\Component\HttpFoundation\Exception\UnexpectedValueException;
|
||||
|
||||
/**
|
||||
* InputBag is a container for user input values such as $_GET, $_POST, $_REQUEST, and $_COOKIE.
|
||||
|
@ -25,26 +24,36 @@ 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
|
||||
*
|
||||
* @return string|int|float|bool|null
|
||||
*/
|
||||
public function get(string $key, mixed $default = null): string|int|float|bool|null
|
||||
public function get(string $key, $default = 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)));
|
||||
if (null !== $default && !\is_scalar($default) && !(\is_object($default) && method_exists($default, '__toString'))) {
|
||||
trigger_deprecation('symfony/http-foundation', '5.1', 'Passing a non-scalar value as 2nd argument to "%s()" is deprecated, pass a scalar or null instead.', __METHOD__);
|
||||
}
|
||||
|
||||
$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));
|
||||
if (null !== $value && $this !== $value && !\is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) {
|
||||
trigger_deprecation('symfony/http-foundation', '5.1', 'Retrieving a non-scalar value from "%s()" is deprecated, and will throw a "%s" exception in Symfony 6.0, use "%s::all($key)" instead.', __METHOD__, BadRequestException::class, __CLASS__);
|
||||
}
|
||||
|
||||
return $this === $value ? $default : $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function all(?string $key = null): array
|
||||
{
|
||||
return parent::all($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the current input values by a new set.
|
||||
*/
|
||||
public function replace(array $inputs = []): void
|
||||
public function replace(array $inputs = [])
|
||||
{
|
||||
$this->parameters = [];
|
||||
$this->add($inputs);
|
||||
|
@ -53,7 +62,7 @@ final class InputBag extends ParameterBag
|
|||
/**
|
||||
* Adds input values.
|
||||
*/
|
||||
public function add(array $inputs = []): void
|
||||
public function add(array $inputs = [])
|
||||
{
|
||||
foreach ($inputs as $input => $value) {
|
||||
$this->set($input, $value);
|
||||
|
@ -65,44 +74,19 @@ final class InputBag extends ParameterBag
|
|||
*
|
||||
* @param string|int|float|bool|array|null $value
|
||||
*/
|
||||
public function set(string $key, mixed $value): void
|
||||
public function set(string $key, $value)
|
||||
{
|
||||
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)));
|
||||
if (null !== $value && !\is_scalar($value) && !\is_array($value) && !method_exists($value, '__toString')) {
|
||||
trigger_deprecation('symfony/http-foundation', '5.1', 'Passing "%s" as a 2nd Argument to "%s()" is deprecated, pass a scalar, array, or null instead.', get_debug_type($value), __METHOD__);
|
||||
}
|
||||
|
||||
$this->parameters[$key] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parameter value converted to an enum.
|
||||
*
|
||||
* @template T of \BackedEnum
|
||||
*
|
||||
* @param class-string<T> $class
|
||||
* @param ?T $default
|
||||
*
|
||||
* @return ?T
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getEnum(string $key, string $class, ?\BackedEnum $default = null): ?\BackedEnum
|
||||
{
|
||||
try {
|
||||
return parent::getEnum($key, $class, $default);
|
||||
} catch (UnexpectedValueException $e) {
|
||||
throw new BadRequestException($e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parameter value converted to string.
|
||||
*/
|
||||
public function getString(string $key, string $default = ''): string
|
||||
{
|
||||
// Shortcuts the parent method because the validation on scalar is already done in get().
|
||||
return (string) $this->get($key, $default);
|
||||
}
|
||||
|
||||
public function filter(string $key, mixed $default = null, int $filter = \FILTER_DEFAULT, mixed $options = []): mixed
|
||||
public function filter(string $key, $default = null, int $filter = \FILTER_DEFAULT, $options = [])
|
||||
{
|
||||
$value = $this->has($key) ? $this->all()[$key] : $default;
|
||||
|
||||
|
@ -112,29 +96,18 @@ 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));
|
||||
trigger_deprecation('symfony/http-foundation', '5.1', 'Filtering an array value with "%s()" without passing the FILTER_REQUIRE_ARRAY or FILTER_FORCE_ARRAY flag is deprecated', __METHOD__);
|
||||
|
||||
if (!isset($options['flags'])) {
|
||||
$options['flags'] = \FILTER_REQUIRE_ARRAY;
|
||||
}
|
||||
}
|
||||
|
||||
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)));
|
||||
trigger_deprecation('symfony/http-foundation', '5.2', 'Not passing a Closure together with FILTER_CALLBACK to "%s()" is deprecated. Wrap your filter in a closure instead.', __METHOD__);
|
||||
// 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;
|
||||
$nullOnFailure = $options['flags'] & \FILTER_NULL_ON_FAILURE;
|
||||
$options['flags'] |= \FILTER_NULL_ON_FAILURE;
|
||||
|
||||
$value = filter_var($value, $filter, $options);
|
||||
|
||||
if (null !== $value || $nullOnFailure) {
|
||||
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;
|
||||
return filter_var($value, $filter, $options);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue