Interface implementation: declaration must be compatible

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;
}

Leave a Comment