DateMinutesMonthTokenConfusion
warning native off by default quick-fixGroup: Probable bugs
Detect a date format literal with unescaped hour token H, G, h or g followed by colon and m and optionally seconds.
Example
<?php
$day=new DateTimeImmutable(); $clock=$day->format('H:m:s');<?php
$day=new DateTimeImmutable(); $clock=$day->format('H:i:s');Reported:
- line 2: Use the minute token in this clock format.
Detection
- Report a date format literal with unescaped hour token H, G, h or g followed by colon and m and optionally seconds.
- Resolve builtin calls and named arguments before checking the contract. Project-local callees are considered only when their bodies or immutable summaries establish the required facts. The default is disabled; enable only when the stated intent matches the application.
- For flow-dependent conditions, require a reachable source-to-use path with no intervening invalidation. Unknown calls, ambiguous aliases or recursion cannot establish definite facts. When the proof is inconclusive, nothing is reported.
Exceptions (no report)
- Escaped tokens, formats with a separate calendar-date component and unknown formats are excluded.
- Unresolved targets, incomplete required facts, suppressed findings and PHP versions lacking the referenced API or language feature produce no report. User declarations shadowing builtin names are not builtin contracts.
Fix
Replace only the m token in the proven clock-time segment with i under this opt-in clock-format contract.
A fix is offered only when the concrete prerequisites above are proven. Edits use exact source byte ranges, preserve comments and argument evaluation order, and introduce syntax supported by the configured PHP version. Never invent error-handling policy.
PHP versions
Apply only on PHP versions supporting the referenced APIs and syntax (within PHP 5.3–8.5). Builtin behavior and argument contracts follow the configured PHP version. Extension-specific calls require resolved extension API symbols; do not treat same-named application functions as extension calls.
Options
None. Enable or disable this rule through normal rule configuration.
Configure
In custos.json:
{
"rules": {
"DateMinutesMonthTokenConfusion": {
"enabled": true
}
}
}Suppress
Before the statement or declaration (or the first statement of the file):
// @custos-ignore DateMinutesMonthTokenConfusion