1.2.698. Missing Assignation In Branches

A variable is assigned in one of the branch, but not the other. Such variable might be needed later, and when going throw this branch, it won’t be available.

In this analysis, elseif() and branches that return or goto somewhere else are omitted.

<?php

if ($condition) {
  $a = 1;
  $b = 2;
} else {
  $a = 3;
}

// $b might be missing
?>

1.2.698.1. Specs

Short name

Structures/MissingAssignation

Rulesets

All, Analyze, Changed Behavior

Exakat since

2.5.2

PHP Version

All

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

Medium

Available in

Entreprise Edition, Exakat Cloud