On Sun, Aug 15, 2021, 12:43 Lynn <kja...@gmail.com> wrote:

> My only feedback is that it should not be called `never`. If I see `never`
> as the parameter type, I read this as never being allowed to pass anything,
> which means that `foo('something')` with `foo(never $something)` will
> result in a compile error. The type `never` only makes sense from a return
> type perspective: "Should it return? never". Perhaps `any` or `anything`
> makes more sense? I've also seen a suggestion to name it `abstract`, and
> maybe there are more suggestions I've missed. To me it also sounds like the
> goal of `never` as a parameter type is different from the return type. From
> my understanding one indicates that a type is required, while the other
> indicates that nothing ever returns, giving it the same name is confusing.
>

While I 100% agree that never is not a good name for the parameter type,
the reasoning is sound that never is now the bottom type in PHP since it
was introduced.

The fact that never as return type means it never returns, but as parameter
type means you can specify anything is just the effect of being LSP
complete. Since nothing can inherit never, then you can never return
something, but because any method can broaden their input capacity,
anything is broader than never.

This is where I think that for me the best option would be to have a sugar
aliasing for never provided by the engine. The potential aliases seem to be
any, anything, something or abstract. Making it an alias does mean that the
following would be allowed:


```
public function myMethod(never $weird): abstract;
```

But this is where coding style tools would come in and enforce that `never`
be only used for return type while it's alias (any, anything, something,
abstract) would only be used on parameter type.

I guess the huge benefit of using abstract as the type alias is that it's
already a reserved word. The more I think about it the more I like this RFC.

>

Reply via email to