1.2.929. PHP 8.1 Typehints

A new scalar typehint was introduced : never.

It can’t be used before PHP 8.1, and will be confused with classes or interfaces.

<?php

function test() : never
{
    exit();
}

?>

See also PHP RFC: noreturn type.

1.2.929.1. Specs

Short name

Php/PHP81scalartypehints

Rulesets

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

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

scalar-typehint

Available in

Entreprise Edition, Exakat Cloud