Hi!
> If we allow larger type, why doesn't such code work ?
>
> interface A { }
> interface B extends A { }
>
> class C {
> public function foo(A $a) { }
> }
>
> class D extends C {
> public function foo(B $a) { } // E_STRICT
> }
>
> This is wrong IMO.
This shouldn't work - it means that if you have D object, you should be
able to call foo on it with any A parameter. However, your definition
says not every A parameter would work, but only one that is actually B
(i.e. class that implements A but not B is not going to work anymore).
That means D violates C's contract by rejecting some calls that C accepted.
--
Stas Malyshev
[email protected]