Skip to content

issue with combined assignment & instanceof check from nullable method #701

@SignpostMarv

Description

@SignpostMarv

I totally forget if this has come up before, but it's something I commonly find myself doing & it triggers an error (since 0.8, incidentally):

if (($foo = Foo::Fetch(2)) instanceof Foo && 'baz' === $foo->bar) {
	var_dump($foo->bar);exit;
}

phpstan doesn't seem to pick up on the second conditional will be Foo rather than Foo|null: https://phpstan.org/r/ab9c4b2ec677848c0d3f4c04a936a521

edited to add: fails with similar but different message on 0.10.1: https://phpstan.org/r/71f0b0c51fdddd32d37b2ca8dd5090d0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions