1.2.763. Never Typehint Usage¶
Never is a typehint, which characterize methods that never return a value. It will either terminate the execution or throw an exception.
<?php
function redirect(string $url): never {
header('Location: ' . $url);
exit();
}
?>
See also The “never” Return Type for PHP.
1.2.763.1. Specs¶
Short name |
Php/NeverTypehintUsage |
Rulesets |
All, Appinfo, 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 |
|
Time To Fix |
|
Precision |
Very high |
Features |
typehint |
Available in |