Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116226 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 6130 invoked from network); 5 Oct 2021 13:50:01 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 5 Oct 2021 13:50:01 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 1E9451804D8 for ; Tue, 5 Oct 2021 07:34:30 -0700 (PDT) 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,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-yb1-f178.google.com (mail-yb1-f178.google.com [209.85.219.178]) (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 ; Tue, 5 Oct 2021 07:34:29 -0700 (PDT) Received: by mail-yb1-f178.google.com with SMTP id a7so16777370yba.6 for ; Tue, 05 Oct 2021 07:34:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datadoghq.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=3iquxX4H5jQct+DM868G4yS0WSQlo574A9TSVDOiHak=; b=Cq8WTrq3iyl8EJ2zTiKDjyRR+oNz1pnWsr9kRmTpS/ecTRXDI4Ke9h/pqw747l6Xsb WQCWwnpAY7G9btLqluFvgYbnGR3WX4XxY8C8TGpdNczxxxzWlJDsLICBJr3awG9F6wa5 75lu8QLPBkzvEpA4ns5eKFr1NrVVx2sCFLOaw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=3iquxX4H5jQct+DM868G4yS0WSQlo574A9TSVDOiHak=; b=aPHd8lytpUHJy80olHnX21s3UJbgFp06zqexhp/wBTDjvbXA5Sg9v9NNqUeDEkyDzY LRTrK2qLqe+fYpo2zcL0otp0UdIgHfLwjMFjQbZz/yn4skOZDZmwqJ9hcOZphnEziqkH oM2VXNDTocOzvVG8T/cYfymwEiSc0JvlDDyx4eifUlOBw/tFIOWIMZUr/WVUxXdjgdW2 RXLV024ZoSqir0vPH/aBlfKtRKkbZouUdGlYBY22MoU5WBuue12mY3F702+OkuI7z85a uamGIm4G1LFyu6jffWyNINbYzR4/qYe1hsZmmN8DuRDGJMR1OFzpA+n24ni6wgMDwWG+ B3nw== X-Gm-Message-State: AOAM53385VsHzke52zC03p7K6V1hWA0e+pIy2X6FdX6sj73ISaUpO7oH m4Dqy5V18B+YDxZNECz3JVgglT/1cGlnneQKn25V6v4TsO+W4g== X-Google-Smtp-Source: ABdhPJwiZveWL/8Rw08n3PX+D//SKhYcd/Mo5Keo6mDkiCjPiQz3TbhTks583Ox2SYAKvfl6/u8LFVTKY0re+WEbWE8= X-Received: by 2002:a25:3614:: with SMTP id d20mr23632155yba.537.1633444465680; Tue, 05 Oct 2021 07:34:25 -0700 (PDT) MIME-Version: 1.0 References: <4638866.snJnjoNyIA@tempete> In-Reply-To: <4638866.snJnjoNyIA@tempete> Reply-To: Levi Morrison Date: Tue, 5 Oct 2021 08:34:15 -0600 Message-ID: To: =?UTF-8?Q?C=C3=B4me_Chilliet?= Cc: PHP internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC] Allow null as standalone type From: internals@lists.php.net ("Levi Morrison via internals") On Tue, Oct 5, 2021 at 8:08 AM C=C3=B4me Chilliet wrote: > > Le lundi 4 octobre 2021, 10:09:12 CEST Nikita Popov a =C3=A9crit : > > 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 uni= on > > are also usable as standalone types, rather than shifting the special c= ase > > from null to false. > > It feels weird/wrong to slowly add values in the type system like this, r= ather than directly supporting static values as type hints. > > Why would function a(): null|false {} be legal but function b(): null|0 w= ould not? > > This is inconsistent to me. And adding null, then false, then true for th= e sake of completeness feels like avoiding to treat the static value as typ= e hint subject. > > C=C3=B4me > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php > Null is both a type and a value. It's odd that we don't support null as a standalone type, because it's the only case I can think of where we have a value without a type in the type system. You could possibly argue the same about `resource`, but that's a legacy type we are working on removing (and special thanks to everyone who has participated). Integers are not the same. If you want to support integer literals and probably all forms of literals as types, I suggest that as a separate RFC. I really don't think they are the same.