Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123276 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 A2D8E1A009C for ; Wed, 8 May 2024 12:51:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1715172747; bh=j7bto4f0U/XevPKG2eThnexM9Uj67DDZGLl2B5leDKA=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=QLi/tv4ZtjluHpMGoOCxCvWZjveW0YcMebdDToq3hnprdrzGW+1DiupULpcil8W6I T6k/NvbQivcADJepT0rrUDiCLgFITdeF6yDZrbZHNG3fbcVK2FU9iEBbl3Mdmj+bBR YKcEJuekE3QaABkUVoed5kPiF0uFOmd2YzHvviiSmtD424oKBG8yRmdcVesfygQadg rpSpR/H3KyR6tQ0DXngQOW+WHgozN/TlC1O96KrSpIJhFiyC4wvAv44DOtd14c8Bkb XW4cMPy9+iVtsirKuJVlJxta9sHJjRpGuWlnHGAo+rFuA7WW2fA3ep7JC3geN+D04u 3qGRzJFm+L24Q== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A6FCC180055 for ; Wed, 8 May 2024 12:52:26 +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=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-yb1-f179.google.com (mail-yb1-f179.google.com [209.85.219.179]) (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 ; Wed, 8 May 2024 12:52:25 +0000 (UTC) Received: by mail-yb1-f179.google.com with SMTP id 3f1490d57ef6-deb5f006019so4695737276.0 for ; Wed, 08 May 2024 05:51:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dqxtech.net; s=google; t=1715172697; x=1715777497; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=d8REintzjzozaurxOgjV39wFYua6U/n3vGi+e7sEQQ0=; b=hBawIhJg+VLf3CJajktehxoobTsjs/QE4fztH923D0xNQOCw+PmXZ3h+2xaLhAPppj cicjEa0+qyMXI8Tt3SArUzQdkcH4D7H9JwoToXS6xStBjOq+n8go2df0FeAcdUgTzjXC tZpNikVJgEHUEE+0FqBtoEqPvAQAJEQ8NJE1YGCHY0GOc4BC7+zvn4NPqo/AYT3eRHB+ abAZwT//sCCE5fT2SboN4naJ77bx9TZj2qsfMbdjkbi5bqTq4oqJY8SSJwodSAXiOPRB 8rQqhWR2Uaeit3CZVrTJPUlyHQoGwJp8SylCrFKC+5i6TPr2fNFoQWQGv3N6mUBujjbp 1tmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715172697; x=1715777497; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=d8REintzjzozaurxOgjV39wFYua6U/n3vGi+e7sEQQ0=; b=VY2BPJLr/3tiKXi1FRxJ+cOMdsJCuBnzj+C9cwOGv7WerwwaHTu0oaeKuSjhRaROx/ ZVQ9wW34aYz6Y2+2TrGh7A/8o6sgIsLy5lf1FVWcb4DpHn1Ac0xfbzTQiCIk2qan/bJs D67dAQvVDMOj3oMaSUkSVSUId74b2GQC2+4ZuDlhRMrq+5UUgkcTcqo2owvexIuUhvGQ y3V76gX1XHuNFrSHviw5WHDP+AVhfhaBcFbjRKsl7LJULZAi2reze6WKaxg34T7HXznJ jHPf/s1jMSTudFbnRsLS/OvkBHJHSX3JhXBKkCk3AK/G1Vqc58Z4gRWHRDN/hEvPIYE6 9qqQ== X-Gm-Message-State: AOJu0YzlGa0Gk08AcBUmPD/RLCpMU+8ySDr86z/E98GBnbPwg6q5kzSP Ehaga+zJV9YTzX+iclPSDvDEvfIxnYty0r0csrIaXWIdA6BTupMTjktFGHMW3NMYGO99KTkhhl8 /fbv26UDqmdHgDblgIzuc0hmPjavgvvUYBbqNTg== X-Google-Smtp-Source: AGHT+IG2QJPE8k7cJoxNAOokIndRo33rDLV5tou4J78/ARcKXCVcpN64yOZQ76y55nRmE4Z8tgdVzobC6aAVhRDNKjI= X-Received: by 2002:a25:8004:0:b0:dcc:9e88:b15 with SMTP id 3f1490d57ef6-debb9dbdc87mr2670154276.41.1715172697020; Wed, 08 May 2024 05:51:37 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 8 May 2024 14:51:26 +0200 Message-ID: Subject: Re: [PHP-DEV] [RFC] Never For Argument Types To: Jordan LeDoux Cc: PHP internals Content-Type: text/plain; charset="UTF-8" From: andreas@dqxtech.net (Andreas Hennings) Hello list, to revive this old RFC. One really nice application of never parameters is with intersection types: interface I {} interface ReturnI { public function foo(never $x): I; } interface AcceptI { public function foo(I $x): mixed; } function f(ReturnI&AcceptI $arg, I $x): I { return $arg->foo($x); } Look at a live example where I simulate the "never" with an "AlmostNever" interface. https://3v4l.org/dPbgt It can even be applied with additional parameters: https://3v4l.org/l8eG6 An application can use this to reduce the range of individual interfaces, and cover scenarios that would otherwise require generics or callable types. So.. I would really like to see it :) --- Andreas On Sat, 14 Aug 2021 at 01:27, Jordan LeDoux wrote: > > Hey internals, > > I've been working on the draft for my operator overloading RFC, and in > doing so I encountered a separate change that I would like to see. > > That is, the use of `never` as an argument type for interfaces. Since > arguments in PHP are contravariant to preserve Liskov substitution, `never` > as the bottom type should indicate that implementing classes can require > any type combination they want. This is in fact consistent with type theory > and set theory, and is how the bottom type is treated in several other > languages. > > In this case, the bottom type would be used to indicate covariant parameter > polymorphism while not conflicting with LSP. > > This would provide a sort of minimal form of generics to PHP without the > issues that actual generics present from an implementation perspective. It > would not, however, restrict or hinder any future RFC for generics. > > This is at the first draft stage, and I currently have the RFC on a github > repo to allow for easy contribution and collaboration. > > Any feedback is greatly appreciated. > > https://github.com/JordanRL/never-argument-type > > Jordan