Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108281 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 82224 invoked from network); 28 Jan 2020 05:36:09 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 28 Jan 2020 05:36:09 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 7E02F1804AC for ; Mon, 27 Jan 2020 19:46:27 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-il1-f171.google.com (mail-il1-f171.google.com [209.85.166.171]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 27 Jan 2020 19:46:23 -0800 (PST) Received: by mail-il1-f171.google.com with SMTP id g12so9473151ild.2 for ; Mon, 27 Jan 2020 19:46:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=zhmYjfIHAMnTiRYCJv4GX2SlZTIm7CYBvyP7POFKYcY=; b=BWT1u1unvhTog7U80V4mxjucND9Yl/bujYfNoQ8zu9GkoQnDUUVhDgrHWf2tP+nbGu 7rg1FApwH2Lp+NkcZxCLpFRcfLOVC/A/1SJUzMqKQeazM6heYpNW+7dR+Z4CqtUZo7uy Cb3Z7ISficLOwFl/VbD2/nK7J9d/uFD0Fr6LL3OnnNUrxO96ikovb7EXnw7YOg2CuIHx XcsVnCNlYmrHimPi7lqRTb5u1TJH3tkhr61U2kXbGWkWUdiOGedg7RjQe5vw4J0xTsRk nHTtvSfLstlokPcy/taiVu1y1+tHC8jrV+0DxBzvz8p5ll4bYktx8Ao17y3qv+o10Z8w fgKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=zhmYjfIHAMnTiRYCJv4GX2SlZTIm7CYBvyP7POFKYcY=; b=Y2WgzovdUN9b7ktMrYVzSNROKwcN8hE0LbnooMClmCtIoFJ4xlYkgdsg8P/JKUXseF 9Hg4Z5xB4vZG3ic7gXY+ZlSzT5MuiTiJhJVzoyhreWSdTTGsQoGBBKBsgCNaERvOYttG v7YiLUl4kqbMrBxfrSl4btTgj5GKZPcl3Z7VHr2w178nhH0HIJ1DGHR4gHqqPMb41b5S SlPb5J+YRkUSoA9zoYwRvt62y9gNFDvly8YKTeWqPTp11odk/bt/s4qXJSN6C/PS0BAa yD7RWYf3qzilN9FgivIpjsiB39HG7W0ZqYlx+kZIXTNvuvfRZvZW0XdYaQY04UZQqD3I gX6A== X-Gm-Message-State: APjAAAXG7R3abySjol6/1aDaMWyFZi9rHunO8XoGy6XIzKBS6G4z2Bti B0Z4T4XL+0zzOWpZUIJUhNYPpde4nJhPiYZidHM= X-Google-Smtp-Source: APXvYqzkXPlUZWU0FPN7swisqqiLsDsexjZ30iA/af85MxJTl6QbdzwcanB+j1NnNMBTJ5Hh7ARkDmAd1PaU/fXcVGY= X-Received: by 2002:a92:b74a:: with SMTP id c10mr14248882ilm.86.1580183182389; Mon, 27 Jan 2020 19:46:22 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 28 Jan 2020 05:46:08 +0200 Message-ID: To: Nikita Popov Cc: Benjamin Morel , PHP Internals Content-Type: multipart/alternative; boundary="000000000000443eeb059d2b11e1" Subject: Re: [PHP-DEV] Union types | true pseudo-type From: drealecs@gmail.com (=?UTF-8?Q?Alexandru_P=C4=83tr=C4=83nescu?=) --000000000000443eeb059d2b11e1 Content-Type: text/plain; charset="UTF-8" On Mon, Jan 27, 2020 at 11:43 AM Nikita Popov wrote: > On Mon, Jan 20, 2020 at 6:30 PM Benjamin Morel > 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 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 > > , 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 > Hi, I think we can continue in a similar conservative approach, without coercion for *true*, similar as for *false*. For the cases mentioned so far, we are interested in exactly the true value, not true-ish value like 1. This would make *true|false* not equivalent with *bool* when strict_types is not enabled and equivalent when strict_types is enabled. Alex --000000000000443eeb059d2b11e1--