vscode-intelephense icon indicating copy to clipboard operation
vscode-intelephense copied to clipboard

Does not recognize instanceof in match

Open Grldk opened this issue 2 years ago • 0 comments

Not sure if this is a bug or a feature request, but I have the following code (roughly):

interface Foo {
    public function bar();
}

class A implements Foo {
    public function bar() 
    { 
        return 'a';
    }
}

class B implements Foo {
    public function bar()
    {
        return 'b';
    }

    public function baz()
    {
        return 'c';
    }
}


function test(Foo $foo) {
    return match (true) {
        $foo instanceof B => $foo->baz(),
        default => $foo->bar(),
    };
}

Intelephense shows an undefined method error on $foo->baz(), while it could (should?) know that $foo is an instance of B, with method baz() in this case.

(Using Intelephense 1.8.2 on Ubuntu 20.04.3 LTS if that matters)

Grldk avatar Aug 25 '22 14:08 Grldk