Repository navigation
Commit fda77dc
LRU-cap resolved local type aliases in UsefulTypeAliasResolver
Every resolved @phpstan-type local alias is cached forever, keyed by
Class::alias. Resolved alias Types transitively pin ClassReflections
(ObjectType::$classReflection, EnumCaseObjectType::$classReflection, ...) and
through them whole BetterReflection trees, so on alias-heavy codebases this
cache quietly retains a large share of the reflection universe. Retention-path
instrumentation on a large project identified it as the single largest
type-level pin: bounding it freed 34 MB end-of-run memory at 2,358 analysed
files — more than any reflection-side cache — with byte-identical error
output and no measurable time cost (interleaved A/B, 100 s vs 95 s).
Cap the cache at 2048 entries with least-recently-used eviction; evicted
aliases are re-resolved on demand. Global aliases are unaffected (bounded by
config).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NrTvR9j1mW2NNNC8RkuTsF1 parent 6f72e96 commit fda77dc
1 file changed
Lines changed: 15 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
18 | 20 | | |
| 21 | + | |
| 22 | + | |
19 | 23 | | |
20 | 24 | | |
21 | 25 | | |
22 | | - | |
| 26 | + | |
23 | 27 | | |
24 | 28 | | |
25 | 29 | | |
| |||
81 | 85 | | |
82 | 86 | | |
83 | 87 | | |
84 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
85 | 93 | | |
86 | 94 | | |
87 | 95 | | |
| |||
120 | 128 | | |
121 | 129 | | |
122 | 130 | | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
123 | 136 | | |
124 | 137 | | |
125 | 138 | | |
| |||
0 commit comments