题
我要解决一个问题,但真的不明白为什么!
启动Symfony(通过前控制器或CLI)时,我会遇到此错误
PHP Fatal error: Declaration of ECommerceKernel::registerContainerConfiguration() must be compatible with that of Symfony\Framework\Kernel::registerContainerConfiguration()
问题是登记册的覆盖方法的覆盖方法。
它的签名是在Symfony Framework kernel中定义的:
abstract public function registerContainerConfiguration(LoaderInterface $loader);
我的覆盖方法看起来像这样:
// 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;
}
我的问题:这里到底发生了什么?我真的无法理解错误,因为方法签名完全相同。
这发生在SRV/供应商/Symfony升级到最新的Github的Symfony/Symfony之后。
解决方案
我有!
抱歉,噪音,但我只是发现了我的错误。
LoaderInterface $加载程序上制作的类型提示必须是
Symfony\Component\DependencyInjection\Loader\LoaderInterface;
我正在使用
Symfony\Components\DependencyInjection\Loader\LoaderInterface
此问题从那以后出现 http://github.com/symfony/symfony/commit/BF82CF42DDA099F8C0B6648B7DBD8E8EA7397C1E
对我感到羞耻,因为我知道这一点(已经宣布了Symfony-Devs列表)。
问题在于,当您尝试使用不隔离类时,PHP解释者不会警告您。
也许我错过了什么?
不隶属于 StackOverflow