I have the interface:
interface AbstractMapper
{
public function objectToArray(ActiveRecordBase $object);
}
And classes:
No, an interface must be implemented exactly. If you restrict the implementation to a more specific subclass, it's not the same interface/signature. PHP doesn't have generics or similar mechanisms.
You can always manually check in code, of course:
if (!($object instanceof Product)) {
throw new InvalidArgumentException;
}
Another way of implementing this would be:
class Executor
{
public function objectToArray(AbstractMapper $var)
{
$this->convert($var);
}
private function convert(Product $var)
{
...
}
}