1.2.687. Methods Without Return

List of all the functions, closures, methods that have no explicit return.

Functions with the void or never return types, are omitted.

<?php

// With return null : Explicitly not returning
function withExplicitReturn($a = 1) {
    $a++;
    return null;
}

// Without indication
function withoutExplicitReturn($a = 1) {
    $a++;
}

// With return type void : Explicitly not returning
function withExplicitReturnType($a = 1) : void {
    $a++;
}

?>

See also return.

1.2.687.1. Suggestions

  • Add the returntype ‘void’ to make this explicit behavior

1.2.687.2. Specs

Short name

Functions/WithoutReturn

Rulesets

All, Analyze

Exakat since

0.8.4

PHP Version

All

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

Very high

Features

return, never

Available in

Entreprise Edition, Exakat Cloud