Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 68d5e0d

Browse files
committed
bug #20756 [3.1][HttpKernel] Regression test for missing controller arguments (iltar)
This PR was merged into the 3.1 branch. Discussion ---------- [3.1][HttpKernel] Regression test for missing controller arguments | Q | A | ------------- | --- | Branch? | 3.1 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #20746 | License | MIT | Doc PR | ~ Same fix as #20755 but for 3.1 and up as the new feature was hit by the same bug. ping @fabpot Commits ------- 9e588b8 Regression test for missing controller arguments (3.1)
2 parents b699e4b + 9e588b8 commit 68d5e0d

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/DefaultValueResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ final class DefaultValueResolver implements ArgumentValueResolverInterface
2727
*/
2828
public function supports(Request $request, ArgumentMetadata $argument)
2929
{
30-
return $argument->hasDefaultValue() || ($argument->isNullable() && !$argument->isVariadic());
30+
return $argument->hasDefaultValue() || (null !== $argument->getType() && $argument->isNullable() && !$argument->isVariadic());
3131
}
3232

3333
/**

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,17 @@ public function testGetArgumentWithoutArray()
203203
$resolver->getArguments($request, $controller);
204204
}
205205

206+
/**
207+
* @expectedException \RuntimeException
208+
*/
209+
public function testIfExceptionIsThrownWhenMissingAnArgument()
210+
{
211+
$request = Request::create('/');
212+
$controller = array($this, 'controllerWithFoo');
213+
214+
self::$resolver->getArguments($request, $controller);
215+
}
216+
206217
/**
207218
* @requires PHP 7.1
208219
*/

0 commit comments

Comments
 (0)