具有接口和类型提示的 Doctrine2 实体


Doctrine2 entity with interface and type hinting

当我构建一个函数并想要键入提示参数时,它是一个实现给定接口的实体,我收到这样的错误:

AddToFavorite::AddToFavorite() must be an instance of Trendmed'Interfaces'Favoriteable, instance of Proxy'__CG__'Trendmed'Entity'Clinic given

当然,我的实体正在实现给定的接口。

我认为这是因为 Doctrine 代理类不直接实现实体类所做的接口,因此禁止我使用正确的接口类型提示。你对这个问题有什么解决方案吗?

我刚刚找到了这个线程,并且会添加这个,因为其他人可能会看。
将 Use 放在顶部,不要在函数 def 中使用完整的命名空间。