Re: [RFC] [DISCUSSION] Scalar Pseudo-type
| From: | Nikita Popov | Date: | Sun, 24 Dec 2017 16:30:22 +0000 |
| Subject: | Re: [RFC] [DISCUSSION] Scalar Pseudo-type | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-101412@lists.php.net to get a copy of this message | ||
On Sun, Dec 24, 2017 at 3:34 PM, Fleshgrinder <php@fleshgrinder.com> wrote:
> Hi Internals!
>
> I prepared a PR to add the
scalar pseudo-type to PHP after the
> discussions around adding a mixed pseudo-type. I strongly
> believe that
> it makes sense to provide the most common primitive union types with
> handy aliases even if we are going to add union types in the future to PHP.
>
> https://github.com/php/php-src/pull/2987
>
> I added support for parameter type covariance and return type
> contravariance to make it as useful in daily development as possible.
>
> I will provide the RFC write-up asap at:
>
> https://wiki.php.net/rfc/scalar-pseudo-type
>
I think this RFC could benefit from displaying some use-cases for this type
annotation. I can't recall any recent instance where I would have found
this specific type combination useful, though I'm sure there are good
examples.
I also wonder whether in weak typing mode, scalar should also accept
__toString objects (and cast them to string), similarly to how a
bool|int|float|string union would behave.
Nikita