You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Type Symfony container get() results from the compiled container's id → class map #694
$container->get(Foo::class) in Symfony apps returns an untyped object. Every call on the result goes through dynamic dispatch. symfony-app has many of these on the request path.
The docblock can't help: ContainerInterface::get declares @return ($id is class-string<C> ? C|object : …). Read faithfully, C|object is object. The template binding from #686 / PR #691 correctly refuses to narrow it. Narrowing it to C would throw TypeError where php accepts any object.
Idea
The compiled container (var/cache/*/Container*.php) knows every service: the id, the factory method and the concrete class it builds. In a full-program build that map is static.
Use it at the call site. When the receiver is the compiled container class (or its interface), the id is a constant string that maps to class X, and the service isn't synthetic or replaced at runtime, type the result obj<X>. Keep the same instanceof + TypeError guard as the template rewrite, so a wrong map can only fail loudly, never silently.
Acceptance
symfony-app: get(<const id>) sites that resolve through the map are rewritten. Report the site count, IR lines and binary size against the base.
symfony-demo pages stay byte-identical to php.
No behaviour change for unknown ids, dynamic ids or set()-replaced services.
Context
Follow-up to #686 (PR #691, P4 of the semantic-core plan).
Activity