Imagine a generic library defines a class:
class A_CLASS {
public function foo(B_CLASS $b) {
// Use $b as B_CLASS
}
}
class B_CLASS {
}
And I need to override this one, but with my own child B_CLASS, so I would declare
class A_CHILD_CLASS extends A_CLASS {
public function foo(B_CHILD_CLASS $b) {
parent::foo($b);
// Use $b as B_CHILD_CLASS
}
}
class B_CHILD_CLASS extends B_CLASS {
}
This is not working on PHP 5.6. In other languages, this will work, and we could also use a generic interface. But in PHP, this is not available and there is no generic interface.
So, how could I implement it in PHP ? This is really a problem in my project.