Re: [RFC] [Discussion] Never parameters

From: Date: Sun, 16 Mar 2025 19:30:34 +0000
Subject: Re: [RFC] [Discussion] Never parameters
References: 1  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
On Mon, Mar 10, 2025 at 12:07 PM Daniel Scherzer <
[email protected]> wrote:

> Hi internals,
>
> I'd like to start discussion on a new RFC about allowing never for
> parameter types when declaring a method.
>
> * RFC: https://wiki.php.net/rfc/never-parameters-v2
> * Implementation: https://github.com/php/php-src/pull/18016
>
> -Daniel
>

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 know the specific
concrete type, which defeats the purpose of using an interface in the first
place.

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


Thread (33 messages)

« previous php.internals (#126791) next »