Re: [RFC] [Discussion] Never parameters

From: Date: Fri, 28 Mar 2025 11:18:45 +0000
Subject: Re: [RFC] [Discussion] Never parameters
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
Hi

Am 2025-03-21 21:41, schrieb Gina P. Banyard:
Am I following that? Because just from writing that I am not sure I agree, which means I may be misunderstanding. :-)
I am saying: interface I { pubic function foo(never $a); } can ***not*** be "upgraded" to interface I<A> {
    pubic function foo(A $a);
} whereas it is possible to go from interface I { pubic function foo(mixed $a); } to interface I<A> {
    pubic function foo(A $a);
} The implementing classes are completely irrelevant in this context.
I don't follow here. Neither interface “could be upgraded” to make use of generics, since the user would need to specify the type for A. However the former could just be upgraded to I<never> and the implementing class could still override the parameter type with some specific type. This would not be better than the old interface with the hardcoded never type, but also not worse. The latter would need to be upgraded to I<mixed>, since otherwise you would be restricting passing types that you formerly didn't, which makes the entire exercise useless. Best regards Tim Düsterhus

Thread (33 messages)

« previous php.internals (#126967) next »