我一直在使用Silex(最初爲1.3)的SimpleUser(https://github.com/jasongrimes/silex-simpleuser)插件。我正在將我的應用程序升級到Silex 2.0。 SimpleUser中的UserProviderInterface實現了ServiceProviderInterface和ControllerProviderInterface。前者現在在Pimple中被定義爲不在Silex中,因爲它在1.3中,並且其註冊方法的參數是Pimple容器而不是Silex應用程序(它擴展了Pimple容器類)。 PHPStorm將此標記爲PHP致命錯誤(聲明必須與ServiceProviderInterface - > register(pimple:\ Pimple \ Container)兼容)。我不確定PHPStorm中的支票是否太簡單,或者這是一個嚴重的問題。
其他帖子指出,你不能簡單地覆蓋接口定義(Can you override interface methods with different, but "compatible", signatures?)(也http://php.net/manual/en/language.oop5.interfaces.php)。
我剛剛解決了我的問題。 Silex 2.0 Provider註釋表明您可以使用Container $ app作爲參數實現註冊方法,其中$ app是Silex \ Application實例。 PHPStorm不再反對UserServiceProvider中的註冊方法。如果有人遇到此問題,我會繼續發佈此信息。
好問題,好研究,好答案!用一個具體的例子來更新你的問題可能是一個想法,並提供一個合適的「答案」。 –