On Fri, May 26, 2017 at 9:01 AM, li...@rhsoft.net <li...@rhsoft.net> wrote:
> > > Am 26.05.2017 um 16:26 schrieb Dan Ackroyd: > >> On 26 May 2017 at 13:23, li...@rhsoft.net <li...@rhsoft.net> wrote: >> >>> does that also fix the issue https://bugs.php.net/bug.php?id=74394 >>> >> >> >> Dear Anonymous, >> >> That "issue" is actually 3 issues. >> >> case 1 >> >> class A { >> public function test($a) {} >> } >> class B extends A { >> public function test(string $a) { } >> } >> >> This breaks LSP - because B::test doesn't accept all the things that >> A::test can accept and so is unlikely to ever be supported. >> > > and how is that a problem? > > A accepts anything > B limits it's inut to a *subset* of "anything" > > Because, if I have a function foo(A $a) { $a->test(new Bar()) } that I cannot pass B into this function, even though it is a subclass of A. You should be able to pass any subclass where its parent is expected, allowing parameter narrowing (covariance) would break this.