Skip to content

Commit

Permalink
Retain $request->request InputBag type
Browse files Browse the repository at this point in the history
  • Loading branch information
timacdonald committed Jul 26, 2023
1 parent 0965fc1 commit e0f94d6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Illuminate/Http/Request.php
Expand Up @@ -11,6 +11,7 @@
use Illuminate\Support\Traits\Macroable;
use RuntimeException;
use Symfony\Component\HttpFoundation\Exception\SessionNotFoundException;
use Symfony\Component\HttpFoundation\InputBag;
use Symfony\Component\HttpFoundation\ParameterBag;
use Symfony\Component\HttpFoundation\Request as SymfonyRequest;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
Expand Down Expand Up @@ -487,7 +488,7 @@ public static function createFromBase(SymfonyRequest $request)
$newRequest->content = $request->content;

if ($newRequest->isJson()) {
$newRequest->request = $newRequest->json();
$newRequest->request = new InputBag($newRequest->json()->all());
}

return $newRequest;
Expand Down
14 changes: 14 additions & 0 deletions tests/Http/HttpRequestTest.php
Expand Up @@ -16,6 +16,7 @@
use RuntimeException;
use Symfony\Component\HttpFoundation\Exception\SessionNotFoundException;
use Symfony\Component\HttpFoundation\File\UploadedFile as SymfonyUploadedFile;
use Symfony\Component\HttpFoundation\InputBag;
use Symfony\Component\HttpFoundation\Request as SymfonyRequest;
use Symfony\Component\HttpFoundation\Session\SessionInterface;

Expand Down Expand Up @@ -1556,4 +1557,17 @@ public function testHttpRequestFlashExceptCallsFlashWithProperParameters()
$request->setLaravelSession($session);
$request->flashExcept(['email']);
}

public function testGeneratingJsonRequestFromParentRequestUsesCorrectType()
{
if (! method_exists(SymfonyRequest::class, 'getPayload')) {
return;
}

$base = SymfonyRequest::create('/', 'POST', server: ['CONTENT_TYPE' => 'application/json'], content: '{"hello":"world"}');

$request = Request::createFromBase($base);

$this->assertInstanceOf(InputBag::class, $request->getPayload());
}
}

0 comments on commit e0f94d6

Please sign in to comment.