1.2.986. Possible Increment

This expression looks like a typo : a missing + would change the behavior.

The same pattern is not reported with -, as it is legit expression. + sign is usually understated, rather than explicit.

<?php

// could it be a ++$b ?
$a = +$b;

?>

See also Incrementing/Decrementing Operators and Arithmetic Operators.

1.2.986.1. Connex PHP features

1.2.986.1.1. Suggestions

  • Drop the whole assignation

  • Complete the addition with another value : $a = 1 + $b

  • Make this a ++ operator : ++$b

  • Make this a negative operator : -$b

  • Make the casting explicit : (int) $b

1.2.986.1.2. Specs

Short name

Structures/PossibleIncrement

Rulesets

All, Changed Behavior, Suggestions

Exakat since

1.2.1

PHP Version

All

Severity

Minor

Time To Fix

Instant (5 mins)

Precision

High

Examples

Zurmo, MediaWiki

Available in

Entreprise Edition, Exakat Cloud