-
-
Notifications
You must be signed in to change notification settings - Fork 934
Closed
phpstan/phpstan-src
#1267Description
phpstan version: 0.11.2
Summary of a problem or a feature request
Multiple DateTime and DateTimeImmutable methods like modify, diff, format, getOffset, getTimezone and setTime can return false on failure.
Code snippet that reproduces the problem
Example:
$validTo = new \DateTimeImmutable();
$validTo = $validTo->setTime(23, 59, 59);
// the problem is here
if ($validTo === false) {
throw new RuntimeException(__('Invalid date'));
}The output:
Strict comparison using === between DateTimeImmutable and false will always evaluate to false.
Expected output
No error, because the the PHP documentation says:
https://secure.php.net/manual/en/datetime.settime.php#refsect1-datetime.settime-returnvalues
Returns the DateTime object for method chaining or FALSE on failure.
The same kind of error applies to multiple other DateTime and DateTimeImmutable methods like modify, diff, format, getOffset, getTimezone.
Metadata
Metadata
Assignees
Labels
No labels