rectorphp / type-perfect

Next level type declaration check PHPStan rules
https://getrector.com/blog/introducing-type-perfect-for-extra-safety
MIT License
76 stars 6 forks source link

False positive: "Use instanceof instead of isset() on object" #23

Closed GErpeldinger closed 5 months ago

GErpeldinger commented 5 months ago

Hello, i've found a new problem when integrating this set of rules in my project, i am on the version dev-main of the package to be sure to have the last change.

I'm experiencing a false positive error with the rule instanceof. Specifically, the error suggests using instanceof instead of isset() on an object property that is not initialized yet.

The bug can be reproduced like this: https://phpstan.org/r/13187976-6dc0-40c3-b86f-f50b50d48dd1

The error message is:

 ------ --------------------------------------------- 
  Line   src/Foo.php                                  
 ------ --------------------------------------------- 
  24     Use instanceof instead of isset() on object  
 ------ ---------------------------------------------