Skip to content

False positive method.nonObject if condition checked via temporary variable #11102

@petski

Description

@petski

Bug report

See https://phpstan.org/r/4b34db49-bd87-40db-a8c0-8a37a4bbc933

Expected Behavior:

PHPStan should recognize the conditions performed are valid, thus not raising any errors.

Actual Behavior:

PHPStan reports a Cannot call method format() on DateTime|null., even though valid condition checks are in place.

Code snippet that reproduces the problem

https://phpstan.org/r/4b34db49-bd87-40db-a8c0-8a37a4bbc933

Expected output

PHPStan shouldn't report an issue for these cases

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

I absolutely love PHPStan. PHPStan keeps my code clean and free of bugs, so it keeps my head sane :).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions