Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113939 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 91556 invoked from network); 3 Apr 2021 19:28:50 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 3 Apr 2021 19:28:50 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 4DF4A1804B2 for ; Sat, 3 Apr 2021 12:27:10 -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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) (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 ; Sat, 3 Apr 2021 12:27:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1617478027; bh=AgKBxnqz5YxTwpxTTwVcHKjxZzscJKD9zMi3KCI72LQ=; h=X-UI-Sender-Class:Subject:To:References:From:Date:In-Reply-To; b=ZP0O0UqAJzht6nYFL+PrCAU2lkLJjUrLf8NZ2bQ+ezIR5jU3Go5BLijQ8tOrx6bFB gZ+VsbUGeDvy/V5C+6/lQ/of8v6GjB0Fh4oO07irEMP69Xmy8mOmPYVX6TIyqkur9d 3XpQpKkruyLqlOEH46l9r+8CSkHrnwkMNP2YdUkk= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.178.120] ([24.134.51.41]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MgNh1-1m5zIC1nBv-00hxwd for ; Sat, 03 Apr 2021 21:27:07 +0200 To: internals@lists.php.net References: Message-ID: Date: Sat, 3 Apr 2021 21:27:24 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Content-Language: en-US X-Provags-ID: V03:K1:dvQddg8zTgkxI4E/AyJmPFprcIDNm4dgtjXcMBUIUop7EqtkjZZ /LPOD/9nUksreAZFvsIYNQwmhp54Rtt9ZK8DaXomJVqmKbo3ZebMHz762NAFLBhSLgFMJWL ZMyIK07OmU9CuK/zTBtJXN7KAwXrv0YNxCAarLyUBP/fkaw2XUcA7c/IzhQv6cfsw5i1VNG qg+TqNAFyDx7nzP9XyVqg== X-UI-Out-Filterresults: notjunk:1;V03:K0:zV94PjxYeL8=:PqAeoA8eOarO1UaJeoOOIY AVdCijaU1ttLOWlmY+CIpD2xA9dA9KAvim0MSb6UjNEM9x4xT8CSRL9rCxW6O1ObDZedd8xVQ +JHNRBZ3Vd2SS+JQV/DXBzk5ART/x8+b6VXUfYKs4nLjgNP5v588obX4w/RG9iBgiHbm/RVZs lRp3ouAl53HDIjciU5nnIg0tbB9gchoVrfv/5bmcwF96Kj8Iy8RW4UsoLgTXqJvunoW8OQMNR aeGgNyRvGVdKAAiVRyZAOWScvNN5V0Jv0A4qpqkiewTPlxu2uKZtK/PGMMO/8D4OCSpWIur2T xK87iID5+WceTxC3fBIeK/lolt0vIw3M7+2qV4n+gIay6iNuqvtEUYffy/Kab9wGgNv12yjUz CRiKB+n3pmvITbBXU6AB4ixA+9WZ1k+0vkp54SsZe5Z4l1g0imqMQ4NaWBGQlVF7z0bYN8hH1 eFgUJKBK7sG7oO1RTW25IXQber49KFW7+ZpPOEcGVmGI4+o8vQ16B8E/rMLDl5y0av1rWh87L zs5HAKJ+IJDnCkar9owhStWOf8rBkn502FZYlaZT/o4CGC7wS0JJ9IRdsLTxuI1XA/ao2SIMZ KZdu7nt8EuQ1oE0NYvJWKc2P42mvIucy/FvHdR9Qs058ggtZYT1iDM5tad/d2fxJZLOzTPrz8 3FmmIPrI5kT+CLy2tC/SJQz7ne4OPN9K8K6GWivtMXcAD6fSF+3D7vTDOOQOnbvAE9cESVdPa 6+eTM/55VJkvNBCVwSGVkveSFhxZrR7JyZzVelO5Qi2v6dQ5RmIpIIL4S3VrlKElLsz0FTHX/ MXIfWmJdQE2F1DbeuaBGZQG5BrUhzH8yVsbDOttmXKdGP2Ih563xtNHZBV8Ea0vC00IgYXW1o T+GLjMnvSHmknSacmAOl9PJS+Y2QQPag8bjBwpTffpRDsCcQrx5+1FMIK84XWEAiAawkAl3Y/ APiSLLZWTmzYO8jJftPeoz30K0U5Muq2AaKALj/cbAZX1fp6Dgbxob1w9u775E9P9KyPQyLrV JOxIeH1LIHdfu6xOlDEknsEB5bIVwlPsxUpN/qBcpNvk6Ts0EesemjSQNFa+DHXduvnIiB/im oJq6j9mWZ1sYevj7HUVYVEbowaOBa9qKovH8K23RXV9mq4390zLYDmk2LvjUDVXaDe3/4v181 m4+YQtvgq6Ny8jy3DmIx9xBflKfSaNVtRsaFXEmqhNAXH96O0TYxmVLZs7CXIpjK7jjbg= Subject: Re: [PHP-DEV] [VOTE] noreturn type From: a.leathley@gmx.net (Andreas Leathley) On 03.04.21 18:30, Benjamin Eberlei wrote: > if (is_string($value) && is_int($value)) { > // inside here $value is_type =3D=3D "never" > } > > The naming "never" here makes no sense, because from a theoretical > perspective reasoning about the type of $value it is nothing and only th= e > block of code is "never reached". > > I suppose PHPStan and Psalm are eager to reuse the new type name for thi= s > kind of type interference, same as TypeScript does. The name is sub > optiomal outside the context of a return type. > I read through all the Typescript and Hack explanations/examples of "never" and "nothing", and to me "never" seems clearer, which just shows how different opinions can be. I would not like "nothing" because it seems so similar to "void" and "null". "This function returns nothing" would inevitably lead to the question what that actually means. "This function returns never" is a reasonably clear description. "This variable at this point is never" or "This variable at this point is nothing" are both not clear without context, although never implies this should not happen (or cannot happen) and could be interpreted as "This variable at this point is never anything", which in general would be clearer to me (not being familiar with either before this proposal). From a practical perspective, I think the proposal is about the return type because this has a clear use case in code today. Your $value example would lead to the Psalm/PHPStan errors of "Type does not contain type" (Psalm) or "Result of && is always false" (PHPStan), I don't think there currently is much use to determine a type of never in these cases. But that might be something Matt/Ondrej can answer a lot better than me. I initially preferred "noreturn", but now prefer "never". "noreturn" is more self-explanatory, but "never" seems more apt and versatile, while still being quite clear.