8000 Fix #37740: Cast all Request parameter values to string · jeremyFreeAgent/symfony@d4e2cec · GitHub
[go: up one dir, main page]

Skip to content

Commit d4e2cec

Browse files
Randy Geraadsfabpot
Randy Geraads
authored andcommitted
Fix symfony#37740: Cast all Request parameter values to string
1 parent c23166c commit d4e2cec

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/Symfony/Component/BrowserKit/Request.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ public function __construct(string $uri, string $method, array $parameters = [],
3737
{
3838
$this->uri = $uri;
3939
$this->method = $method;
40+
41+
array_walk_recursive($parameters, static function (&$value) {
42+
$value = (string) $value;
43+
});
44+
4045
$this->parameters = $parameters;
4146
$this->files = $files;
4247
$this->cookies = $cookies;

src/Symfony/Component/BrowserKit/Tests/RequestTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,24 @@ public function testGetServer()
5151
$request = new Request('http://www.example.com/', 'get', [], [], [], ['foo' => 'bar']);
5252
$this->assertEquals(['foo' => 'bar'], $request->getServer(), '->getServer() returns the server parameters of the request');
5353
}
54+
55+
public function testAllParameterValuesAreConvertedToString(): void
56+
{
57+
$parameters = [
58+
'foo' => 1,
59+
'bar' => [
60+
'baz' => 2,
61+
],
62+
];
63+
64+
$expected = [
65+
'foo' => '1',
66+
'bar' => [
67+
'baz' => '2',
68+
],
69+
];
70+
71+
$request = new Request('http://www.example.com/', 'get', $parameters);
72+
$this->assertSame($expected, $request->getParameters());
73+
}
5474
}

0 commit comments

Comments
 (0)
0