
The JIT - just in time - compiler promises significant performance improvements, albeit not always within the context of web requests. Public function bar ( ?Bar $bar): void # JIT RFC Furthermore, nullable unions can be written using |null, or by using the existing ? notation: public function foo ( Foo|null $foo): void

Note that void can never be part of a union type, since it indicates "no return value at all". public function foo ( Foo|Bar $input): int| float Union types are a collection of two or more types which indicate that either one of those can be used.

Given the dynamically typed nature of PHP, there are lots of cases where union types can be useful. Let's start with all new features, it's quite a list!

Do you want to learn more about PHP 8.1? There's The Road to PHP 8.1.įor the next 10 days, you'll receive a daily email covering a new and exiting feature of PHP 8.1 afterwards you'll be automatically unsubscribed, so no spam or followup.
