【发布时间】:2017-12-10 12:43:41
【问题描述】:
class Param() {
}
class Subparam extends Param {
}
class Base {
function mymethod(Param a) {
}
}
class Sub extends Base {
function mymethod(Subparam a) {
}
}
在 PHP 中,这会导致警告:Declaration should be compatible with Base->mymethod(a : \Param)
除了仅使用注释之外,我还能做些什么来防止这种情况发生?
【问题讨论】:
-
你真的不能。
标签: php oop covariance