Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126968 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 7E72A1A00BC for ; Fri, 28 Mar 2025 11:28:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1743161177; bh=ze77Fy6K7gmGpEvUykEMVD7fpE2wYAmSE2j+S3Cw+8g=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=UnQ07jZ2eJ+mDi6IoAM7fUvXb5o2xib4INWjGi12N7nD82RNrbX37MutREUYzjlV1 kib//RGTCEf8WptYM0YoVwYd06fJSy/odicKKO7xR3Eurjuxjhiv1rbwYBuvYRPyuq 02+UCLNEWHAAzAjKsSh9Xe2cKWrBZXXpnyfK0XxOf9/CI0ytByrGe67QdTwPzJVR73 o/BdJZnECiR23R0B2e5FHCyONRTX+3VbxzwIZuP2qSnYX6fEmUfHL2zlLozVvJRbjC Owr0dr8h7vAyckI2CjPChkeoFANuehXlLii1AbQv3rfszLtVojrv3Ru5jWhYHxnObr ajotv/Xkn768A== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 675F6180037 for ; Fri, 28 Mar 2025 11:26:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-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,DMARC_PASS,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from chrono.xqk7.com (chrono.xqk7.com [176.9.45.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 28 Mar 2025 11:26:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1743161323; bh=X09dNdQaVas4vg57IssA2G7rt3SufKxPHQ9+aUUwKxs=; h=MIME-Version:Date:From:To:Cc:Subject:In-Reply-To:References: Message-ID:Content-Type:from:to:cc:subject:message-id; b=PwFRj/fgDnvMOQStBJCkglvUf3YBvHgoTd+EJJXg51h2doL2eM+gMgGEJpyDyeJby tu16Xc8SW8Ig/fuda7MDEaowA/zWrtBvNBcjUwLdpm1wR/KytZjIXNtKMHn2g8+sLO JMQdrLsCJVhOpEKA/Ylv1M3pN8CzHxj5fEoEkvVO66YH4SLVGuYUSXPOm19yiqDXoS 1OUNemy6X0katGz+mY1QzfK7CkeB5jIOmcBfrMChQ6uQbGXfAG9xBNZNGsZnsESzaZ 3xN4lpraVMBFEKnbHs8xtv63fpNqo9BJLr48f1a7XY4T5SmaUpZs2kr3PIVsdtLmV/ jp4Q4GnDVaB5g== Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Date: Fri, 28 Mar 2025 12:28:43 +0100 To: "Rowan Tommins [IMSoP]" Cc: internals@lists.php.net Subject: Re: [PHP-DEV] [RFC] [Discussion] Never parameters In-Reply-To: References: Message-ID: <985ae6bea66195fe294223ed48b30dbb@bastelstu.be> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit From: tim@bastelstu.be (=?UTF-8?Q?Tim_D=C3=BCsterhus?=) Hi Am 2025-03-25 21:42, schrieb Rowan Tommins [IMSoP]: > And I've seen plenty of junior devs struggle with simple things like > the difference between "nullable" and "optional", so I worry that > making the type system too rich will lose PHP its reputation as an > approachable language. > > > It's possible I'd react less strongly if a keyword was chosen that made > more sense in context, although I'm not sure what that would be. FWIW: There is precedent for “never” as a parameter type in TypeScript. In fact, the Comparable example I gave also works in TypeScript in an unmodified fashion: https://www.typescriptlang.org/play/?#code/JYOwLgpgTgZghgYwgAgMIHsC2AHOU4BGANigN4BQyVyCWuUEAKugBTpgAW0AXMiBADdoASl4gArpgLRyAX3LkEROAGcVyALIBPAHKTpUZMBwlMEcOow48hEsgrUadPE1bsuUXtr1SRY-dD2lI7UwDDIbJyBADzInMAqwkEhKcgMYOJQIMgAtACMwSmyyBBEKihhEe6BAHxxHAlJDqmO6ZnZBS3FpeXJLdRtWcgADIUh8o7y8uQw4iAIYMDo2TDorAi8VvS2EAA0yAAmm874xBBNY7QgKugkAHRE6ADmLAh3tNYMzCwHyKp8ghEwjkQA The `compareTo()` method is indeed not callable OOTB and I need to tell the compiler that I know what I'm doing by the `as never` assertion, but it still guarantees me that the return value is a number. I also expect folks to rarely encounter `never` as a parameter type in practice since generic interfaces are comparatively rare, but in the cases where you have a generic interface, `never` feels more useful to have than not having it. Best regards Tim Düsterhus