Skip to content

Commit bedcb15

Browse files
committed
simplified code
1 parent f39afc8 commit bedcb15

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,9 @@ protected function doGetArguments(Request $request, $controller, array $paramete
117117
{
118118
$attributes = $request->attributes->all();
119119
$arguments = array();
120-
$variadicAvailable = method_exists('\ReflectionMethod', 'isVariadic');
121120
foreach ($parameters as $param) {
122121
if (array_key_exists($param->name, $attributes)) {
123-
if ($variadicAvailable && $param->isVariadic() && is_array($attributes[$param->name])) {
122+
if (PHP_VERSION_ID >= 50600 && $param->isVariadic() && is_array($attributes[$param->name])) {
124123
$arguments = array_merge($arguments, array_values($attributes[$param->name]));
125124
} else {
126125
$arguments[] = $attributes[$param->name];

src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,12 +205,10 @@ public function testGetVariadicArguments()
205205
$resolver = new ControllerResolver();
206206

207207
$request = Request::create('/');
208-
$param1 = new \stdClass();
209-
$param2 = new \stdClass();
210208
$request->attributes->set('foo', 'foo');
211-
$request->attributes->set('bar', array($param1, $param2));
209+
$request->attributes->set('bar', array('foo', 'bar'));
212210
$controller = array(new VariadicController(), 'action');
213-
$this->assertEquals(array('foo', $param1, $param2), $resolver->getArguments($request, $controller));
211+
$this->assertEquals(array('foo', 'foo', 'bar'), $resolver->getArguments($request, $controller));
214212
}
215213

216214
public function testCreateControllerCanReturnAnyCallable()

src/Symfony/Component/HttpKernel/Tests/Fixtures/Controller/VariadicController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
class VariadicController
66
{
7-
public function action($foo,...$bar)
7+
public function action($foo, ...$bar)
88
{
99
}
1010
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy