# [RFC] [VOTE] Allow null and false as stand-alone types

- Thread: https://externals.io/message/117314
- Original archive: https://news-web.php.net/php.internals/117314
- Started by G. P. B. on 2022-03-12T17:31:55+00:00
- Messages: 8
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #117314 — G. P. B. — 2022-03-12T17:31:55+00:00

URL: https://externals.io/message/117314#117314

I've started voting for the Allow null and false as stand-alone types RFC:
https://wiki.php.net/rfc/null-false-standalone-types

Voting will last for 2 weeks until 26th of March.

Best regards,

George P. Banyard

---

## #117316 — David Rodrigues — 2022-03-12T18:18:24+00:00

URL: https://externals.io/message/117314#117316 · In reply to: #117314

Maybe I'm a little late to this discussion, but is there any reason why
*false|null* is allowed but *true|null* is not?

I can think of few cases where *true|null* could be interesting, but I've
been through situations like this.


Atenciosamente,
David Rodrigues


Em sáb., 12 de mar. de 2022 às 14:32, G. P. B. <george.banyard@gmail.com>
escreveu:

> I've started voting for the Allow null and false as stand-alone types RFC:
> https://wiki.php.net/rfc/null-false-standalone-types
>
> Voting will last for 2 weeks until 26th of March.
>
> Best regards,
>
> George P. Banyard

---

## #117317 — G. P. B. — 2022-03-12T18:30:00+00:00

URL: https://externals.io/message/117314#117317 · In reply to: #117316

On Sat, 12 Mar 2022 at 18:18, David Rodrigues <david.proweb@gmail.com>
wrote:

> Maybe I'm a little late to this discussion, but is there any reason why
> *false|null* is allowed but *true|null* is not?
>
> I can think of few cases where *true|null* could be interesting, but I've
> been through situations like this.
>

true is not a type in PHP compared to false, therefore it is not included.
I'm working on a proposal to add true as a type to PHP, but that's a
seperate RFC and discussion.

Best regards,

George P. Banyard

---

## #117334 — come@chilliet.eu — 2022-03-15T15:41:45+00:00

URL: https://externals.io/message/117314#117334 · In reply to: #117317

Le samedi 12 mars 2022, 19:30:00 CET G. P. B. a écrit :
> true is not a type in PHP compared to false, therefore it is not included.
> I'm working on a proposal to add true as a type to PHP, but that's a
> seperate RFC and discussion.

Was there ever an RFC for adding literal values to the type system?
This would solve all these problems by allowing stuff like:

function foobar(): "foo"|"bar"|true {
}

Côme

---

## #117335 — Derick Rethans — 2022-03-15T16:16:03+00:00

URL: https://externals.io/message/117314#117335 · In reply to: #117334

>Le samedi 12 mars 2022, 19:30:00 CET G. P. B. a écrit :
> > […]
>
>Was there ever an RFC for adding literal values to the type system?
>This would solve all these problems by allowing stuff like:
>
>function foobar(): "foo"|"bar"|true {
>}

It's called enums ;-), so yes! 

cheers 
Derick

---

## #117357 — Levi Morrison via internals — 2022-03-17T15:54:26+00:00

URL: https://externals.io/message/117314#117357 · In reply to: #117314

>
> I've started voting for the Allow null and false as stand-alone types RFC:
> https://wiki.php.net/rfc/null-false-standalone-types
>
> Voting will last for 2 weeks until 26th of March.
>
> Best regards,
>
> George P. Banyard

Hello,

I have voted yes, despite this clause:

> Moreover, a function which has a void return type must only use return; whereas one with null must use return null;.

IMO, it should allow any expression including just `return;` and let
the runtime fail if it needs to.

---

## #117358 — G. P. B. — 2022-03-17T16:09:00+00:00

URL: https://externals.io/message/117314#117358 · In reply to: #117357

On Thu, 17 Mar 2022 at 15:54, Levi Morrison <levi.morrison@datadoghq.com>
wrote:

> On Sat, Mar 12, 2022 at 10:32 AM G. P. B. <george.banyard@gmail.com>
> wrote:
> > […]
> RFC:
> > […]
>
> Hello,
>
> I have voted yes, despite this clause:
>
> > […]
> whereas one with null must use return null;.
>
> IMO, it should allow any expression including just `return;` and let
> the runtime fail if it needs to.
>

This behaviour is the current behaviour in PHP, see:
https://3v4l.org/1m0Mk
and
https://3v4l.org/d19rd

It might make sense to change this, but this is out of scope for this RFC.

Best regards,

George P. Banyard

---

## #117435 — G. P. B. — 2022-03-27T11:12:16+00:00

URL: https://externals.io/message/117314#117435 · In reply to: #117314

Hello internals,

The RFC has been accepted unanimously in favour with 38 votes.

Best regards,

George P. Banyard
