Skip to content

Commit cfc4fbb

Browse files
ondrejmirtesclaude
andcommitted
Clear the type-operation memo only after the container's global state is installed
postInitializeContainer() cleared TypeCombinatorCache before building the typeSpecifier service and before setting BleedingEdgeToggle and ReportUnsafeArrayStringKeyCastingToggle. Extension constructors built during that service's creation can already run union()/intersect() — through ConstantArrayTypeBuilder::setOffsetValueType() they reach StringType's toggle read — so entries could be memoized under the previous container's state and survive the swap. Clearing last closes the window. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LVQhbBxDjDVAVeJVvLpWYE
1 parent d7a2e4d commit cfc4fbb

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

‎src/DependencyInjection/ContainerFactory.php‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,15 +201,17 @@ public static function postInitializeContainer(Container $container): void
201201
PhpVersionStaticAccessor::registerInstance($container->getByType(PhpVersion::class));
202202
ObjectType::resetCaches();
203203

204-
// Type operations read global state — the bleeding-edge toggle, the unsafe
205-
// array-string-key-casting level, the reflection provider, the PHP version — so a
206-
// memoized result is only valid for the state it was computed under.
207-
TypeCombinator::clearCache();
208-
209204
$container->getService('typeSpecifier');
210205

211206
BleedingEdgeToggle::setBleedingEdge($container->getParameter('featureToggles')['bleedingEdge']);
212207
ReportUnsafeArrayStringKeyCastingToggle::setLevel($container->getParameter('reportUnsafeArrayStringKeyCasting'));
208+
209+
// Type operations read global state — the toggles above, the reflection provider,
210+
// the PHP version — so a memoized result is only valid for the state it was computed
211+
// under. Clearing must be the LAST step: building the typeSpecifier service runs
212+
// extension constructors that can already perform type operations, and entries
213+
// memoized before the toggles are set would encode the previous container's state.
214+
TypeCombinator::clearCache();
213215
}
214216

215217
public function getCurrentWorkingDirectory(): string

0 commit comments

Comments
 (0)