vimeo / psalm

A static analysis tool for finding errors in PHP applications
https://psalm.dev
MIT License
5.54k stars 659 forks source link

A variable being null is not memoized together with the value after null-safe calls #10553

Open bwoebi opened 7 months ago

bwoebi commented 7 months ago

Given a variable whose return type is only null if on the null-safe call $object?->bar() the object was actually null, a subsequent null-safe call to the given object will not be evaluated at all, allowing to ignore that given variable if it was passed as parameter.

https://psalm.dev/r/54cc95bce8

psalm-github-bot[bot] commented 7 months ago

I found these snippets:

https://psalm.dev/r/54cc95bce8 ```php start(); $foo?->cancel($id); ``` ``` Psalm output (using commit a75d26a): ERROR: PossiblyNullArgument - 17:15 - Argument 1 of Foo::cancel cannot be null, possibly null value provided ```