8000 Merge branch '2.3' into 2.7 · HeahDude/symfony@c6b6892 · GitHub
[go: up one dir, main page]

Skip to content

Commit c6b6892

Browse files
committed
Merge branch '2.3' into 2.7
* 2.3: fix debug toolbar rendering by removing inadvertently added links simplified code Allow variadic controller parameters to be resolved.
2 parents 41112c9 + 17e8780 commit c6b6892

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_item.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% if link|default(true) %}
1+
{% if link is not defined or link %}
22
{% set icon %}
33
<a href="{{ path('_profiler', { 'token': token, 'panel': name }) }}">{{ icon }}</a>
44
{% endset %}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,11 @@ protected function doGetArguments(Request $request, $controller, array $paramete
105105
$arguments = array();
106106
foreach ($parameters as $param) {
107107
if (array_key_exists($param->name, $attributes)) {
108-
$arguments[] = $attributes[$param->name];
108+
if (PHP_VERSION_ID >= 50600 && $param->isVariadic() && is_array($attributes[$param->name])) {
109+
$arguments = array_merge($arguments, array_values($attributes[$param->name]));
110+
} else {
111+
$arguments[] = $attributes[$param->name];
112+
}
109113
} elseif ($param->getClass() && $param->getClass()->isInstance($request)) {
110114
$arguments[] = $request;
111115
} elseif ($param->isDefaultValueAvailable()) {

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Psr\Log\LoggerInterface;
1515
use Symfony\Component\HttpKernel\Controller\ControllerResolver;
16+
use Symfony\Component\HttpKernel\Tests\Fixtures\Controller\VariadicController;
1617
use Symfony\Component\HttpFoundation\Request;
1718

1819
class ControllerResolverTest extends \PHPUnit_Framework_TestCase
@@ -197,6 +198,20 @@ public function testGetArguments()
197198
$this->assertEquals(array($request), $resolver->getArguments($request, $controller), '->getArguments() injects the request');
198199
}
199200

201+
/**
202+
* @requires PHP 5.6
203+
*/
204+
public function testGetVariadicArguments()
205+
{
206+
$resolver = new ControllerResolver();
207+
208+
$request = Request::create('/');
209+
$request->attributes->set('foo', 'foo');
210+
$request->attributes->set('bar', array('foo', 'bar'));
211+
$controller = array(new VariadicController(), 'action');
212+
$this->assertEquals(array('foo', 'foo', 'bar'), $resolver->getArguments($request, $controller));
213+
}
214+
200215
public function testCreateControllerCanReturnAnyCallable()
201216
{
202217
$mock = $this->getMock('Symfony\Component\HttpKernel\Controller\ControllerResolver', array('createController'));
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace Symfony\Component\HttpKernel\Tests\Fixtures\Controller;
4+
5+
class VariadicController
6+
{
7+
public function action($foo, ...$bar)
8+
{
9+
}
10+
}

0 commit comments

Comments
 (0)
0