Is there an oppotunity to create an interface function in PHP, where a parameter requires to be an object, but not specified, what object it has to be?
Now my code looks like this:
interface Container {
public static function add(\Employee $element);
}
Right now I can just implement the function with a parameter, which requires an instance from "Employee". When I now implement it in a class it looks like this:
class EmployeeContainer implements Container {
public static function add(\Employee $element) {
$pnr = $element->getPNR();
}
}
When I create another class, that implements Container and set the required Object for example to Trainee, the PHP compiler throws an error:
class TraineeContainer implements Container {
public static function add(\Trainee $element) {
$pnr = $element->getPNR();
}
}
Fatal error: Declaration of TraineeContainer::add($element) must be compatible with Container::add(Employee $element)
Is there a way to set in the interface the required object to a custom object?
Why I want this?
Many IDE's supporting this form of instance description to suggest methods based on an object.