Re: [RFC][Vote] Return Types
| From: | Dmitry Stogov | Date: | Thu, 06 Nov 2014 15:08:25 +0000 |
| Subject: | Re: [RFC][Vote] Return Types | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-78821@lists.php.net to get a copy of this message | ||
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 <ajf@ajf.me> wrote:
>
> > On 6 Nov 2014, at 07:43, Dmitry Stogov <dmitry@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/
>