I forgot that I had found a regression, I reproduced it today so I put an example here in order to not forget to fix it: ```php <?php namespace Test; interface Foo { } class FooBar implements Foo { } class Bar { private Foo $foo; public function __construct(Foo $foo) { $this->foo = $foo; } public function foo(): void { if (!$this->foo instanceof FooBar) { return; } // $this is now inferred as FooBar } } ``` It's all in the comment, kind of really annoying :smile:
Activity
dantleech commentedon Nov 10, 2020
Regression or bug? I don't think we did anything to change this behavior?
camilledejoye commentedon Nov 11, 2020
For me it's a regression, I don't remember ever having this problem (except the previous time I mentioned but I didn't created the ticket right away).
dantleech commentedon Nov 11, 2020
AFAIK this would always been the case, we don't track property types currently: https://github.com/phpactor/worse-reflection/blob/360a923947ac2c4646e81ebd12fa2d2391c94830/lib/Core/Inference/FrameBuilder/InstanceOfWalker.php#L18 and it is wrongly seeing
$thisas the target.The whole inference thing is a bit of a mess.
camilledejoye commentedon Nov 11, 2020
I'm surprise I never had this issue before ><
I will finishing with phpactor/indexer-extension#24 (comment) and try to fix this one next