vimeo / psalm

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

Incorrect type detection when null-safe operator usage #11085

Open vjik opened 2 weeks ago

vjik commented 2 weeks ago

https://psalm.dev/r/abb526bcc8

psalm-github-bot[bot] commented 2 weeks ago

I found these snippets:

https://psalm.dev/r/abb526bcc8 ```php value; } } class B { public function __construct( private A $a ) {} public function getA(): A { return $this->a; } } class C { public ?B $b = null; } function test(C $c): void { echo $c->b?->getA()->getValue() ?? 'no value'; } ``` ``` Psalm output (using commit 16b24bd): ERROR: RedundantCondition - 29:10 - Type int for $384 is never null ERROR: TypeDoesNotContainNull - 29:40 - Cannot resolve types for $384 - int does not contain null ```