On Mon, Jan 20, 2020 at 6:30 PM Benjamin Morel <benjamin.mo...@gmail.com> wrote:
> Hi internals, > > 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". > > In addition to my Packagist survey > <https://externals.io/message/106844#107304>, I'd like to point out that I > just came across a native method in the SSH2 extension, that does use true > as a type: > > https://www.php.net/manual/en/function.ssh2-auth-none.php > > > Returns TRUE if the server does accept "none" as an authentication method, > > or an array of accepted authentication methods on failure. > > > > Of course, you could type-hint it array|bool, but the same could be said > for |false. > > Thoughts? > Generally I'm fine with also allowing the "true" type. We certainly have quite a few extension methods that return isolated true values for legacy reasons. However, before "true" is allowed, it is important to answer the two questions at the end of https://wiki.php.net/rfc/union_types_v2#literal_types. Namely, how do true/false interact with weak typing coercions (currently "false" only accepts "false", but not 0 or "") and whether true|false should be equivalent to bool (also related to the previous question). Regards, Nikita