DateIntervalSpecification
error on by defaultGroup: Probable bugs · PhpStorm name: DateIntervalSpecificationInspection
new DateInterval($spec) throws for a malformed ISO-8601 duration string. Check literal specifications against the accepted shapes so the mistake is caught before runtime.
Example
php
<?php
function intervals($mode)
{
$weekly = 'P1W';
$broken = '1W';
return [
new DateInterval('3M'),
new DateInterval('P2D1Y'),
new DateInterval('PT1D'),
new DateInterval("PT"),
new DateInterval('PT10:30:00'),
new DateInterval('p1d'),
new DateInterval($weekly),
new DateInterval($broken),
new DateInterval("P{$mode}D"),
new DateInterval('P1Y2M3DT4H5M6S'),
new DateInterval('PT36H'),
new DateInterval('P0002-00-10T12:00:00'),
new DateTimeImmutable('3M'),
];
}Reported:
- line 5: Malformed DateInterval specification.
- line 8: Malformed DateInterval specification.
- line 9: Malformed DateInterval specification.
- line 10: Malformed DateInterval specification.
- line 11: Malformed DateInterval specification.
- line 12: Malformed DateInterval specification.
- line 13: Malformed DateInterval specification.
Configure
In custos.json:
json
{
"rules": {
"DateIntervalSpecification": {
"enabled": false
}
}
}Suppress
Before the statement or declaration (or the first statement of the file), either of:
php
// @custos-ignore DateIntervalSpecification
/**
* @noinspection DateIntervalSpecificationInspection
*/