Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126871 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 185651A00BC for ; Thu, 20 Mar 2025 16:51:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1742489326; bh=yaxb5qnnWJOBx8sWKg41WO5CON7yIGX7u+Y6ykqO1CQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Q0wfJ8JMTT2fqE2RempL8wnbvPO56JOzZSBA3pEzymCOnIwUJ5vZSgrA+/XFRl7ni TjOwGaE/KsO18tW0L5bWNHudfvKlZA7Ydoc6HfSJVIim4onr//SpsFj79JhEQD2Esq FGx1J6KkCRKkPZmW3aZYElYV5D2U3G1dp3jkREd5U00Q/JRExTpeMHzFqahPkmGsAv ILk6e0Kd8DrXauk+zK05H6yj2mUX1+UGpvj1+f9t1FPbllkfx0s7w0qvXnaGPGzpK7 ylnYXY5DdRRNrG7svydYY/RYeixkz7qVeKpNetSQay1/ap0yTUjTOKyNy9hy9iv40Y O1O0PxCIU/G+Q== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 468BE1801D7 for ; Thu, 20 Mar 2025 16:48:45 +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=-2.0 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_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-vk1-f180.google.com (mail-vk1-f180.google.com [209.85.221.180]) (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 16:48:45 +0000 (UTC) Received: by mail-vk1-f180.google.com with SMTP id 71dfb90a1353d-5242f137a1eso486157e0c.1 for ; Thu, 20 Mar 2025 09:51:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742489475; x=1743094275; 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=yaxb5qnnWJOBx8sWKg41WO5CON7yIGX7u+Y6ykqO1CQ=; b=NoINNPasysB4lZzUJPeX4i/zDhZay9UC+x3oj6gXJwtBrMw0PqjSjnO+l3hVQomsi5 cEe2CWYxDf3cShNGx5b4rPXA57VXD9tHULNArocPlsTYLog2+nk563GKjhkWe7fqiHgR 7OOlvU0eQRxmQkgD98qefithe56tLzLcVPMZUu5zU56UXntf26cY9deLvMAFYzirTwhh 4CoCcmFmeMP0pL7Z7hGmGOmjchy+qR08lBnoWFzYeWmGa8V1KOl48TUZIbAfZMFibtpy 9oozRb/bcUQFkybH1JW7oYMOXKQmxD6KmIGQ/xYE2NhKdol2q1Eh5FAAc/LP+S71XeTn ZyVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742489475; x=1743094275; 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=yaxb5qnnWJOBx8sWKg41WO5CON7yIGX7u+Y6ykqO1CQ=; b=M2BXaDJYrBo43rL3P7lsHLuTk6NnaOHf+LhmSn5cO74UWrQQu95knKpHWch40q+A/Z GDPPwVhWhgANWxhqOjs2DDmyG7J4rd9LyulXrc1xj7zh1aHrEdZsWy0fLODxQTSVyIMk mGBrGrK5daZ9Gk7xO2Ku9xWqVvSJZSdvIofrQ42mxY+gtEhLQZFYh5651kFBHfkV1ca3 x4T+IY+1mztJNSr0dOzv2xDtNfDecn+BeZYQkuCxoxI9kHeHmzA8hTJaYo+0NcU9qjyq YY1fTJtZ+iTTR6kJ+EogHMLNSiIJyKgmiHJ4BfJ37RclQF4Etta899Nh6oOdt7V1KJYr u2Ew== X-Gm-Message-State: AOJu0Yw0rquJ4dqwu8kah6qWGwb6IS/pUcqaVxVDydRdq6643hB+pq2+ l6nuHen6xTSz2NvLr7Cpto0gPlvaNv4dXNyPpOc/pWSRr8Mnal+XQ7p1vKys4A8EDqbdjnvuKR8 q5LsUFaEt+oUyFyfrPKkrEjOLtqCrDWHa X-Gm-Gg: ASbGncuDFCa8xw0j1W2JQ9yyVVB9m4DpaVy3S4uT+QYvd0o1qV8DRRSkkLx/s3fEll7 5uxum8rKX4TXpARbUmLkxFuYtYftt1h3BQjYPh7uKIK5otvwfgCvUqWEdModDVVDVNSwLftZALa hCtERPAcZVV9Tc/EUaDlaUYH1qVL4xWoaxTp1C0KQiMgRCdKHfiRWENz70Y5vszFXvVvMY X-Google-Smtp-Source: AGHT+IH/q0qERj2gEmy61R72yK6HqHw/yj73Yquigv5soekVEnt0gLAJWtYWdOGV6lhJFshkSwyHT5snKAB1OGKSsAQ= X-Received: by 2002:a05:6122:3401:b0:51f:3e67:75df with SMTP id 71dfb90a1353d-525a859a667mr167959e0c.10.1742489474878; Thu, 20 Mar 2025 09:51:14 -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 09:50:37 -0700 X-Gm-Features: AQ5f1JpHMPAUL-4v8dba6XGq5_-C6BexKCnLpX3ebzNx3VpElHvq2ARmwNnKGrY Message-ID: Subject: Re: [PHP-DEV] [RFC] [Discussion] Never parameters To: Matt Fonda Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary="0000000000002cd3ea0630c8f2f7" From: daniel.e.scherzer@gmail.com (Daniel Scherzer) --0000000000002cd3ea0630c8f2f7 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 neve= r > 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 know the specific > concrete type, which defeats the purpose of using an interface in the fir= st > place. > First, I would point out that I tried to make this limited to methods that 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 can always type against the implementation with the actual methods that are not never-typed. 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 are no promises about what parameters it accepts", the options would otherwise be * documenting that the method should exist, and checking for it, but not adding it to the interface directly so that PHP doesn't complain * having implementations "accept" parameters that they then manually throw errors for, c.f. https://3v4l.org/pTdMg The original inspiration which I discussed in the RFC is fixing the signature of the BackedEnum methods, which currently use the second option. > > See note from Nikita [1] from previous discussion which expands on this > idea more, and shows that generics is really what we need here. > > [1] https://externals.io/message/115712#115719 > > Best regards, > --Matthew > I agree that generics would be great and really useful, but should that stop never parameters? There has also been some discussion about generics on the inner classes RFC thread - should the dream of generics eventually stand in the way of independently-useful and smaller-scoped features now? -Daniel --0000000000002cd3ea0630c8f2f7 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Sun, Mar 16, 2025 at 12:31=E2=80=AFPM = Matt Fonda <matthewfonda@gmail= .com> wrote:
<= blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-l= eft:1px solid rgb(204,204,204);padding-left:1ex">
Hi Dan= iel,

I believe this feature essentially amounts to &q= uot;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 me= thod with a never parameter type, then we cannot actually call that method.= We'd need to know the specific concrete type, which defeats the purpos= e of 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 int= erfaces and abstract methods. You already can't call those directly, yo= u need to have a subclass. And you can always type against the implementati= on with the actual methods that are not never-typed.

So I would ask - if not `never` parameters, then what should users do? I= t seems like, for the use case of "the interface adds a method but the= re are no promises about what parameters it accepts", the options woul= d otherwise be
* documenting that the method should exist, and ch= ecking for it, but not adding it to the interface directly so that PHP does= n't complain
* having implementations "accept" para= meters that they then manually throw errors for, c.f.=C2=A0https://3v4l.org/pTdMg

The = original inspiration which I discussed in the RFC is fixing the signature o= f the BackedEnum methods, which currently use the second option.
= =C2=A0

See note from Nikita [1] from previous discussion which exp= ands on this idea more, and shows that generics is really what we need here= .


Best regards,
--Matthew

I agree that generics = would be great and really useful, but should that stop never parameters? Th= ere has also been some discussion about generics on the inner classes RFC t= hread - should the dream of generics eventually stand in the way of indepen= dently-useful and smaller-scoped features now?

-Da= niel
=C2=A0
--0000000000002cd3ea0630c8f2f7--