Skip to content

DatePeriod::getEndDate can return null #6477

@nyamsprod

Description

@nyamsprod

Bug report

PHPStan believes that DatePeriod::getEndDate will always return a DateTimeInterface object while it can also return null if no end date can be computed from the DatePeriod constructor input see https://www.php.net/manual/en/dateperiod.getenddate.php

Code snippet that reproduces the problem

https://phpstan.org/r/93804099-9892-4e17-a54e-6b9b8d18be62

and

https://3v4l.org/qBgdp

Expected output

Expect no error to be display

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions