diff --git a/src/Illuminate/Http/Concerns/InteractsWithInput.php b/src/Illuminate/Http/Concerns/InteractsWithInput.php index cc391885bd46..7e20f5d23010 100644 --- a/src/Illuminate/Http/Concerns/InteractsWithInput.php +++ b/src/Illuminate/Http/Concerns/InteractsWithInput.php @@ -94,11 +94,13 @@ public function has($key) /** * Determine if the request contains any of the given inputs. * - * @param dynamic $key + * @param string|array $key * @return bool */ - public function hasAny(...$keys) + public function hasAny($keys) { + $keys = is_array($keys) ? $keys : func_get_args(); + $input = $this->all(); foreach ($keys as $key) { diff --git a/tests/Http/HttpRequestTest.php b/tests/Http/HttpRequestTest.php index 60f77010933d..7e59352bb881 100644 --- a/tests/Http/HttpRequestTest.php +++ b/tests/Http/HttpRequestTest.php @@ -262,15 +262,18 @@ public function testHasAnyMethod() $this->assertTrue($request->hasAny('city')); $this->assertFalse($request->hasAny('foo')); $this->assertTrue($request->hasAny('name', 'email')); + $this->assertTrue($request->hasAny(['name', 'email'])); $request = Request::create('/', 'GET', ['name' => 'Taylor', 'email' => 'foo']); $this->assertTrue($request->hasAny('name', 'email')); $this->assertFalse($request->hasAny('surname', 'password')); + $this->assertFalse($request->hasAny(['surname', 'password'])); $request = Request::create('/', 'GET', ['foo' => ['bar' => null, 'baz' => '']]); $this->assertTrue($request->hasAny('foo.bar')); $this->assertTrue($request->hasAny('foo.baz')); $this->assertFalse($request->hasAny('foo.bax')); + $this->assertTrue($request->hasAny(['foo.bax', 'foo.baz'])); } public function testFilledMethod()