Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug #24600 [HttpKernel] Don't bind scalar values to controller method…
… arguments (yceruto) This PR was merged into the 3.4 branch. Discussion ---------- [HttpKernel] Don't bind scalar values to controller method arguments | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #24555 (comment) | License | MIT | Doc PR | - See linked issue. Let's suppose we have this configuration: ```yaml services: _defaults: # ... bind: $foo: '%foobar%' ``` `$foo` was successfully bound to any controller constructor, but in another controller I have this edit action (nothing to do with the intention of bind such a parameter, but it has the same name): ```php /** * @route("/{foo}/edit") */ public function editAction(string $foo) {} ``` triggering: > Type error: Argument 1 passed to Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument::__construct() must be an instance of Symfony\Component\DependencyInjection\Reference, string given, called in /home/yceruto/github/symfony/symfony-demo/vendor/symfony/dependency-injection/Compiler/ServiceLocatorTagPass.php on line 81 or after #24582: > Invalid service locator definition: only services can be referenced, "string" found for key "foo". Inject parameter values using constructors instead. Commits ------- a1df9af don't bind scalar values to controller method arguments
- Loading branch information