IntdivMinimumIntegerOverflow
error native on by default PHP ≥ 7.0Group: Probable bugs
Identify intdiv whose dividend resolves to PHP_INT_MIN and divisor to -1; do not assume a particular machine integer width.
Detection
- Report intdiv whose dividend resolves to PHP_INT_MIN and divisor to -1; do not assume a particular machine integer width.
- Resolve builtin functions, classes, constants and methods, including imports and supported named arguments. Follow only bounded local facts within one lexical scope. Receiver and argument provenance must establish the specific API contract; variable names and comments never prove intent.
- Report one finding per violating operation. A reachable path, unchanged value identity and applicable API behavior are required. Intervening mutation, unknown calls involving tracked values, escaped aliases or exhausted analysis budgets invalidate proof.
- A variable operand counts only when every binding of it that can run before the call is a plain
=assignment, and the same holds for each variable its value is copied from. Bindings located after the call are ignored unless the call sits in a loop of the same scope.
Exceptions (no report)
- Exclude unresolved required symbols, user-defined lookalikes, incomplete syntax, unknown required values and unsupported versions.
- Both
@custos-ignore IntdivMinimumIntegerOverflowand@noinspection IntdivMinimumIntegerOverflowsuppress this native rule. - No report when a variable operand, or a variable it was copied from, is changed in any other way before the call:
++/--, a compound assignment, a destructuring assignment, aforeachkey or value target,unset,global,static, acatchvariable or a by-reference assignment. - No report when such a variable may be reachable through a reference:
$r = &$v,[&$v],use (&$v), a call-time&$v, an unpacked argument, an argument bound to a by-reference parameter of the resolved callee (for examplesscanforpreg_matchoutput arguments), or any argument of a call whose callee cannot be resolved.
Fix
None. A repair requires a semantic decision or application error-handling policy.
PHP versions
Requires PHP 7.0 or later. Do not apply extension contracts when the resolved API is unavailable. Gate syntax and version-specific behavior to the configured target.
Configure
In custos.json:
json
{
"rules": {
"IntdivMinimumIntegerOverflow": {
"enabled": false
}
}
}Suppress
Before the statement or declaration (or the first statement of the file):
php
// @custos-ignore IntdivMinimumIntegerOverflow