What’s New in PHP 8 ?
Union types
public function foo(Foo|Bar $input): int|float;
The nullsafe operator
$dateAsString = $startDate ? $startDate->asDateTimeString() : null;
$dateAsString = $booking->getStartDate()?->asDateTimeString();
New mixed
type
function bar(): ?mixed {}
Throw expression
$triggerError = fn () => throw new MyError();
$foo = $bar[‘offset’] ?? throw new OffsetDoesNotExist(‘offset’);
Comments