Re: [RFC][Vote] Return Types

From: Date: Thu, 06 Nov 2014 18:45:10 +0000
Subject: Re: [RFC][Vote] Return Types
References: 1 2 3 4 5 6 7 8 9 10 11 12 13  Groups: php.internals 
Request: Send a blank email to internals+get-78824@lists.php.net to get a copy of this message
It fails because class C is not known at the point when we check if A::foo() is compatible with B::foo(). The relation between C and B doesn't really matter in this case (I may provide another example with relation that must be supported). Thanks. Dmitry. On Thu, Nov 6, 2014 at 6:15 PM, Andrea Faulds <ajf@ajf.me> wrote: > > > On 6 Nov 2014, at 15:08, Dmitry Stogov <dmitry@zend.com> wrote: > > > > Use A or B for return type in B::foo(). It'll lead to compile error > anyway (Class C is not defined). > > It's not possible to compile this by design. > > Ok, let’s try this: > > <?php > class A { > function foo(): C {} > } > class B extends A { > function foo(): B {} > } > class C extends B { > function foo(): C {} > } > ?> > > I don’t think this can’t be compiled. When you get to B, you know that A > doesn’t extend anything, and B doesn’t extend C, so C can’t possibly be a > superclass of B, and it would fail, right? > > -- > Andrea Faulds > http://ajf.me/ > > > > >

« previous php.internals (#78824) next »