Object type not narrowed by not null check on property
Bug report
I think the provided example is the easiest to explain it :)
I have a variable, $test, of type null|<some object>. I then read a nullable property using ?->id and store it in some variable, $testId. When I then test for if ($testId) the type of $test is automatically narrowed to just <some object> (i.e.: PHPStan, correctly, determines that $test can't be null anymore), which is a nice feature to have. But when I do if (null !== $testId) I would expect the same to happen, as $testId can only be null|int, and it can only be int when $test (also) is not null. But this isn't the case and $test is still nullable.
Code snippet that reproduces the problem
https://phpstan.org/r/6af5c33d-b9a3-453b-99e2-3be9dff271a0
Expected output
The dumpType on line 15 reporting Test, as it does for line 19. This as $testId can only be not null when $test also isn't null.
Did PHPStan help you today? Did it make you happy in any way?
I'm happy it notices the narrowed type when using if ($testId), which I actually didn't really expect, so this definitely is a great feature 🎉.