Skip to content

Missing potential false on DateTime::modify #4927

@yann-eugone

Description

@yann-eugone

Bug report

Both DateTime::modify & DateTimeImmutable::modify can return false, but got following message when testing result :

Strict comparison using === between DateTimeImmutable and false will always evaluate to false.
Strict comparison using === between DateTime and false will always evaluate to false.

I found #1934 which is about almost the same thing, but somehow the issue get closed.

Code snippet that reproduces the problem

https://phpstan.org/r/3b587421-aa5b-4c3f-ac48-7b5c20e1d61c

https://3v4l.org/sTN7A

Expected output

These 2 methods should consider that the return type is potentially false, as documented here :

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions