Re: [RFC] Allow null as standalone type

From: Date: Tue, 05 Oct 2021 14:47:36 +0000
Subject: Re: [RFC] Allow null as standalone type
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-116228@lists.php.net to get a copy of this message
On Tue, Oct 5, 2021 at 4:08 PM Côme Chilliet <come@chilliet.eu> wrote:

>
> Why would function a(): null|false {} be legal but function b(): null|0
> would not?
>
> This is inconsistent to me. And adding null, then false, then true for the
> sake of completeness feels like avoiding to treat the static value as type
> hint subject.
>

I'm not opposed to having values that aren't objects. Feels like a
shorthand notation of enums, or the subset thereof.

```php
function getType(): 'dropdown'|'textfield';
function getExitCode(): 0|1|255;
```


Thread (12 messages)

« previous php.internals (#116228) next »