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.
Thanks. Dmitry. On Thu, Nov 6, 2014 at 6:00 PM, Andrea Faulds <a...@ajf.me> wrote: > > > On 6 Nov 2014, at 07:43, Dmitry Stogov <dmi...@zend.com> wrote: > > > > It may be a serious new problem. For example you won't be able to compile > > the following code at all? > > > > <?php > > class A { > > function foo(): C {} > > } > > class B extends A { > > function foo(): C {} > > } > > class C extends B { > > function foo(): C {} > > } > > ?> > > > > The similar code with argument type hinting works fine. > > It's just a first example I could imagine, I believe, we will get more... > > I can't see any reason that example wouldn't work. The types didn't > change, so there's no class loading needed for the covariance check. > > -- > Andrea Faulds > http://ajf.me/ >