Re: Union types | true pseudo-type

From: Date: Tue, 21 Jan 2020 07:12:05 +0000
Subject: Re: Union types | true pseudo-type
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-108205@lists.php.net to get a copy of this message
On 20/01/2020 18:30, Benjamin Morel wrote:
I'd like to bring back the topic of supporting "true" as a type in PHP 8 union types. Now that the RFC <https://wiki.php.net/rfc/union_types_v2> has been successfully voted, I'd like to revive the discussion about adding the "true" pseudo-type in addition to "false". [..] Thoughts? — Benjamin
Hey, Looking at my current project's code, I found one place where we use a "string|true" as return type for an authentication method which returns true or an error code if it fails. Of course all the use cases we can argue about whether they are valid and so on, but my main problem is the weird state of having false as a type and not true. It just feels like an inconsistency in the language that'll surely bite people when they'll try to use true as a type. It might not be often, but it's kind of a shame if we can foresee it and prevent it from happening. TL;DR: true Best, Jordi -- Jordi Boggiano @seldaek - https://seld.be

« previous php.internals (#108205) next »