我几乎在每个CMS类中都有publicDelete()函数。不幸的是,在我之前有一些聪明的人用($rowId)
param创建了一些,其中一些根本没有参数。
父Main_Admin_Module
有这样的空函数声明:
public function beforeDelete() {}
但正因为如此,我得到了错误,如
错误:Model_EshopCategories :: beforeDelete()的声明应该是 与Admin_Module_Main :: beforeDelete()
的兼容
因为(显然)($rowId)
声明与(empty)
声明不兼容。
不幸的是,这会阻止Json响应,因为响应主体包含错误并因此被损坏,因此我想修复此问题。
我的问题是:我可以简单地删除父方法,还是应该在删除之前重写每个孩子以解决这个问题?我尝试用父方法做($rowId = null)
,但它没有用。
答案 0 :(得分:0)
It appears to me that the base method is an unnecessary burden, since it doesn't do anything and enforces rules that cannot be followed by all subclasses. Especially if it's called with different parameters under different circumstances, this method shouldn't be a part of the common API of Admin_Module_Main
class.
My suggestion would be to delete the beforeDelete()
method from Admin_Module_Main
.
The alternative that doesn't require you to delete the base method would be to go through every subclass of Admin_Module_Main
and make the parameters optional (plus the code that handles the default value in the optional parameter). This might be a better solution in case you don't know everything about the callers of beforeDelete()
method.
答案 1 :(得分:-2)
One of the solution to avoid this error if you don't want to fix code in all classes is to change the error_reporting level. Go to your php.ini configuration and update error_reporting in a way like.
error_reporting = E_ALL & ~E_STRICT
or do in the code
error_reporting(E_ALL ^ E_STRICT);
E_STRICT level is a reason why you see this error message.