8000 minor #46936 Fix deprecation in `InputBag` for non-scalar values (fri… · symfony/symfony@f9e8317 · GitHub
[go: up one dir, main page]

Skip to content

Commit f9e8317

Browse files
committed
minor #46936 Fix deprecation in InputBag for non-scalar values (fritzmg, chalasr)
This PR was merged into the 5.4 branch. Discussion ---------- Fix deprecation in `InputBag` for non-scalar values | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | | License | MIT | Doc PR | In Symfony 6.0, `InputBag::get` was changed so that when you are retrieving a non-scalar value from it, it will throw a `BadRequestException`. This is also correctly documented in the UPGRADE.md. However, the deprecation in Symfony 5.4 assumes something different: it says that non-**string** values are deprecated. This PR fixes that. Commits ------- 6245bac Revert removal of Stringable check de23ac8 also fix the test 30444a8 fix deprecation
2 parents 9eca550 + 6245bac commit f9e8317

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/Symfony/Component/HttpFoundation/InputBag.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function get(string $key, $default = null)
3636
$value = parent::get($key, $this);
3737

3838
if (null !== $value && $this !== $value && !\is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) {
39-
trigger_deprecation('symfony/http-foundation', '5.1', 'Retrieving a non-string value from "%s()" is deprecated, and will throw a "%s" exception in Symfony 6.0, use "%s::all($key)" instead.', __METHOD__, BadRequestException::class, __CLASS__);
39+
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__);
4040
}
4141

4242
return $this === $value ? $default : $value;

src/Symfony/Component/HttpFoundation/Tests/InputBagTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ public function testSetWithNonScalarOrArrayIsDeprecated()
7272
/**
7373
* @group legacy
7474
*/
75-
public function testGettingANonStringValueIsDeprecated()
75+
public function testGettingANonScalarValueIsDeprecated()
7676
{
7777
$bag = new InputBag(['foo' => ['a', 'b']]);
78-
$this->expectDeprecation('Since symfony/http-foundation 5.1: Retrieving a non-string value from "Symfony\Component\HttpFoundation\InputBag::get()" is deprecated, and will throw a "Symfony\Component\HttpFoundation\Exception\BadRequestException" exception in Symfony 6.0, use "Symfony\Component\HttpFoundation\InputBag::all($key)" instead.');
78+
$this->expectDeprecation('Since symfony/http-foundation 5.1: Retrieving a non-scalar value from "Symfony\Component\HttpFoundation\InputBag::get()" is deprecated, and will throw a "Symfony\Component\HttpFoundation\Exception\BadRequestException" exception in Symfony 6.0, use "Symfony\Component\HttpFoundation\InputBag::all($key)" instead.');
7979
$bag->get('foo');
8080
}
8181

0 commit comments

Comments
 (0)
0