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 <a...@ajf.me> wrote:

>
> > On 6 Nov 2014, at 15:08, Dmitry Stogov <dmi...@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/
>
>
>
>
>

Reply via email to