1.2.833. 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.833.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.833.2. Specs

Short name

Functions/NoReturnUsed

Rulesets

All, Analyze, Suggestions

Exakat since

0.11.3

PHP Version

All

Severity

Minor

Time To Fix

Slow (1 hour)

Precision

High

Features

return

Examples

SPIP, LiveZilla

Available in

Entreprise Edition, Exakat Cloud