Skip to content

BcMathFloatOperand ​

warning native off by default

Group: Probable bugs

Supply decimal strings before BCMath arithmetic. This inspection is disabled by default; enabling it selects the stated policy.

Example ​

php
<?php
$x = bcadd(0.15 + 0.25, '0', 8);

Reported:

  • line 2: Supply decimal strings before BCMath arithmetic.

Detection ​

  • A resolved bcadd, bcsub, bcmul, bcdiv, bcmod, bcpow, bccomp or bcsqrt receives a proven float operand. Enabling this rule establishes a decimal-exact-input policy; integers and decimal strings are excluded.
  • Resolve builtin functions, extension classes, constants and method receivers, including aliases and supported named arguments. Inspect reachable operations in one lexical scope with bounded local flow.
  • Emit one finding per violating operation. Never infer policy from names or comments. When the proof is inconclusive, nothing is reported.

Exceptions (no report) ​

  • Exclude shadowed or unresolved symbols, incomplete code, unknown required constants, ambiguous receiver identity and unsupported versions. Reassignment, escaping aliases, and unknown calls invalidate dependent flow facts.
  • Both @custos-ignore BcMathFloatOperand and @noinspection BcMathFloatOperand suppress this native rule.

Fix ​

None. A safe repair requires choosing values, error handling, or application behavior.

PHP versions ​

Apply throughout PHP 5.3–8.5 only where the extension API and syntax exist. Do not flag API unavailability through this rule. Invalid-input error forms vary by PHP version; the BCMath operand contract is unchanged.

Options ​

None. Use normal rule configuration to enable or disable the inspection.

Configure ​

In custos.json:

json
{
  "rules": {
    "BcMathFloatOperand": {
      "enabled": true
    }
  }
}

Suppress ​

Before the statement or declaration (or the first statement of the file):

php
// @custos-ignore BcMathFloatOperand

Released under the MIT License. Native rules and rules modeled on Php Inspections (EA Extended); independent clean-room implementation.