8000 Fix fetching array parameters from the InputBag on Symfony 6 (#40609) · laravel/framework@69e915f · GitHub
[go: up one dir, main page]

Skip to content

Commit 69e915f

Browse files
authored
Fix fetching array parameters from the InputBag on Symfony 6 (#40609)
1 parent a934887 commit 69e915f

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/Illuminate/Http/Concerns/InteractsWithInput.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Illuminate\Support\Facades\Date;
88
use SplFileInfo;
99
use stdClass;
10+
use Symfony\Component\HttpFoundation\InputBag;
1011
use Symfony\Component\VarDumper\VarDumper;
1112

1213
trait InteractsWithInput
@@ -507,6 +508,10 @@ protected function retrieveItem($source, $key, $default)
507508
return $this->$source->all();
508509
}
509510

511+
if ($this->$source instanceof InputBag) {
512+
return $this->$source->all()[$key] ?? $default;
513+
}
514+
510515
return $this->$source->get($key, $default);
511516
}
512517

tests/Http/HttpRequestTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,14 @@ public function testQueryMethod()
676676
$this->assertSame('Bob', $request->query('foo', 'Bob'));
677677
$all = $request->query(null);
678678
$this->assertSame('Taylor', $all['name']);
679+
680+
$request = Request::create('/', 'GET', ['hello' => 'world', 'user' => ['Taylor', 'Mohamed Said']]);
681+
$this->assertSame(['Taylor', 'Mohamed Said'], $request->query('user'));
682+
$this->assertSame(['hello' => 'world', 'user' => ['Taylor', 'Mohamed Said']], $request->query->all());
683+
684+
$request = Request::create('/?hello=world&user[]=Taylor&user[]=Mohamed%20Said', 'GET', []);
685+
$this->assertSame(['Taylor', 'Mohamed Said'], $request->query('user'));
686+
$this->assertSame(['hello' => 'world', 'user' => ['Taylor', 'Mohamed Said']], $request->query->all());
679687
}
680688

681689
public function testPostMethod()

0 commit comments

Comments
 (0)
0