1.2.1110. 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.1110.1. Suggestions

  • Use explicit math assignation

1.2.1110.2. Specs

Short name

Structures/ShouldUseMath

Rulesets

All, 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