Re: RFC: Return Types Update

From: Date: Thu, 16 Oct 2014 14:46:34 +0000
Subject: Re: RFC: Return Types Update
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-78116@lists.php.net to get a copy of this message
On Thu, 16 Oct 2014 18:39:06 +0400, Davey Shafik <davey@php.net> wrote:
I very much like this — though I would say it was dependent on the nullable types RFC (like splat and variadics were codependent). While I would like to see the introduction of a void type, I understand and respect the limitations on the RFC. However, one thing that I do think is missing, is the equivalent of Hacks $this return type. You have self and parent, but I think without a static equivalent you can break things: class foo {
     static public function instanceOf(): self {
           return new static();
     }
} class bar extends foo { } foo::instanceOf(); // new foo, this is fine, returns self. bar::instanceOf(); // new bar, no longer self
Hi, bar is considered as instance of foo so shouldn't be any problem. Otherwise it would break LSP

« previous php.internals (#78116) next »