On Mon, 20 Apr 2020 at 16:17, Larry Garfield <la...@garfieldtech.com> wrote:

> I... cannot actually envision what code would actually accept that mess. :-)

var_dump() would be one example. Also caches that can store any
userland value would be another reasonably common use.

The general pattern is when you're handling someone else's 'data' and
have no restrictions on what type that data should be. That's actually
the use-case that prompted me to help draft this RFC.

> now that we have Union types what places are
> there where the currently available type declarations are insufficient?

A type that explicitly allows any type is more forwards compatible
than writing out a union type.

Compare this:

var_dump( mixed $expression [, mixed $... ] ) : void

to:

var_dump( null|bool|int|float|string|array|object|resource $expression
[, null|bool|int|float|string|array|object|resource $... ] ) : void

If/when we add an 'enum' type that is not a child type of any of the
current types, the signature of that function doesn't need to change
if it uses mixed, rather than the written out union type.

Also, the 'fitting on a line' problem.

cheers
Dan
Ack

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to