Skip to content
This repository was archived by the owner on Jun 4, 2025. It is now read-only.

Commit 68d7262

Browse files
committed
Cast setQuery() and setPost() parameters to arrays
1 parent fc55874 commit 68d7262

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/Request.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,12 @@ public function getQuery(string $name = null)
321321
*/
322322
public function setQuery(array $query) : Request
323323
{
324-
$this->query = $query;
325324
$this->queryString = http_build_query($query);
326325

326+
// Ensure that we get a value for getQuery() that's consistent with the query string, and whose scalar values
327+
// have all been converted to strings, to get a result similar to what we'd get with an incoming HTTP request.
328+
parse_str($this->queryString, $this->query);
329+
327330
$this->requestUri = $this->path;
328331

329332
if ($this->queryString !== '') {
@@ -362,7 +365,9 @@ public function getPost(string $name = null)
362365
*/
363366
public function setPost(array $post) : Request
364367
{
365-
$this->post = $post;
368+
// Ensure that we get a value for getQuery() that's consistent with the query string, and whose scalar values
369+
// have all been converted to strings, to get a result similar to what we'd get with an incoming HTTP request.
370+
parse_str(http_build_query($post), $this->post);
366371

367372
if (! $this->isContentType('multipart/form-data')) {
368373
$body = http_build_query($post);

0 commit comments

Comments
 (0)