Covariance (OOP) in PHP - how does it work

Viewed 722
class Param() {
}
class Subparam extends Param {
}

class Base {

  function mymethod(Param a) {
  }

}

class Sub extends Base {

 function mymethod(Subparam a) {
 }

}

In PHP, this leads to a warning: Declaration should be compatible with Base->mymethod(a : \Param)

What can I do to prevent that, other than using annotations only?

2 Answers
Related