throw
expression used in PHP < 8.0 PHP-W1017throw
expression is allowed only in PHP >= 8.0.
Trying to use it in earlier PHP versions will give you an error.
class Example
{
public function doSomething(bool $b): void
{
$b ? true : throw new \Exception();
throw new \Exception();
}
}
throw
.