« Named paramsReferencing functions »

Null type

General idea

PHP doesn't currently support a stand alone null type, despite that being the default type that all functions that lack an explicit return statement have.

Hurdles to overcome


PHP programmers don't understand type systems. People have been using void and a lot of them will think that null is a duplicate type


Implemented in PHP 8.2 along with false as a type.


It wasn't included in the union types RFC because:

Allowing it as a standalone type would make both function foo(): void and function foo(): null legal function signatures, with similar but not identical semantics. This would negatively impact teachability for an unclear benefit.