1.2.575. Init Then Update

This is a structure where the variable is initialized in the main sequence of the code, then adapted to another value in a subsequent if structure.

This analysis reports such structures, based on assignation of constant values in the initial statement.

<?php

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

?>

1.2.575.1. Specs

Short name

Structures/InitThenIf

Rulesets

All, Changed Behavior, Inventory

Exakat since

2.5.2

PHP Version

All

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

Medium

Features

initialisation

Available in

Entreprise Edition, Exakat Cloud