Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115721 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 93392 invoked from network); 14 Aug 2021 13:29:48 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 14 Aug 2021 13:29:48 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 164821804C8 for ; Sat, 14 Aug 2021 07:01:15 -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.0 required=5.0 tests=BAYES_00,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS8943 85.119.80.0/21 X-Spam-Virus: No X-Envelope-From: Received: from mail.apserver.co.uk (server2.alteredperspective.co.uk [85.119.82.103]) by php-smtp4.php.net (Postfix) with ESMTP for ; Sat, 14 Aug 2021 07:01:13 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by mail.apserver.co.uk (Postfix) with ESMTP id E2CA94F4064; Sat, 14 Aug 2021 15:00:29 +0100 (BST) Received: from mail.apserver.co.uk ([127.0.0.1]) by localhost (server2.alteredperspective.co.uk [127.0.0.1]) (amavisd-new, port 10024) with LMTP id b3t2ssQIq1yq; Sat, 14 Aug 2021 15:00:27 +0100 (BST) Received: from [192.168.0.6] (maid-09-b2-v4wan-162707-cust865.vm41.cable.virginm.net [82.44.111.98]) by mail.apserver.co.uk (Postfix) with ESMTPA id 552F04F4061; Sat, 14 Aug 2021 15:00:27 +0100 (BST) To: Jordan LeDoux , PHP internals References: Message-ID: <64b3800a-c54e-c1cc-8bab-bc503a969c37@allenjb.me.uk> Date: Sat, 14 Aug 2021 15:01:10 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-GB Subject: Re: [PHP-DEV] [RFC] Never For Argument Types From: php.lists@allenjb.me.uk (AllenJB) On 14/08/2021 00: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 Whilst I understand there's a historical aspect to the keyword naming used in this RFC, as a PHP developer, I think the use of "never" here is going to be confusing to people when considered along-side the never return type. I think it would make more sense to change the keyword for this RFC to something else such as "any", "unspecified", "unknown" or "specify". (Whilst "nothing" might also be considered given its use in other languages, I don't think the meaning / purpose is that clear). This RFC only considers this feature for arguments. Why is it also not a valid feature for return types? I think it might be useful for abstract classes and interfaces (for example, the Iterator interface) to force implementers to specify a return type for certain methods whilst not specifying anything about it themselves.