Re: [RFC] Allow null as standalone type

From: Date: Tue, 05 Oct 2021 14:08:26 +0000
Subject: Re: [RFC] Allow null as standalone type
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-116225@lists.php.net to get a copy of this message
Le lundi 4 octobre 2021, 10:09:12 CEST Nikita Popov a écrit :
> If we make this change, I would however suggest to also support "false" as
> a standalone type. I think this change primarily has benefits from a
> typesystem completeness perspective rather than a strong practical need.
> From that angle, it would be nice if all types that are usable in a union
> are also usable as standalone types, rather than shifting the special case
> from null to false.

It feels weird/wrong to slowly add values in the type system like this, rather than directly
supporting static values as type hints.

Why would function a(): null|false {} be legal but function b(): null|0 would not?

This is inconsistent to me. And adding null, then false, then true for the sake of completeness
feels like avoiding to treat the static value as type hint subject.

Côme


Thread (12 messages)

« previous php.internals (#116225) next »