I have been developing an ORM and currently run into this error in testing.
Declaration of ClassA::setB() should be compatible with that of SuperClass::setB()
My code is something like this.
class SuperClass() {
protected $b;
public function setB(ClassB $b) {
$this->b = $b;
}
}
class ClassB {}
class ChildB extends ClassB {}
class ClassA extends SuperClass {
public function setB(ChildB $b) {
parent::setB($b);
}
}
Is this excepted behaviour. What I think is ClassA is overloading method setB of SuperClass, but ClassA::setB
is still compatible with SuperClass::setB
because class ChildB
is a child class of ClassB
.
Or is overloading in anyway just prohibited.