Re: Allow dropping typehints during inheritance

From: Date: Thu, 05 Feb 2015 22:34:49 +0000
Subject: Re: Allow dropping typehints during inheritance
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-81968@lists.php.net to get a copy of this message
On 5 February 2015 at 21:52, Levi Morrison <levim@php.net> wrote: > To chime in regarding allowing contravariant parameter types: I > struggle to find use cases for it. Theoretically it would allow a class to implement two separate interfaces that would otherwise be incompatible: interface A { function foo(); } interface B implements A { function bar(B $b); } interface C implements A { function bar(C $c); }; class D implements B, C { // Any object that implements B or C must also // implement A, but only the methods from interface A // are safe to call inside the method. function bar(A $a){ $a->foo(); } function foo(){...} } But I agree, the number of times I've wanted to do this is low. cheers Dan

« previous php.internals (#81968) next »