Re: [RFC] Static return type
| From: | Guilliam Xavier | Date: | Wed, 15 Jan 2020 07:09:37 +0000 |
| Subject: | Re: [RFC] Static return type | ||
| References: | 1 2 3 4 5 6 7 8 9 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-108137@lists.php.net to get a copy of this message | ||
Hi,
After reading all the thread:
I'm +1 for
: static as proposed by this RFC.
I'm also +1 for : $this, preferably also in PHP 8.0, but that could
be a separate RFC:
- I like the idea to check it at compile time (like : void), i.e.
that all the return points of the method be syntactically `return
$this; (maybe also allow return $this->otherMethod(/*...*/);` where
the forwarded method is itself declared : $this).
- Regarding covariance, $this should probably be treated like a
"subtype" of static.
- I don't like the idea of making an implicit return $this; in
addition to the check.
I'm -1 for : fluent or fluent function as an alternative to :
$this.
I'm -0.5 for : new / : clone.
About "what comes out is the same type as what goes in", I would wait
for generics.
--
Guilliam Xavier