Skip to content

Commit 5a5d397

Browse files
taylorotwellchalasr
authored andcommitted
[HttpFoundation] Allow null in InputBag@set
1 parent f930551 commit 5a5d397

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

InputBag.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ public function add(array $inputs = [])
7272
/**
7373
* Sets an input by name.
7474
*
75-
* @param string|array $value
75+
* @param string|array|null $value
7676
*/
7777
public function set(string $key, $value)
7878
{
79-
if (!is_scalar($value) && !\is_array($value) && !method_exists($value, '__toString')) {
80-
trigger_deprecation('symfony/http-foundation', '5.1', 'Passing "%s" as a 2nd Argument to "%s()" is deprecated, pass a string or an array instead.', get_debug_type($value), __METHOD__);
79+
if (null !== $value && !is_scalar($value) && !\is_array($value) && !method_exists($value, '__toString')) {
80+
trigger_deprecation('symfony/http-foundation', '5.1', 'Passing "%s" as a 2nd Argument to "%s()" is deprecated, pass a string, array, or null instead.', get_debug_type($value), __METHOD__);
8181
}
8282

8383
$this->parameters[$key] = $value;

Tests/InputBagTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function testFilterArray()
5151
public function testSetWithNonStringishOrArrayIsDeprecated()
5252
{
5353
$bag = new InputBag();
54-
$this->expectDeprecation('Since symfony/http-foundation 5.1: Passing "Symfony\Component\HttpFoundation\InputBag" as a 2nd Argument to "Symfony\Component\HttpFoundation\InputBag::set()" is deprecated, pass a string or an array instead.');
54+
$this->expectDeprecation('Since symfony/http-foundation 5.1: Passing "Symfony\Component\HttpFoundation\InputBag" as a 2nd Argument to "Symfony\Component\HttpFoundation\InputBag::set()" is deprecated, pass a string, array, or null instead.');
5555
$bag->set('foo', new InputBag());
5656
}
5757

0 commit comments

Comments
 (0)