Question

I'm encoutering a problem, but really don't understand why!

I get this error when launching Symfony ( via front controller or CLI )

PHP Fatal error:  Declaration of ECommerceKernel::registerContainerConfiguration() must be compatible with that of Symfony\Framework\Kernel::registerContainerConfiguration()

The problem is the override of the registerContainerConfiguration method.

It's signature is defined in Symfony\Framework\Kernel:

abstract public function registerContainerConfiguration(LoaderInterface $loader);

my overwritten method looks like this:

// in ECommerceKernel
public function registerContainerConfiguration(LoaderInterface $loader)
{
    $return = $loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml');

    $em = $this->getContainer()->getDoctrine_Orm_EntityManagerService();
    $dm = $this->getContainer()->getDoctrine_Odm_Mongodb_DocumentManagerService();

    $eventManager = $em->getEventManager();
    $eventManager->addEventListener(
        array(\Doctrine\ORM\Events::postLoad), new ECommerceEventSubscriber($dm)
    );

    return $return;
}

My question: What is really happening here? I really can't understand the error because the method signatures are exactly the same.

This happened after a srv/vendor/symfony upgrade to the latest github's symfony/symfony.

Was it helpful?

Solution

Here I have it!

Sorry for the noise, but I just discovered my mistake.

The type hinting made on LoaderInterface $loader must be a

Symfony\Component\DependencyInjection\Loader\LoaderInterface;

and I was using a

Symfony\Components\DependencyInjection\Loader\LoaderInterface

The problem appeared since http://github.com/symfony/symfony/commit/bf82cf42dda099f8c0b6648b7dbd8e8ea7397c1e

Shame on me, cause I was aware of this ( it has been announced int the symfony-devs list ).

the problem is that PHP interpretr doesn't warn you when you try to use an inexisiting class.

Or maybe I missed something ?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top