This PR was squashed before being merged into the 5.2-dev branch.
Discussion
----------
Fix #37740: Cast all Request parameter values to string
| Q | A
| ------------- | ---
| Branch? | 5.1
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | Fix #37740| License | MIT
This fix ensures that all parameter values in Browserkit\Request are received as strings on the receiving end.
Commits
-------
d4e2cec1fb
Fix #37740: Cast all Request parameter values to string
This commit is contained in:
commit
6539a0fc2f
@ -37,6 +37,11 @@ class Request
|
||||
{
|
||||
$this->uri = $uri;
|
||||
$this->method = $method;
|
||||
|
||||
array_walk_recursive($parameters, static function (&$value) {
|
||||
$value = (string) $value;
|
||||
});
|
||||
|
||||
$this->parameters = $parameters;
|
||||
$this->files = $files;
|
||||
$this->cookies = $cookies;
|
||||
|
@ -51,4 +51,24 @@ class RequestTest extends TestCase
|
||||
$request = new Request('http://www.example.com/', 'get', [], [], [], ['foo' => 'bar']);
|
||||
$this->assertEquals(['foo' => 'bar'], $request->getServer(), '->getServer() returns the server parameters of the request');
|
||||
}
|
||||
|
||||
public function testAllParameterValuesAreConvertedToString(): void
|
||||
{
|
||||
$parameters = [
|
||||
'foo' => 1,
|
||||
'bar' => [
|
||||
'baz' => 2,
|
||||
],
|
||||
];
|
||||
|
||||
$expected = [
|
||||
'foo' => '1',
|
||||
'bar' => [
|
||||
'baz' => '2',
|
||||
],
|
||||
];
|
||||
|
||||
$request = new Request('http://www.example.com/', 'get', $parameters);
|
||||
$this->assertSame($expected, $request->getParameters());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user