Skip to content

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 later get(). Mago 1.60.2 through 1.62.0 narrows only parameter variables and $this in invocation assertions. Because the container lookup key is a string argument, has('app.foo') cannot refine a later get('app.foo').
  • Per-command return types for getArgument() and getOption(). Return-type providers cannot inspect the enclosing Command class. The extension validates argument and option names through ConsoleCommandArgumentsHook instead of narrowing return types per command.
  • Class-level #[AsEventListener] and #[AsMessageHandler] attributes. Mago 1.60.2 through 1.62.0 matches method attributes in registerAttributedEntryPoint(). 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(), and FormConfigInterface::getOption(). The extension does not narrow these methods from their $default argument. At runtime, a stored null or configured value overrides the default, so assuming a non-null return type hides real nullability bugs.
  • HandledStamp::getResult(). This method stays mixed because Symfony's compiled container XML does not record a message-to-handler return type graph.
  • WrappedExceptionsInterface::getWrappedExceptions(). Narrowing applies only when the filter class is Throwable or a Throwable subtype. Non-Throwable marker interfaces keep Symfony's Throwable[] return type so callers retain Throwable methods.

Assumptions in narrowers

  • Default console helpers. ConsoleHelperReturnTypeProvider assumes your application does not remap formatter, debug_formatter, process, or question to unrelated helper classes.
  • Controller attributes. ControllerAttributesReturnTypeProvider assumes the attribute map passed to setController() matches its class keys.
  • Untracked TreeBuilder nodes on Symfony 6.4 and 7.2. When a NodeBuilder is not tracked back to a root node, it stays ArrayNodeDefinition|null. An untracked NodeDefinition falls back to Symfony's declared end() return type.

Console command analysis scope

  • Statically analyzable configure() declarations only. ConsoleCommandArgumentsHook reads statically analyzable addArgument(), addOption(), and setDefinition() calls inside configure(), 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\Application is present in [source] includes, env, no-debug, and profile count as default options on every Command subclass. Static metadata cannot tell which Application class runs a command. Exclude vendor/symfony/framework-bundle from [source] includes in standalone Console projects to enforce plain Application defaults.

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() and Envelope::all()
  • Request::getContent()
  • FileLocatorInterface::locate()
  • EventDispatcherInterface::dispatch()
  • CacheInterface::get()
  • ValidatorInterface::validate()
  • RouteCollection, FormView, and Twig helpers