Commit 39a4603
committed
feature #46279 [DependencyInjection] Optimize autowiring logic by telling it about excluded symbols (nicolas-grekas)
This PR was merged into the 6.2 branch.
Discussion
----------
[DependencyInjection] Optimize autowiring logic by telling it about excluded symbols
| Q | A
| ------------- | ---
| Branch? | 6.1
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| Tickets | -
| License | MIT
| Doc PR | -
Replaces symfony/symfony#46275
While inspecting the dumped container of the demo app, I noticed that it contains so-called "errored" services. They come e.g from entities that are used as type-hints on controllers. To compute those services, the autowiring logic currently loads all services looking for possible type-compatible candidates.
But here, we should know that those won't be found: they're excluded from being loaded.
Instead of completely ignoring excluded classes, this PR still registers them, but as abstract and with a special `container.excluded` tag.
This allows the rest of the compilation logic to skip+remove them, while allowing `AutowiringPass` to compute a better error message and way faster.
Here is the relevant part of a https://blackfire.io comparison:

Commits
-------
739789f384 [DependencyInjection] Optimize autowiring logic by telling it about excluded symbolsFile tree
2 files changed
+11
-0
lines changed- DependencyInjection/Compiler
- Resources/config
2 files changed
+11
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| 30 | + | |
29 | 31 | | |
| 32 | + | |
| 33 | + | |
30 | 34 | | |
31 | 35 | | |
32 | 36 | | |
| |||
218 | 222 | | |
219 | 223 | | |
220 | 224 | | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
221 | 231 | | |
222 | 232 | | |
0 commit comments