GmpDivisionByKnownZero
error native on by defaultGroup: Probable bugs
Use a nonzero GMP divisor.
Example
php
<?php
$n = gmp_div_q('23', '0');Reported:
- line 2: Use a nonzero GMP divisor.
Detection
- gmp_div_q, gmp_div_r, gmp_div_qr or gmp_mod has an integer zero or valid zero-valued integer string divisor. Include proven gmp_init zero values; exclude ambiguous bases and unknown operands.
- 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.
- A divisor that reads a local variable is not a known zero when that local, or a local it was assigned from, is changed anywhere in the same scope by
++or--, bound by acatchclause or imported by reference into a closure, or when the scope callsextract()orparse_str(). A counter initialized to zero and incremented in a loop is ordinary code. - Both @custos-ignore GmpDivisionByKnownZero and @noinspection GmpDivisionByKnownZero 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.
Options
None. Use normal rule configuration to enable or disable the inspection.
Configure
In custos.json:
json
{
"rules": {
"GmpDivisionByKnownZero": {
"enabled": false
}
}
}Suppress
Before the statement or declaration (or the first statement of the file):
php
// @custos-ignore GmpDivisionByKnownZero