1.2.762. Never Keyword

Never becomes a PHP keyword. It is used for typing functions which never returns anything (either dies or throw an exception).

It should be avoided in namespaces, classes, traits and interfaces. Methods, constants and functions are OK.

<?php

// This is OK
function never() { }

// This is no OK
class never {  }

?>

See also never and PHP RFC: noreturn type.

1.2.762.1. Suggestions

  • Rename the classes, traits and interfaces with a different name.

1.2.762.2. Specs

Short name

Php/NeverKeyword

Rulesets

All, Analyze, Appinfo, Changed Behavior, CompatibilityPHP81

Exakat since

2.3.0

PHP Version

With PHP 8.1 and older

Severity

Major

Time To Fix

Slow (1 hour)

Changed Behavior

PHP 8.1 - More

Precision

Very high

Features

never

Available in

Entreprise Edition, Exakat Cloud