Skip to content

Commit 7940c6d

Browse files
committed
Retain $request->request InputBag type
1 parent 0965fc1 commit 7940c6d

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/Illuminate/Http/Request.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Illuminate\Support\Traits\Macroable;
1212
use RuntimeException;
1313
use Symfony\Component\HttpFoundation\Exception\SessionNotFoundException;
14+
use Symfony\Component\HttpFoundation\InputBag;
1415
use Symfony\Component\HttpFoundation\ParameterBag;
1516
use Symfony\Component\HttpFoundation\Request as SymfonyRequest;
1617
use Symfony\Component\HttpFoundation\Session\SessionInterface;
@@ -487,7 +488,7 @@ public static function createFromBase(SymfonyRequest $request)
487488
$newRequest->content = $request->content;
488489

489490
if ($newRequest->isJson()) {
490-
$newRequest->request = $newRequest->json();
491+
$newRequest->request = new InputBag($newRequest->json()->all());
491492
}
492493

493494
return $newRequest;

tests/Http/HttpRequestTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use RuntimeException;
1717
use Symfony\Component\HttpFoundation\Exception\SessionNotFoundException;
1818
use Symfony\Component\HttpFoundation\File\UploadedFile as SymfonyUploadedFile;
19+
use Symfony\Component\HttpFoundation\InputBag;
1920
use Symfony\Component\HttpFoundation\Request as SymfonyRequest;
2021
use Symfony\Component\HttpFoundation\Session\SessionInterface;
2122

@@ -1556,4 +1557,13 @@ public function testHttpRequestFlashExceptCallsFlashWithProperParameters()
15561557
$request->setLaravelSession($session);
15571558
$request->flashExcept(['email']);
15581559
}
1560+
1561+
public function testGeneratingJsonRequestFromParentRequestUsesCorrectType()
1562+
{
1563+
$base = SymfonyRequest::create('/', 'POST', server: ['CONTENT_TYPE' => 'application/json'], content: '{"hello":"world"}');
1564+
1565+
$request = Request::createFromBase($base);
1566+
1567+
$this->assertInstanceOf(InputBag::class, $request->getPayload());
1568+
}
15591569
}

0 commit comments

Comments
 (0)