Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115737 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 72744 invoked from network); 15 Aug 2021 10:33:34 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 15 Aug 2021 10:33:34 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id BB1111804BD for ; Sun, 15 Aug 2021 04:05:14 -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=-0.7 required=5.0 tests=BAYES_05,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, 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-il1-f179.google.com (mail-il1-f179.google.com [209.85.166.179]) (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 ; Sun, 15 Aug 2021 04:05:14 -0700 (PDT) Received: by mail-il1-f179.google.com with SMTP id j18so15584232ile.8 for ; Sun, 15 Aug 2021 04:05:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=S1UK5X2O19QlvXATBKPDHf+aYHVOP8aaBlJVESA+V5I=; b=deqiAKH6LOHAsAGlcrbXpHpDbq3ZkLvXZvqby+Pwc/V9suA6NU7pqTHS1BwXR55JRo H7gD3t/CofKYkR+QhlZm8Btweepabj324ZjNyaeq5bPD1aFzIhN1Qx7Q0PhGqnt3uoTv e1B2OL04IMw8YxdkelvZp0KhXO2w6xVkquXiuiYZo4iKD5oPboqExNvvy0FDoqbniRVW VgdGV0B2TXYJW6jaB/1odHP2G2M4eLdMwomHa0MNEBG00fROtp3Y2qqnmGz9TsRLJhj0 ZLR/QKwADQUH+V3OskJx5EFS2FGgCWeCbmb1/+9YhdcPG5r4VIQTkSVBQlp5vR0LVtJb h2hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=S1UK5X2O19QlvXATBKPDHf+aYHVOP8aaBlJVESA+V5I=; b=qekw13uSYWoh5G1B/mvzRUjPhAM56G3BGO0xa0Fg+637lFogZwONlfMYYovIcO1bWm sUaK8BqbKUB7HnMy9sh4LFSF3BopOusg9GTikVbyYrOKY/QvLx71eHPJVhGTmf89PrCg 2BW+6Tx923CxJS5TpoLay0nQQ1hnJQLMAoEEQmmaaUs5hSNRm0Mt67QgNf9rwJv5rTds z+5vW9XV/6jF4woKCz35nFMRTuUDabhDN3mNWY/LbLbR7dxWQ1BhXDTmh1P9DxsT68WU 8F0r7cuD6j8vgjdJbWNZ+hjS29qXMSfryFIcoHTnm6zdtKeWVOzK/HCans6UrR6PH9Hl HOpA== X-Gm-Message-State: AOAM532/aBYCICJ+1yLcA45A332V6YuE4h/K//NxeX3d2fJfgCPBsTKv M0wPRkTGBeEJEMUIeXltZHqMvDTULiq4ZaehmWM= X-Google-Smtp-Source: ABdhPJyl64kLMUFx9PyiRvokJVg5X/Z3//YVNlCbUNURsqdfW8gwbh+tedp2FlKHTQ7bkm151DyRqS2nGDH5cY0cduM= X-Received: by 2002:a05:6e02:b43:: with SMTP id f3mr8329307ilu.94.1629025510485; Sun, 15 Aug 2021 04:05:10 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Sun, 15 Aug 2021 13:05:00 +0200 Message-ID: To: Lynn Cc: Jordan LeDoux , PHP internals Content-Type: multipart/alternative; boundary="000000000000e1f61a05c9970e03" Subject: Re: [PHP-DEV] [RFC] Never For Argument Types From: deleugyn@gmail.com (Deleu) --000000000000e1f61a05c9970e03 Content-Type: text/plain; charset="UTF-8" On Sun, Aug 15, 2021, 12:43 Lynn wrote: > My only feedback is that it should not be called `never`. If I see `never` > as the parameter type, I read this as never being allowed to pass anything, > which means that `foo('something')` with `foo(never $something)` will > result in a compile error. The type `never` only makes sense from a return > type perspective: "Should it return? never". Perhaps `any` or `anything` > makes more sense? I've also seen a suggestion to name it `abstract`, and > maybe there are more suggestions I've missed. To me it also sounds like the > goal of `never` as a parameter type is different from the return type. From > my understanding one indicates that a type is required, while the other > indicates that nothing ever returns, giving it the same name is confusing. > While I 100% agree that never is not a good name for the parameter type, the reasoning is sound that never is now the bottom type in PHP since it was introduced. The fact that never as return type means it never returns, but as parameter type means you can specify anything is just the effect of being LSP complete. Since nothing can inherit never, then you can never return something, but because any method can broaden their input capacity, anything is broader than never. This is where I think that for me the best option would be to have a sugar aliasing for never provided by the engine. The potential aliases seem to be any, anything, something or abstract. Making it an alias does mean that the following would be allowed: ``` public function myMethod(never $weird): abstract; ``` But this is where coding style tools would come in and enforce that `never` be only used for return type while it's alias (any, anything, something, abstract) would only be used on parameter type. I guess the huge benefit of using abstract as the type alias is that it's already a reserved word. The more I think about it the more I like this RFC. > --000000000000e1f61a05c9970e03--