A class that implements the interface must use the same method signatures that are defined in the interface. This will not result in a fatal error. And the same rules for classes that extend abstract classes.
For more details see here . See here
And this is the correct behavior \ logic.
check here Abstract types are useful in that they can be used to define and enforce the protocol; A set of operations that all objects implementing the protocol must support.
if we assume that your code will work without exception, then we have the following problem: ConcreteFooMapper cannot use instances of some class ConcreteFoo2 implements Foo parameter class ConcreteFoo2 implements Foo as a parameter for the load method, but should (by the definition of an abstract class)
In addition, if you use the same signature, this is not a problem, because all information about the class \ type is available. Please check the following code
<?php interface Foo { public function foo(); } class ConcreteFoo implements Foo { public function foo() { } } abstract class AbstractFooMapper { abstract public function load(Foo $entity, array $data); } class ConcreteFooMapper extends AbstractFooMapper { public function load(Foo $entity, array $data) { var_dump($entity instanceof Foo); var_dump($entity instanceof ConcreteFoo); } } $someConcreteFoo = new ConcreteFoo(); $someFooMapper = new ConcreteFooMapper(); $someFooMapper->load($someConcreteFoo, array('somekey' => 'somevalue'));
source share