Re: [PHP-DEV] [RFC] [Discussion] Never parameters

2025-04-05 Thread Daniel Scherzer
On Thu, Mar 20, 2025 at 4:00 PM Larry Garfield wrote: > I have a use case for this in Serde, so would be in favor. > > We should not block this kind of improvement on the hope of generics. > Worst case, we have this plus generics so you have options, how terrible. > > Would you mind sharing detai

Re: [PHP-DEV] [RFC] [Discussion] Never parameters

2025-04-05 Thread Juris Evertovskis
On 2025-03-20 18:50, Daniel Scherzer wrote: The original inspiration which I discussed in the RFC is fixing the signature of the BackedEnum methods, which currently use the second option. Hey, I'm not opposed to having a bottom type, but the `try`/`tryFrom` issue feels caused by another

Re: [PHP-DEV] [RFC] [Discussion] Never parameters

2025-04-05 Thread Larry Garfield
On Thu, Mar 20, 2025, at 11:24 AM, Gina P. Banyard wrote: > As the person that had the initial discussion in R11 with Jordan [1] > never as a parameter type for an interface actually is not the solution > for "poor man generics". > Matthew Fonda [2] already replied to the thread pointing out the

Re: [PHP-DEV] [RFC] [Discussion] Never parameters

2025-04-04 Thread Matt Fonda
On Thu, Mar 20, 2025 at 9:51 AM Daniel Scherzer wrote: > On Sun, Mar 16, 2025 at 12:31 PM 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

Re: [PHP-DEV] [RFC] [Discussion] Never parameters

2025-04-04 Thread Tim Düsterhus
Hi Am 2025-03-20 21:27, schrieb Matt Fonda: 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? It would more cleanly allow for userland / PHPDoc-based generics, wh

Re: [PHP-DEV] [RFC] [Discussion] Never parameters

2025-03-31 Thread Matt Fonda
Hi Larry, On Fri, Mar 28, 2025 at 7:48 PM Larry Garfield wrote: > I have to think people are misunderstanding Nikita's earlier comment, or > perhaps that he phrased it poorly. > > The determination of whether a method call is type-compatible with the > parameters passed to it is made *at runtime

Re: [PHP-DEV] [RFC] [Discussion] Never parameters

2025-03-28 Thread Larry Garfield
On Fri, Mar 28, 2025, at 3:42 PM, Matt Fonda wrote: > Hi Tim and Larry, > > Thanks for sharing examples. I'm not sure I follow how never parameters > help in either of these cases. As far as I can tell, the problem > remains that these methods can't actually be called. > I share Nikita's sentime

Re: [PHP-DEV] [RFC] [Discussion] Never parameters

2025-03-28 Thread Matt Fonda
Hi Tim and Larry, Thanks for sharing examples. I'm not sure I follow how never parameters help in either of these cases. As far as I can tell, the problem remains that these methods can't actually be called. On Fri, Mar 21, 2025 at 4:50 AM Tim Düsterhus wrote: > Am 2025-03-20 21:27, schrieb Mat

Re: [PHP-DEV] [RFC] [Discussion] Never parameters

2025-03-28 Thread Tim Düsterhus
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 { pubic function

Re: [PHP-DEV] [RFC] [Discussion] Never parameters

2025-03-28 Thread Tim Düsterhus
Hi Am 2025-03-25 21:42, schrieb Rowan Tommins [IMSoP]: And I've seen plenty of junior devs struggle with simple things like the difference between "nullable" and "optional", so I worry that making the type system too rich will lose PHP its reputation as an approachable language. It's possib

Re: [PHP-DEV] [RFC] [Discussion] Never parameters

2025-03-25 Thread Rowan Tommins [IMSoP]
On 25 March 2025 18:14:21 GMT, Daniel Scherzer wrote: >On Tue, Mar 25, 2025 at 11:01 AM Rowan Tommins [IMSoP] >wrote: > >> >> I don't think the language should pretend to support something that it >> doesn't >> > >I don't see what the pretending is here - the engine supports declaring >that a

Re: [PHP-DEV] [RFC] [Discussion] Never parameters

2025-03-25 Thread Daniel Scherzer
On Tue, Mar 25, 2025 at 11:01 AM Rowan Tommins [IMSoP] wrote: > > I don't think the language should pretend to support something that it > doesn't > I don't see what the pretending is here - the engine supports declaring that a method must accept a parameter but makes no promises about the type

Re: [PHP-DEV] [RFC] [Discussion] Never parameters

2025-03-21 Thread Gina P. Banyard
On Thursday, 20 March 2025 at 16:57, Larry Garfield wrote: > On Thu, Mar 20, 2025, at 11:24 AM, Gina P. Banyard wrote: > > > As the person that had the initial discussion in R11 with Jordan [1] > > never as a parameter type for an interface actually is not the solution > > for "poor man generic

Re: [PHP-DEV] [RFC] [Discussion] Never parameters

2025-03-21 Thread Rowan Tommins [IMSoP]
On 21/03/2025 11:50, Tim Düsterhus wrote: Am 2025-03-20 21:27, schrieb Matt Fonda: 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? It would more cleanly allow fo

Re: [PHP-DEV] [RFC] [Discussion] Never parameters

2025-03-21 Thread Larry Garfield
On Thu, Mar 20, 2025, at 6:02 PM, Daniel Scherzer wrote: > On Thu, Mar 20, 2025 at 4:00 PM Larry Garfield wrote: >> I have a use case for this in Serde, so would be in favor. >> >> We should not block this kind of improvement on the hope of generics. Worst >> case, we have this plus generics so

Re: [PHP-DEV] [RFC] [Discussion] Never parameters

2025-03-21 Thread Tim Düsterhus
Hi Am 2025-03-20 21:04, schrieb Juris Evertovskis: I'm not opposed to having a bottom type, but the `try`/`tryFrom` issue feels caused by another shortcoming. In my view`from` and `tryFrom` are factory methods that construct an instance by being called on the class itself. As such they should

Re: [PHP-DEV] [RFC] [Discussion] Never parameters

2025-03-20 Thread Daniel Scherzer
On Sun, Mar 16, 2025 at 12:31 PM 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, > t

Re: [PHP-DEV] [RFC] [Discussion] Never parameters

2025-03-20 Thread Gina P. Banyard
On Tuesday, 11 March 2025 at 21:45, Larry Garfield wrote: > On Mon, Mar 10, 2025, at 2:05 PM, Daniel Scherzer 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.ne

Re: [PHP-DEV] [RFC] [Discussion] Never parameters

2025-03-16 Thread Matt Fonda
On Mon, Mar 10, 2025 at 12:07 PM Daniel Scherzer < daniel.e.scher...@gmail.com> 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: htt

Re: [PHP-DEV] [RFC] [Discussion] Never parameters

2025-03-13 Thread Larry Garfield
On Thu, Mar 13, 2025, at 10:35 AM, Tim Düsterhus wrote: > Hi > > Am 2025-03-11 22:45, schrieb Larry Garfield: >> We should not block this kind of improvement on the hope of generics. >> Worst case, we have this plus generics so you have options, how >> terrible. > > In this case, I agree. This i

Re: [PHP-DEV] [RFC] [Discussion] Never parameters

2025-03-13 Thread Tim Düsterhus
Hi Am 2025-03-11 22:45, schrieb Larry Garfield: We should not block this kind of improvement on the hope of generics. Worst case, we have this plus generics so you have options, how terrible. In this case, I agree. This is an obvious addition to the type system that uses the existing infras

Re: [PHP-DEV] [RFC] [Discussion] Never parameters

2025-03-12 Thread Yogarine
On 10 Mar 2025, at 20:07, Daniel Scherzer 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/18

Re: [PHP-DEV] [RFC] [Discussion] Never parameters

2025-03-11 Thread Rob Landers
> >> I would also personally prefer associated types: ... This at least lets you >> ensure the "other point" is the same type in both functions, though >> personally, I'd rather just have generics. > > I'd also like to have generics, but that isn't something I can implement > myself. Associa

Re: [PHP-DEV] [RFC] [Discussion] Never parameters

2025-03-11 Thread Larry Garfield
On Mon, Mar 10, 2025, at 2:05 PM, Daniel Scherzer 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/pu

Re: [PHP-DEV] [RFC] [Discussion] Never parameters

2025-03-11 Thread Daniel Scherzer
[responding to multiple people instead of spamming multiple emails, I hope that is okay] On Mon, Mar 10, 2025 at 12:38 PM Eugene Sidelnyk wrote: > > Yet, do you think it's reasonable that "never" type should be used rather > than "void"? From what I know, never - is a special type used whe

Re: [PHP-DEV] [RFC] [Discussion] Never parameters

2025-03-11 Thread Eugene Sidelnyk
> Hi internals, > > I'd like to start discussion on a new RFC about allowing `never` for > parameter types when declaring a method. > At first signature seemed somewhat confusing to me, but now it makes perfect sense. Type-wise, about LSP, I find it logical that more concrete implementations cou

Re: [PHP-DEV] [RFC] [Discussion] Never parameters

2025-03-11 Thread Ilija Tovilo
Hi Daniel On Mon, Mar 10, 2025 at 8:06 PM Daniel Scherzer wrote: > > 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/180

[PHP-DEV] [RFC] [Discussion] Never parameters

2025-03-11 Thread Daniel Scherzer
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

Re: [PHP-DEV] [RFC] [Discussion] Never parameters

2025-03-10 Thread Rob Landers
On Mon, Mar 10, 2025, at 20:05, Daniel Scherzer 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/pu

Re: [PHP-DEV] [RFC] [Discussion] Never parameters

2025-03-10 Thread John Bafford
Hi Daniel, > On Mar 11, 2025, at 08:05, Daniel Scherzer > 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.co