PHP-DI / Silex-Bridge

PHP-DI integration in Silex
http://php-di.org/doc/frameworks/silex.html
MIT License
24 stars 8 forks source link

ControllerResolver fails when parameter with default value is not provided #23

Closed felixfbecker closed 7 years ago

felixfbecker commented 7 years ago

A controller like this:

$app->get('/hello/{world}', function (string $world = 'world') {

});

should work with this request:

GET /hello

but fails with

Controller requires that you provide a value for the "$world" argument.

This is because the ResolverChain used for resolving the controller parameters does not include a DefaultValueResolver:

https://github.com/PHP-DI/Silex-Bridge/blob/master/src/Application.php#L77

mnapoli commented 7 years ago

:+1: I don't remember if there's a reason for that, but my reasoning would be: if it doesn't break any test then it's safe to add the DefaultValueResolver ;)

mnapoli commented 7 years ago

Thank you for the PR, I've tagged 1.5.2