1.2.575. Infinite Recursion

A method is calling itself, with unchanged arguments. This might repeat indefinitely.

This rules applies to recursive functions without any condition. This also applies to function which inject the incoming arguments, without modifications.

<?php

function foo($a, $b) {
    if ($a > 10) {
        return;
    }
    foo($a, $b);
}

function foo2($a, $b) {
    ++$a;   // $a is modified
    if ($a > 10) {
        return;
    }
    foo2($a, $b);
}

?>

1.2.575.1. Connex PHP features

1.2.575.1.1. Suggestions

  • Modify arguments before injecting them again in the same method

  • Use different values when calling the same method

1.2.575.1.2. Specs

Short name

Structures/InfiniteRecursion

Rulesets

All, Analyze, Changed Behavior

Exakat since

1.8.6

PHP Version

All

Severity

Major

Time To Fix

Quick (30 mins)

Precision

Very high

Available in

Entreprise Edition, Exakat Cloud