1.2.1118. Should Use Math

Use math operators to make the operation readable.

<?php

// Adding one to self
$a *= 2;
// same as above
$a += $a;

// Squaring oneself
$a \*\*\= 2;
// same as above
$a *= $a;

// Removing oneself
$a = 0;
// same as above
$a -= $a;

// Dividing oneself
$a = 1;
// same as above
$a /= $a;

// Divisition remainer
$a = 0;
// same as above
$a %= $a;

?>

See also Mathematical Functions.

1.2.1118.1. Suggestions

  • Use explicit math assignation

1.2.1118.2. Specs

Short name

Structures/ShouldUseMath

Rulesets

All, Changed Behavior, Suggestions

Exakat since

1.1.5

PHP Version

All

Severity

Minor

Time To Fix

Instant (5 mins)

Precision

Very high

Examples

OpenEMR

Available in

Entreprise Edition, Exakat Cloud