I'm trying to override a class' parent function with some changes. I have one argument that needs to be type-hinted on the parent and on the child it's a class that extends that type-hint:
class BaseObject {
//...
}
class NewObject extends BaseObject {
//...
}
// -----------------------------------
class ParentClass {
function method(BaseObject $obj) {
//...
}
}
class ChildClass extends ParentClass {
function method(NewObject $obj) {
//...
}
}
PHP is returning:
Declaration of ChildClass::method(NewObject $obj) should be compatible with ParentClass::method(BaseObject $obj)
I find this kind of odd, since NewObject is an instance of the BaseObject.