1.2.923. PHP 8.0 Typehints

New scalar typehints were introduced : mixed and false.

They can’t be used before PHP 8.0, and will be confused with classes or interfaces, or generate a parse error.

<?php

function test(mixed $a) : false|other
{
    //....
}

?>

See also PHP RFC: noreturn type.

1.2.923.1. Specs

Short name

Php/PHP80scalartypehints

Rulesets

All, Changed Behavior, CompatibilityPHP53, CompatibilityPHP54, CompatibilityPHP55, CompatibilityPHP56, CompatibilityPHP70, CompatibilityPHP71, CompatibilityPHP72, CompatibilityPHP73, CompatibilityPHP74

Exakat since

2.3.0

PHP Version

With PHP 8.1 and more recent

Severity

Minor

Time To Fix

Instant (5 mins)

Precision

Very high

Features

mixed, false, typehint

Available in

Entreprise Edition, Exakat Cloud