1.2.1423. Void Is Not A Reference¶
It is not possible to return by reference, in a method that is typed void. The returned value is a literal
null
.
<?php
function &foo() : void {}
?>
1.2.1423.1. Suggestions¶
Remove the void type
Remove the reference on the method
1.2.1423.2. Specs¶
Short name |
Functions/VoidIsNotAReference |
Rulesets |
All, Analyze, Changed Behavior, CompatibilityPHP53, CompatibilityPHP54, CompatibilityPHP55, CompatibilityPHP56, CompatibilityPHP70, CompatibilityPHP71, CompatibilityPHP72, CompatibilityPHP73, CompatibilityPHP74, CompatibilityPHP80, CompatibilityPHP81 |
Exakat since |
2.6.2 |
PHP Version |
With PHP 8.1 and older |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Changed Behavior |
PHP 8.1 - More |
Precision |
Very high |
Available in |