IntlTimezoneOffsetMillisecondsUsedAsSeconds
warning native on by default quick-fix PHP ≥ 5.5Group: Probable bugs
Convert timezone offsets to seconds.
Example
<?php
$z=IntlTimeZone::createTimeZone("Europe/Paris"); $z->getOffset($instant,false,$raw,$dst); $d=new DateTime(); $d->modify(($raw+$dst)." seconds");Reported:
- line 2: Convert timezone offsets to seconds.
Detection
- Track direct rawOffset/dstOffset output locals of a preceding resolved IntlTimeZone::getOffset call in the same lexical scope. Report DateTime/DateTimeImmutable::modify with either local, or their sum, concatenated with the literal seconds unit. Already-divided offsets and unknown provenance are excluded.
- Resolve builtin functions, extension classes, method receivers, constants and named arguments. Follow unchanged locals and aliases only within the same bounded lexical scope. Require a reachable path; merge branch facts only when all incoming paths establish them.
- Emit one finding at the violating operation, not one per evidence statement. Rebinding, writes, by-reference escape, unresolved calls that can mutate relevant state, and exhausted analysis budgets remove proof.
Exceptions (no report)
Reject offset-unit proof after an intervening use of the output local, a reference alias, a nested scope or proof-budget exhaustion. Compound assignments and opaque calls discard the proof.
- Exclude shadowed builtins, unresolved receivers, incomplete syntax and unknown prerequisite facts. An extension function name alone does not prove an application function is that builtin.
- A dominating valid guard or repair described in Detection prevents the finding. Both legacy noinspection and custos-ignore forms suppress this ID.
Fix
For the exact proven offset expression concatenated with a seconds literal, wrap only the numeric expression in (original / 1000); preserve its single evaluation. A sum written without its own parentheses is grouped before the division, giving ((raw + dst) / 1000), so both offsets are converted rather than only the right one.
All edits use exact byte ranges and preserve comments and evaluation order. Offer no fix when its stated prerequisites cannot be proven or the replacement is unsupported by the configured PHP version.
PHP versions
Requires PHP 5.5 or later and the referenced extension API. Respect method-specific introduction versions within PHP 5.3–8.5; unsupported optional APIs cannot establish facts. Named arguments require PHP 8.0 or later.
Configure
In custos.json:
{
"rules": {
"IntlTimezoneOffsetMillisecondsUsedAsSeconds": {
"enabled": false
}
}
}Suppress
Before the statement or declaration (or the first statement of the file):
// @custos-ignore IntlTimezoneOffsetMillisecondsUsedAsSeconds