1.2.977. Plus Plus Used On Strings

Reports strings that are incremented with the post increment operator 's'++.

This spots issues of the famous feature of PHP : incrementing strings with letters.

This analysis checks for string to be incremented. It doesn’t check if the string is a numeric string, but does check the type, implicit or explicit.

<?php

$a = 'a';
$a++;
print $a;
// prints b
?>

See also Incrementing/Decrementing Operators and Path to Saner Increment/Decrement operators.

1.2.977.1. Specs

Short name

Php/PlusPlusOnLetters

Rulesets

All, Appinfo

Exakat since

2.5.1

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

High

Available in

Entreprise Edition, Exakat Cloud