Skip to content

Issues with nullable type after checking “ifnull” #13989

@stpnkcrk

Description

@stpnkcrk

Bug report

After update to 2.1.34, argument.type error started popping up in unexpected situations. See reproduction on phpstan.org/try. The issue seems to be calling a method on $this inside callable passed as parameter.

If a method on $this isn’t inside the callable or the callable is passed after the then-checked-nullable, it works.

Code snippet that reproduces the problem

https://phpstan.org/r/939edeab-1035-4618-80d8-56ce95614038

Expected output

All three cases should not throw an exception.

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

No response

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