1.2.841. No Return Used¶
The return value of the following methods are never used. The return argument may be dropped from the code, as it is dead code.
This analysis supports functions and static methods, when a definition may be found. It doesn’t support method calls.
<?php
function foo($a = 1) { return 1; }
foo();
foo();
foo();
foo();
foo();
foo();
// This function doesn't return anything.
function foo2() { }
// The following function are used in an expression, thus the return is important
function foo3() { return 1;}
function foo4() { return 1;}
function foo5() { return 1;}
foo3() + 1;
$a = foo4();
foo(foo5());
?>
1.2.841.1. Connex PHP features¶
1.2.841.1.1. Suggestions¶
Remove the return statement in the function
Actually use the value returned by the method, for test or combination with other values
1.2.841.1.2. Specs¶
Short name |
Functions/NoReturnUsed |
Rulesets |
|
Exakat since |
0.11.3 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Slow (1 hour) |
Precision |
High |
Examples |
|
Available in |