8000 [DoctrineBridge] DoctrineLoader relies on AutoMappingTrait · Issue #41796 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
[DoctrineBridge] DoctrineLoader relies on AutoMappingTrait #41796
Closed
@m-vo

Description

@m-vo

Symfony version(s) affected: >= 4.4

Description
DoctrineExtension#loadValidatorLoader registers the DoctrineLoader as a service. This class uses the Symfony\Component\Validator\Mapping\Loader\AutoMappingTrait which might not be available.

As soon as this service gets autloaded at container build time* this will produce a fatal error under PHP8.1:

PHP Fatal error:  During class fetch: Uncaught ReflectionException: Class "Symfony\Component\Validator\Mapping\Loader\AutoMappingTrait" not found while loading "Symfony\Bridge\Doctrine\Validator\DoctrineLoader`

*) one scenario is for instance reading class annotations/attributes and thereby calling $container->getReflectionClass()

How to reproduce

  1. Set up a Sf application with doctrine-bundle installed.
  2. Add a compiler pass that does the following:
    foreach ($container->getDefinitions() as $definition) {
      $container->getReflectionClass($definition->getClass(), false);
    }
  3. Build the container.

This reminded me a bit of #32395. 🙂 Maybe we could mark the service as synthetic if the AutoMappingTrait is not available or register a dummy instead?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0