Limitations¶
This page explains why friendsofmago/mago-symfony does not narrow or check specific Symfony patterns. Most boundaries come from Mago SDK limits or Symfony runtime rules where narrowing would hide real bugs.
Mago SDK boundaries¶
ContainerInterface::has()does not narrow a laterget(). Mago1.60.2through1.62.0narrows only parameter variables and$thisin invocation assertions. Because the container lookup key is a string argument,has('app.foo')cannot refine a laterget('app.foo').- Per-command return types for
getArgument()andgetOption(). Return-type providers cannot inspect the enclosingCommandclass. The extension validates argument and option names throughConsoleCommandArgumentsHookinstead of narrowing return types per command. - Class-level
#[AsEventListener]and#[AsMessageHandler]attributes. Mago1.60.2through1.62.0matches method attributes inregisterAttributedEntryPoint(). Class-level attributes that route to__invoke()stay deferred until the Mago SDK supports class-level attributed entry points.
Runtime semantics where narrowing would be unsound¶
SessionInterface::get(),InputBag::get(),Route::getDefault(), andFormConfigInterface::getOption(). The extension does not narrow these methods from their$defaultargument. At runtime, a storednullor configured value overrides the default, so assuming a non-null return type hides real nullability bugs.HandledStamp::getResult(). This method staysmixedbecause Symfony's compiled container XML does not record a message-to-handler return type graph.WrappedExceptionsInterface::getWrappedExceptions(). Narrowing applies only when the filter class isThrowableor aThrowablesubtype. Non-Throwablemarker interfaces keep Symfony'sThrowable[]return type so callers retainThrowablemethods.
Assumptions in narrowers¶
- Default console helpers.
ConsoleHelperReturnTypeProviderassumes your application does not remapformatter,debug_formatter,process, orquestionto unrelated helper classes. - Controller attributes.
ControllerAttributesReturnTypeProviderassumes the attribute map passed tosetController()matches its class keys. - Untracked
TreeBuildernodes on Symfony 6.4 and 7.2. When aNodeBuilderis not tracked back to a root node, it staysArrayNodeDefinition|null. An untrackedNodeDefinitionfalls back to Symfony's declaredend()return type.
Console command analysis scope¶
- Statically analyzable
configure()declarations only.ConsoleCommandArgumentsHookreads statically analyzableaddArgument(),addOption(), andsetDefinition()calls insideconfigure(), including array literals,new InputDefinition([...]), constants, and aliased imports. Dynamic registration loops or helper methods disable unknown-name reporting on that command to avoid false positives. - FrameworkBundle default options. When
Symfony\Bundle\FrameworkBundle\Console\Applicationis present in[source] includes,env,no-debug, andprofilecount as default options on everyCommandsubclass. Static metadata cannot tell whichApplicationclass runs a command. Excludevendor/symfony/framework-bundlefrom[source] includesin standalone Console projects to enforce plainApplicationdefaults.
APIs already typed by Symfony vendor signatures¶
The extension does not add duplicate providers for APIs that Mago already types accurately from Symfony 6.4 and 7.x vendor signatures:
Envelope::last()andEnvelope::all()Request::getContent()FileLocatorInterface::locate()EventDispatcherInterface::dispatch()CacheInterface::get()ValidatorInterface::validate()RouteCollection,FormView, and Twig helpers