Skip to content

Commit

Permalink
don't bind scalar values to controller method arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
yceruto committed Oct 18, 2017
1 parent f35996d commit a1df9af
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Expand Up @@ -135,6 +135,11 @@ public function process(ContainerBuilder $container)
$binding = $bindings[$bindingName];

list($bindingValue, $bindingId) = $binding->getValues();

if (!$bindingValue instanceof Reference) {
continue;
}

$binding->setValues(array($bindingValue, $bindingId, true));
$args[$p->name] = $bindingValue;

Expand Down
Expand Up @@ -310,6 +310,22 @@ public function provideBindings()
{
return array(array(ControllerDummy::class), array('$bar'));
}

public function testDoNotBindScalarValueToControllerArgument()
{
$container = new ContainerBuilder();
$resolver = $container->register('argument_resolver.service')->addArgument(array());

$container->register('foo', ArgumentWithoutTypeController::class)
->setBindings(array('$someArg' => '%foo%'))
->addTag('controller.service_arguments');

$pass = new RegisterControllerArgumentLocatorsPass();
$pass->process($container);

$locator = $container->getDefinition((string) $resolver->getArgument(0))->getArgument(0);
$this->assertEmpty($locator);
}
}

class RegisterTestController
Expand Down

0 comments on commit a1df9af

Please sign in to comment.