Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115729 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 11562 invoked from network); 14 Aug 2021 16:41:27 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 14 Aug 2021 16:41:27 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9AC411804B3 for ; Sat, 14 Aug 2021 10:12:59 -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,FREEMAIL_FROM, 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-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (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, 14 Aug 2021 10:12:59 -0700 (PDT) Received: by mail-wr1-f48.google.com with SMTP id k29so17594595wrd.7 for ; Sat, 14 Aug 2021 10:12:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=LdCbepYp1beOZGEBulGDZt7L+PmDl+3IqgJKMQkgQTA=; b=trQyc64WdUwe2/DGihptOprJl2W3QNn15po+rHx7At0KFxosys0rEZoKTuI9uPxwMv 8pkBgEhWmiaZaGQWJvmA/WMFjwratUSFddrw6veT13Es5BLbPWgYRsAWxmaiaMPMncdc vUOStS5QEhh4HOffgghfGw9d6nLHOd8PkfGVPCPfINoxBgmWetmCClMD0ufxc21fJgA5 u4Kt79vXI11BZmUEWfUzKVIqiI2R3OO+/XPEiZ/jNTKqeTGx95AkY6LyHSzTzIHReOr/ sFeE7/XURWwzEvUt9uqkZcP2orcOQDbOVMXVctb88Q4ReKclvGc/juu4PcPRLOySFNCX hegg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=LdCbepYp1beOZGEBulGDZt7L+PmDl+3IqgJKMQkgQTA=; b=ps8ugMX5FBWobogpN6X9VoCzLHqpAcWCJCY/7KdHQF+ofe8hVpQM0xOHj3kjk4PaPK 2uPdPq8rby4gpKXaujshIwN7CfbIaWHcEkWkq1mu2IDyHFZUsDjSsFK552dZigRg5hA0 zE2c3EwAYK6NCnQwOd1ZWQfSIN2ahA/GVc8vJ0jYqAHtYJtyjhGtEVhTBpP5p1chABt3 AZYiI6E5WQ9//IubglBuhe2fojXhFRGYUP0Yj0xccaGeAK/GWlIaYOl7D2noN9wLlW5l xpxvKA2zWp0FXQ+REtuFsbuTMgjMC1mWTIB7akhUvbxmMIPdVq2KUJ7is8PSEL5L+cm5 iL8g== X-Gm-Message-State: AOAM530ISKTj5/vWK4oNnXDE3/+TQ48FESkHoxhrXTXg1QZJwzGLPlz8 O68u1Dhbne6Qee3SIepulHM= X-Google-Smtp-Source: ABdhPJwVXD9+hvmcCWi0Ram9PH33pvG1GDhxiyKu+iDGoRzbSlCbEwss0B8afzRCj1kgw/myTcuUuQ== X-Received: by 2002:a5d:590f:: with SMTP id v15mr8793266wrd.189.1628961178256; Sat, 14 Aug 2021 10:12:58 -0700 (PDT) Received: from [172.20.10.2] (26.236.197.178.dynamic.wless.lssmb00p-cgnat.res.cust.swisscom.ch. [178.197.236.26]) by smtp.gmail.com with ESMTPSA id o6sm5317650wru.92.2021.08.14.10.12.57 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 14 Aug 2021 10:12:57 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\)) In-Reply-To: Date: Sat, 14 Aug 2021 19:12:56 +0200 Cc: Jordan LeDoux , PHP internals Content-Transfer-Encoding: quoted-printable Message-ID: <39B2655D-3877-41C1-9112-E2772E44544D@gmail.com> References: To: Matthew Brown X-Mailer: Apple Mail (2.3608.120.23.2.7) Subject: Re: [PHP-DEV] [RFC] Never For Argument Types From: claude.pache@gmail.com (Claude Pache) >=20 > On Fri, 13 Aug 2021 at 19:27, Jordan LeDoux = wrote: >=20 >> Hey internals, >>=20 >> 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. >>=20 >> 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. >>=20 >> In this case, the bottom type would be used to indicate covariant = parameter >> polymorphism while not conflicting with LSP. >>=20 >> 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. >>=20 >> This is at the first draft stage, and I currently have the RFC on a = github >> repo to allow for easy contribution and collaboration. >>=20 >> Any feedback is greatly appreciated. >>=20 >> https://github.com/JordanRL/never-argument-type >>=20 >> Jordan >>=20 > Le 14 ao=C3=BBt 2021 =C3=A0 18:19, Matthew Brown = a =C3=A9crit : >=20 > Hey! >=20 > Using the "never" type to require that downstream libs specify a type = does > not make intuitive sense to me, because the same is not true the other = way > (covariantly) for return types. >=20 > The existence of a "never" type on an overriding method does not = require > that upstream libs specify a return type =E2=80=94 this is perfectly = valid: >=20 > class A { > public function foo() {} > } > class AChild extends A { > public function foo():never { exit; } > } >=20 > Best wishes, >=20 > Matt Indeed, I was going to write something similar. Concretely, I assume = that one would want to update the ArrayAccess internal interface as = follows: ```php interface ArrayAccess { public function offsetGet(never $x): mixed; // ... } ``` If users of that interface would suddenly be *required* to specify a = parameter type, whereas previously they were *forbidden* to specify one, = except a meaningless `mixed`... it would be not nice and useless. Moreover, note that `mixed` was only introduced very recently, in 8.0: = so that, it would be impossible to implement `ArrayAccess` on code that = work both in 7.x and a future version with the updated interface. Not = only would it be not nice, but it would be positively harmful. =E2=80=94Claude