Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.5] Allow passing keys to Request::all() to behave like old Request::only() #18754

merged 1 commit into from Apr 10, 2017
Show file tree
Hide file tree
Changes from all commits
File filter

Filter by extension

Filter by extension

Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -117,9 +117,21 @@ protected function isEmptyString($key)
* @return array

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick question, why the docblock is not updated?

public function all()
public function all($keys = null)
return array_replace_recursive($this->input(), $this->allFiles());
$input = array_replace_recursive($this->input(), $this->allFiles());

if (! $keys) {
return $input;

$results = [];

foreach (is_array($keys) ? $keys : func_get_args() as $key) {
Arr::set($results, $key, Arr::get($input, $key));

return $results;

@@ -243,6 +243,21 @@ public function testInputMethod()
$this->assertInstanceOf('Symfony\Component\HttpFoundation\File\UploadedFile', $request['file']);

public function testAllMethod()
$request = Request::create('/', 'GET', ['name' => 'Taylor', 'age' => null]);
$this->assertEquals(['name' => 'Taylor', 'age' => null, 'email' => null], $request->all('name', 'age', 'email'));
$this->assertEquals(['name' => 'Taylor'], $request->all('name'));
$this->assertEquals(['name' => 'Taylor', 'age' => null], $request->all());

$request = Request::create('/', 'GET', ['developer' => ['name' => 'Taylor', 'age' => null]]);
$this->assertEquals(['developer' => ['name' => 'Taylor', 'skills' => null]], $request->all('', 'developer.skills'));
$this->assertEquals(['developer' => ['name' => 'Taylor', 'skills' => null]], $request->all(['', 'developer.skills']));
$this->assertEquals(['developer' => ['age' => null]], $request->all('developer.age'));
$this->assertEquals(['developer' => ['skills' => null]], $request->all('developer.skills'));
$this->assertEquals(['developer' => ['name' => 'Taylor', 'age' => null]], $request->all());

public function testOnlyMethod()
$request = Request::create('/', 'GET', ['name' => 'Taylor', 'age' => null]);