# Lifecycle and entry points

`SymfonyPlugin` informs Mago about Symfony lifecycle initializers, `#[Required]` dependency injection properties, and framework method entry points.

## Class initializers

When you enable `[analyzer] check-property-initialization = true` in `mago.toml`, Mago treats properties assigned inside these methods as initialized:

- `Symfony\Bundle\FrameworkBundle\Controller\AbstractController::setContainer()`
- `Symfony\Component\Console\Command\Command::initialize()`
- `Symfony\Component\Validator\ConstraintValidator::initialize()`
- `Symfony\Component\Console\Helper\InputAwareHelper::setInput()`
- Any method marked with `#[Symfony\Contracts\Service\Attribute\Required]`

On Mago `1.62.0` and newer, `SymfonyPlugin` registers these declaratively via `registerClassInitializer()` and `registerAttributedClassInitializer()`. On Mago `1.60.2` through `1.61.x`, it falls back to `RequiredInitializerProvider`, which matches public non-static `#[Required]` methods.

## Public \#\[Required\] property injection

Symfony's `AutowireRequiredPropertiesPass` injects public writable properties marked with `#[Symfony\Contracts\Service\Attribute\Required]`.

`RequiredPropertyIssueFilter` suppresses `uninitialized-property` and `missing-constructor` diagnostics for a property when all of these conditions hold:

- The property has public read visibility and public write visibility.
- The property is not `readonly`, not `static`, and not virtual.
- The property carries `#[Symfony\Contracts\Service\Attribute\Required]`.
- The property has a single native named type. Nullable `?T` is allowed, while unions and intersections are excluded.
- Either the type is a class or interface (excluding traits and enums), or the property also carries `#[Symfony\Component\DependencyInjection\Attribute\Autowire]` or a subclass of it.

For `missing-constructor`, the filter suppresses the diagnostic only when every uninitialized property reported on the class satisfies those rules.

## Method-level entry points

When you enable `[analyzer] find-unused-definitions = true` in `mago.toml`, `SymfonyPlugin` registers framework callbacks as entry points so Mago does not report them as unused.

### Attributed methods

The plugin registers methods carrying any of these attributes as entry points:

- `Symfony\Component\Routing\Attribute\Route`
- `Symfony\Component\Routing\Annotation\Route`
- `Symfony\Component\EventDispatcher\Attribute\AsEventListener`
- `Symfony\Component\Messenger\Attribute\AsMessageHandler`
- `Symfony\Component\Validator\Constraints\Callback`

### Framework lifecycle overrides

The plugin registers these base class and interface methods as entry points:

| Class or interface | Methods |
| --- | --- |
| `Symfony\Component\Console\Command\Command` | `configure`, `initialize`, `interact`, `execute` |
| `Symfony\Component\Form\AbstractType` | `buildForm`, `buildView`, `finishView`, `configureOptions` |
| `Symfony\Component\Validator\ConstraintValidator` | `initialize`, `validate` |
| `Symfony\Component\Security\Core\Authorization\Voter\Voter` | `supports`, `voteOnAttribute` |
| `Symfony\Component\Config\Definition\ConfigurationInterface` | `getConfigTreeBuilder` |
| `Symfony\Component\DependencyInjection\Extension\ExtensionInterface` | `load` |
| `Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface` | `process` |
| `Symfony\Component\EventDispatcher\EventSubscriberInterface` | `getSubscribedEvents` |
| `Symfony\Contracts\Service\ServiceSubscriberInterface` | `getSubscribedServices` |
