php - 运行时通知 : Declaration of in symfony2

标签 php symfony error-handling

我开发到不同的系统。其中一个使用 PHP 5.4,另一个我使用 PHP 5.5.9 版本。

如果我用 5.4 版本打开我的项目,一切都很好,并且没有错误报告。但是如果我尝试使用 PHP 5.5.9 打开同一个项目,我会收到以下错误并且 symfony 停止:

ContextErrorException: Runtime Notice: Declaration of Event\UserBundle\Manager\EventManager::getRepository() should be compatible with Event\UserBundle\Manager\AbstractManager::getRepository($entity = NULL) in ...



现在我读到php严格警告会产生这个错误。但在我的 PHP.ini 错误设置中是这样的:
E_ALL & ~E_DEPRECATED & ~E_STRICT
任何人都可以帮我解决这个问题吗?

最佳答案

问题是您要覆盖的方法 getRepository与基本方法 getRepository($entity = null) 的格式不同.要停止错误(通过使其兼容),只需添加 $entity = null到方法声明。

至于实际的错误问题(不显示然后显示)我帮不了你。在较新的版本中,事情可能变得更加严格。我最近确实注意到,较新的版本不允许在类中将函数声明为抽象,然后在随附的接口(interface)中声明,因此这是可能的。

关于php - 运行时通知 : Declaration of in symfony2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23302620/

相关文章:

php - 具有多行和删除的表

php - bug fatal error : Cannot redeclare date_diff() in

php - 如何在 symfony2 功能测试中发出 https 请求?

php - 如何在 Controller symfony 2 中渲染 Twig 宏

python - 什么可能导致此错误: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 568: invalid start byte

php - Slim 框架忽略 fatal error 的自定义错误处理程序

php - Linux 上的 Swift Mailer 错误

php - 在 PHP 中使用 JSON 字符串的 Http 发布请求

forms - 选择或创建实体

excel - 无法为 Excel UDF 返回正确的错误类型