Re: [RFC][Vote] Return Types
| From: | Levi Morrison | Date: | Thu, 06 Nov 2014 14:51:53 +0000 |
| Subject: | Re: [RFC][Vote] Return Types | ||
| References: | 1 2 3 4 5 6 7 8 9 10 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-78819@lists.php.net to get a copy of this message | ||
On Thu, Nov 6, 2014 at 12:43 AM, Dmitry Stogov <dmitry@zend.com> wrote:
> It's clear, that covariant types are more smart, but not supporting them,
> won't prevent access to more specific type properties and methods.
> We are not C++ or Java, and we don't need to cast objects to more specific
> types.
>
> On the other hand covariance requires all return types to be defined before
> class binding.
> 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 {}
> }
> ?>
I think I have figured out away to do the type checks that would allow
this and current checks to work; I'll report back after some trial and
testing.