Re: [RFC] Static return type

From: Date: Thu, 09 Jan 2020 14:40:54 +0000
Subject: Re: [RFC] Static return type
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-108062@lists.php.net to get a copy of this message
> Of course this ": $this" could be added later in the future. > But this would have the risk that people start adding ": static" on methods > that really return $this. > I second $this. I also would like to be able to declare `function foo(): $this at the same time as function foo(): static` so that we can use the most accurate description right away. Although I'm not into the C part of the proposal, if I may have a suggestion here, it would be to implement the check *at compile time*. Like nullable return types check at compile time that return null; is used instead of just return;, I think a $this return type could and should enforce return $this; on all return point of such methods. That would also make the check free at runtime. Cheers, Nicolas

« previous php.internals (#108062) next »