1.2.837. No Reference On Left Side

Do not use references as the right element in an assignation. This is the case for most situations : addition, multiplication, bitshift, logical, power, concatenation. Note that PHP won’t compile the code if the operator is a short operator (+=, .=, etc.), nor if the & is on the right side of the operator.

<?php

$b = 2;
$c = 3;

$a = &$b + $c;
// $a === 2 === $b;

$a = $b + $c;
// $a === 5

?>

See also References Explained and Operator Precedence.

1.2.837.1. Connex PHP features

1.2.837.1.1. Specs

Short name

Structures/NoReferenceOnLeft

Rulesets

All, Analyze, CE, CI-checks, Changed Behavior

Exakat since

0.11.5

PHP Version

All

Severity

Critical

Time To Fix

Quick (30 mins)

Precision

Very high

Available in

Entreprise Edition, Community Edition, Exakat Cloud