Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug #23605 [DI][Bug] Autowiring thinks optional args on core classes …
…are required (weaverryan) This PR was merged into the 3.3 branch. Discussion ---------- [DI][Bug] Autowiring thinks optional args on core classes are required | Q | A | ------------- | --- | Branch? | 3,3 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | none | License | MIT | Doc PR | n/a Currently, the following fails: ```yml services: PDO: class: PDO arguments: - 'sqlite:/foo.db' ``` The error: > Cannot autowire service "PDO": argument "$username" of method "__construct()" must have a type-hint or be given a value explicitly `$username` is the second argument to `PDO`, and it's optional. Here's the reason: it appears that `$parameter->isDefaultValueAvailable()` returns false for optional arguments of core classes. But, `$parameter->isOptional()` returns true. This allows optional arguments to not throw an exception. I can't think of any edge cases this will cause - but it's possible I'm not thinking of something :). Cheers! Commits ------- 178a0f7 Fixing a bug where if a core class was autowired, autowiring tried to autowire optional args as if they were required
- Loading branch information