Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
Commitadeab15
committed
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/aCurrently, the following fails:```ymlservices: 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 requiredFile tree
2 files changed
+23
-0
lines changed- src/Symfony/Component/DependencyInjection
- Compiler
- Tests/Compiler
2 files changed
+23
-0
lines changedLines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
273 | 273 | | |
274 | 274 | | |
275 | 275 | | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
276 | 282 | | |
277 | 283 | | |
278 | 284 | | |
| |||
Lines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
512 | 512 | | |
513 | 513 | | |
514 | 514 | | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
515 | 532 | | |
516 | 533 | | |
517 | 534 | | |
| |||
0 commit comments
Comments
(0)