Skip to content

DateTimeImmutable::createFromInterface return type incorrect #7225

@Jeroeny

Description

@Jeroeny

Bug report

If you call DateTimeImmutable::createFromInterface on a class CustomDateTimeImmutable extends DateTimeImmutable, Phpstan thinks it will return DateTimeImmutable, but it will actually return the specific CustomDateTimeImmutable.
Interestingly enough createFromFormat is analysed correctly.

Code snippet that reproduces the problem

https://phpstan.org/r/070552d2-d2a8-406c-9846-10e6cf44d651

https://3v4l.org/oBrlZ

Expected output

No error.

Did PHPStan help you today? Did it make you happy in any way?

Phpstan 1.6 is really nice :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions