We already have other "meta" types. E.g. "callable" can be a string, an array, an object with __invoke(). A "numeric" can be float or int. A "iterable" can be an array or an traversable object.
Technically you are right, my "anything that could be an array index" would be equivalent to "string|int". Personally I don't think we need every possible union, let alone intersections. I am not strictly opposed to them, but don't find them as necessary. Most well-written functions will have one return type. But there are some cases of naturally occuring union or meta types, which might deserve their own meta type name. On 19 December 2017 at 16:28, Levi Morrison <le...@php.net> wrote: > On Tue, Dec 19, 2017 at 4:47 AM, Andreas Hennings <andr...@dqxtech.net> wrote: >> On 19 December 2017 at 08:06, Fleshgrinder <p...@fleshgrinder.com> wrote: >>> What is really needed are `scalar`, `number`, union types, intersection >>> types, and all that together with generics. >> >> Do we have ongoing discussions or RFCs for those already? >> I know we have one for generics, which seems somehow stuck, >> https://wiki.php.net/rfc/generics > > No. Work is quietly being done on parameterized types (aka generics) here: > > https://github.com/morrisonlevi/php-src/tree/parameterized_traits > > There really isn't a lot to discuss at this stage anyway; the > technical implementation is paramount. > >> What would "scalar" mean exactly? string+int+float? > > Scalar and number are just ways of naming certain union types which > feature was already declined. Maybe a single RFC which targets both > union and intersection types would pass. Our `is_scalar` function > returns true for integer, float, string or boolean; a scalar type > should mirror that definition: int | float | string | bool. > >> I would sometimes like a string+int, for "everything that can be an array >> key". > > This is just another named union for `string | int`. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php