I think it\'ll be much easier to see the problem in a code example than writing the question in the first place. Here is my php code:
php doesn't seem to be recognizing the signatures of
AnAbstractClass::method
andConcreteClass::method
as compatible.
PHP is correct, they're not compatible. By allowing only instances of AClass
(or its children) to be passed to ConcreteClass::method
, you're breaking the contract that AnAbstractClass
provides: Any of its subclasses must accept AnInterface
as an argument to its method()
.
If your example worked, and I had another class BClass
implementing AnInterface
, we'd have a situation where according to AnAbstractClass
, method()
should accept instances of BClass
, while according to ConcreteClass
, it shouldn't.
Change your signature for ConcreteClass::method
to match that of AnAbstractClass::method
.