Commit cc7090f
committed
feature symfony#61765 [TypeInfo] Add result cache to
This PR was submitted for the 7.3 branch but it was merged into the 7.4 branch instead.
Discussion
----------
[TypeInfo] Add result cache to `TypeContextFactory`
| Q | A
| ------------- | ---
| Branch? | 7.4
| Bug fix? | no
| New feature? | no
| Deprecations? | no
| Issues | Fix symfony#61725
| License | MIT
Add caches to `TypeContextFactory` method to prevent multiple parsing of the same classes by PHPStan property extractor.
1. Add cache to intermediate `TypeContext` creation from `createFromClassName()` and `createFromReflection()` by adding:
- `intermediateTypeContextCache` proprety.
- `createIntermediateTypeContext()` create the intermediate `TypeContext` if not found in cache.
2. Add cache to `createFromClassName()` by:
- `typeContextCache` proprety.
- extracting `TypeContext` creation to private `createNewInstanceFromClassName()` method.
- refactoring `createFromClassName()` to get the `TypeContext` from `$this->typeContextCache`, or creating it by calling `createNewInstanceFromClassName()` method.
3. Add a test to check that the results are cached.
This optimize deserialization and form validation.
Commits
-------
e39963f [TypeInfo] Add result cache to TypeContextFactoryTypeContextFactory (landure)File tree
2 files changed
+50
-26
lines changed- src/Symfony/Component/TypeInfo
- Tests/TypeContext
- TypeContext
2 files changed
+50
-26
lines changedLines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
63 | 70 | | |
64 | 71 | | |
65 | 72 | | |
| |||
Lines changed: 43 additions & 26 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| |||
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
44 | 55 | | |
45 | 56 | | |
46 | 57 | | |
| |||
57 | 68 | | |
58 | 69 | | |
59 | 70 | | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
| 71 | + | |
80 | 72 | | |
81 | 73 | | |
82 | 74 | | |
| |||
94 | 86 | | |
95 | 87 | | |
96 | 88 | | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
| 89 | + | |
103 | 90 | | |
104 | 91 | | |
105 | 92 | | |
| |||
117 | 104 | | |
118 | 105 | | |
119 | 106 | | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
120 | 137 | | |
121 | 138 | | |
122 | 139 | | |
| |||
0 commit comments