Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126880 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 19E321A00BC for ; Thu, 20 Mar 2025 20:28:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1742502353; bh=ZJySu+EZ+ZVgr/uZdgiIlBr+GYtC/483kJNRtpbSaqM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=IeH32ZGICse8T84pIGl84iqfiwu1Lu8yrT8PzAhhg7AOHS73oaVYMNsdA6So8l7Ah GUAwL0UOJllYMuepJ9JSAFttnLWtGlijPPdHPvWwXKa/qnZevvza90SjZEpnSWkuWo Ds3LcgP50fzQyzjT0lrfW+JQYmT1RsGaruFsCKaUbcc2zFVZ6iixinNWGT5Pfx1zF3 8OhCoUZ1y9rpxrHSfvmxsOvDh7X7VymsAKIvZ2uTZP7m8HvIUJEa03q4Nicbi2mPgu +BJOPtIkTCTVSGfOsUsnST/enblrQGC5NX9gyWi2ykYIj32SWz1n/z6fMRdwfvT2hB b/nqME+J9oOuQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 4B1DD1801D7 for ; Thu, 20 Mar 2025 20:25:52 +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.2 required=5.0 tests=BAYES_40,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (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 ; Thu, 20 Mar 2025 20:25:52 +0000 (UTC) Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-224191d92e4so25378675ad.3 for ; Thu, 20 Mar 2025 13:28:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742502502; x=1743107302; 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=lpBGvBGwOmKfFb20lyrUQ+UMJhDfC/MNEO1BIRott2E=; b=lhZNNGNyXGJeKMxX8kl4yW9HSaTCe4G4sdsNeEoB5ScA+1rcQcYe2OvdK4/bgD4De0 MCTwdSdEbFkREUsx/M6Q219pUIU5UPkaiNTp/DV8Hf3XrE3TnjHNG/Agmqym8Mvpkeki jCS7F3jPcjsAjqNZia4Iw0gerVDQYSQPRZWzd0C28RdeS8zDLzgMxy1DjZCzkVYrqDaJ deg27sdHZDCdH5s0eBj0oDuxh6j357T2WsSDNePzeomdOMB20LTxCnZFhW3IsKZTm10O gaqz5wucocMrR0ElJF1wZ87IWjpCsRvcywy9boPM5Y9pf8ggz3jQCXVrNSLUtfPB/qmL bIfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742502502; x=1743107302; 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=lpBGvBGwOmKfFb20lyrUQ+UMJhDfC/MNEO1BIRott2E=; b=DZJhBCIpnPN8PYzBzp7A3Q6EISOEEmoPXFSSZ1HwUKW8agI8QM1zk902TD/fUZPqoZ yOvTPVflJz3c99Lxl7cTQWcPy57Ud42g7kzZbiY20h5g5Lpw2sbhcC6XE25TbLdA2fzY i2Jd1i+LXTh6w/5tEDwA71v4dOJRZk1owevt8YHPrSmuzHZGYlr5CqKT1BlFbGOSOW34 FFc9n9Xd7fwPP9sg4cQHuSPLSzvUKasGAPSaKzo5ljAQnrw2gryRjYEEgMbJowhUhOZf QmZNPdzbu1MYwU85TzC8pIMLQonMHX0sOKgcE5GqsbWkvOEDX1M5MQp4LM4w9g7GLD0a iM5A== X-Gm-Message-State: AOJu0Yz2Sf4KhoIkwKTaOJHVuLK4xGTzJEm/i7a84kZGfO7DZ3y4qg9D iFTXJEPiDnSMTTEFZOWwM6fLyFWviidcNVHQedh1kbHmxAxi0xhErMQIqhvr2/84RSKKQMo8CwV TJBqayiJdNSYaPgVJBgRCVQFw8Ma4TQ== X-Gm-Gg: ASbGnctfXukc2bMkJSWV0YvguKPi+N6yZFFqfLVZLo6GcEdLdlXuFEESBgiDE1b2rkH u6gH2prabDxwtmxRPjQ3/yOZhXJ8PLU7QWsVmr5TiuMAcKZ2Qxy6hURY3m2TFrPN4K26qRKW2za zHNsp8v2Ib/dr+hK/0Ltvw7jWK1fazhQ+MpW66WTMqlXzs26ZW3P4iSIbt X-Google-Smtp-Source: AGHT+IEk1uIM62H3tLgqF/R3LNab4+M33a/246Mgb5qOcUody9Ge3xJnXpu43QEVa56YBp1bXpxG2q66QizWClGAWkY= X-Received: by 2002:a17:90b:4ad1:b0:2ff:62f3:5b19 with SMTP id 98e67ed59e1d1-3030fe7f529mr738222a91.13.1742502501644; Thu, 20 Mar 2025 13:28:21 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 20 Mar 2025 13:27:54 -0700 X-Gm-Features: AQ5f1Jo7msPtkJh3MOBKwC3ltzMdahilMSw0Y4EsHKOoWq9QODxneopjclt6504 Message-ID: Subject: Re: [PHP-DEV] [RFC] [Discussion] Never parameters To: Daniel Scherzer Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary="000000000000a183cf0630cbfa00" From: matthewfonda@gmail.com (Matt Fonda) --000000000000a183cf0630cbfa00 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Mar 20, 2025 at 9:51=E2=80=AFAM Daniel Scherzer wrote: > On Sun, Mar 16, 2025 at 12:31=E2=80=AFPM Matt Fonda > wrote: > >> Hi Daniel, >> >> I believe this feature essentially amounts to "add methods which can >> never be called", which in my mind makes no sense. If a method types >> against an interface, and that interface uses a method with a never >> parameter type, then we cannot actually call that method. We'd need to k= now >> the specific concrete type, which defeats the purpose of using an interf= ace >> in the first place. >> > > First, I would point out that I tried to make this limited to methods tha= t > already cannot be called - only to interfaces and abstract methods. You > already can't call those directly, you need to have a subclass. And you c= an > always type against the implementation with the actual methods that are n= ot > never-typed. > To clarify, what I mean by calling methods on an interface is typing against the interface (for example, as a parameter to a method/function) and then calling methods defined by the interface. As users of the interface, we can call methods on it without knowing or caring which specific subclass we're actually working with. In my mind, this is the entire point of interfaces. We can write code like the following: function foo(SomeInterface $i) { // ... call $i->someMethod(); } Within foo, all we know is that $i is an instance of SomeInterface. We can call any method on $i that SomeInterface defines. If one of those methods had a never argument, then we could never call it. If we did want to call the method with a never argument, then we'd need to know a specific subclass and what type it overrides never with. At that point, we're no longer using the interface; we're instead using the specific subclass, entirely eliminating the need for the interface in the first place. > So I would ask - if not `never` parameters, then what should users do? It > seems like, for the use case of "the interface adds a method but there ar= e > no promises about what parameters it accepts" > If an interface adds a method but makes no promises about what parameters it accepts, then why is it part of the interface in the first place--why add a method that can't be used? Best regards, --Matthew --000000000000a183cf0630cbfa00 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Thu, Mar 20, 2025 at = 9:51=E2=80=AFAM Daniel Scherzer <daniel.e.scherzer@gmail.com> wrote:
<= div class=3D"gmail_quote">
On Sun, Mar 16, 2025 at 12:31=E2=80=AFPM= Matt Fonda <matthewfonda@gmail.com> wrote:
Hi Daniel= ,

I believe this feature essentially amounts to "= ;add methods which can never be called", which in my mind makes no sen= se. If a method types against an interface, and that interface uses a metho= d with a never parameter type, then we cannot actually call that method. We= 'd need to know the specific concrete type, which defeats the purpose o= f using an interface in the first place.

First, I would point out that I tried to = make this limited to methods that already cannot be called - only to interf= aces and abstract methods. You already can't call those directly, you n= eed to have a subclass. And you can always type against the implementation = with the actual methods that are not never-typed.

To clarify, what I mean by calling methods on an i= nterface is typing against the interface (for example, as a parameter to a = method/function) and then calling methods defined by the interface. As user= s of the interface, we can call methods on it without knowing or caring whi= ch specific subclass we're actually working with. In my mind, this is t= he entire point of interfaces. We can write code like the following:
<= div>
function foo(SomeInterface $i) {
=C2=A0 =C2=A0= // ... call $i->someMethod();
}

With= in foo, all we know is that $i is an instance of SomeInterface. We can call= any method on $i that SomeInterface defines. If one of those methods had a= never argument, then we could never call it.

If w= e did want to call the method with a never argument, then we'd need to = know a specific subclass and what type it overrides never with. At that poi= nt, we're no longer using the interface; we're instead using the sp= ecific subclass, entirely eliminating the need for the interface in the fir= st place.
=C2=A0
So I would ask - if not = `never` parameters, then what should users do? It seems like, for the use c= ase of "the interface adds a method but there are no promises about wh= at parameters it accepts"

<= div>If an interface adds a method but makes no promises about what paramete= rs it accepts, then why is it part of the interface in the first place--why= add a method that can't be used?

Best regards= ,
--Matthew
--000000000000a183cf0630cbfa00--