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