On Mon, Apr 20, 2020, at 9:15 AM, Sara Golemon wrote: > On Mon, Apr 20, 2020 at 8:52 AM Larry Garfield <la...@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
Sure, but how often is that an actual description of what the code accepts? I... cannot actually envision what code would actually accept that mess. :-) With union types and stringable already on the way, I'm not sure what other non-hypothetical use cases would still be that fugly that you'd now need to fall back to `mixed`. (I still think intersection types are needed, but that's a separate matter.) There may be, but I cannot think of them. > 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; Concur. > That said, baking 'mixed' in as an implicit alias of the above isn't > problematic for that future. > > -Sara Concur. --Larry Garfield -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php