Re: [RFC] Mixed type
| From: | Sara Golemon | Date: | Mon, 20 Apr 2020 14:15:24 +0000 |
| Subject: | Re: [RFC] Mixed type | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-109719@lists.php.net to get a copy of this message | ||
On Mon, Apr 20, 2020 at 8:52 AM Larry Garfield <larry@garfieldtech.com>
wrote:
> On Mon, Apr 20, 2020, at 6:17 AM, Dan Ackroyd wrote:
> > Here is an RFC for adding a 'mixed' type to the language:
> > https://wiki.php.net/rfc/mixed_type_v2
> >
>
> I am not against this, but now that we have Union types what places are
> there where the currently available type declarations are insufficient?
> Resource seems like the only remaining gap where you'd be forced to use
>
mixed instead of a union.
>
> I imagine some type combinations get pretty wide. Like, this is verbose AF.
null|bool|int|float|string|array|object|resource
For the long term good of the language I'd prefer type aliases (or typedefs
or usings or whatever you want to call them.
use mixed = null|bool|int|float|string|array|object|resource;
use scalar = null|bool|int|float|string;
use number = int|float;
That said, baking 'mixed' in as an implicit alias of the above isn't
problematic for that future.
-Sara