1.2.1299. Unused Returned Value

The function called returns a value, which is ignored.

Usually, this is a sign of dead code, or a missed check on the results of the functioncall. At times, it may be a valid call if the function has voluntarily no return value.

It is recommended to add a check on the return value, or remove the call.

Note that this analysis ignores functions that return void (same meaning that PHP 7.1 : return ; or no return in the function body).

<?php

// simplest form
function foo() {
    return 1;
}

foo();

// In case of multiple return, any one that returns something means that return value is meaningful
function bar() {
    if (rand(0, 1)) {
        return 1;
    } else {
        return ;
    }
}

bar();

?>

1.2.1299.1. Specs

Short name

Functions/UnusedReturnedValue

Rulesets

All, Analyze, Dead code

Exakat since

0.8.5

PHP Version

All

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

Very high

Features

return

Available in

Entreprise Edition, Exakat Cloud