vimeo / psalm

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

False-positive RedundantIdentityWithTrue using `match` #8246

Open fluffycondor opened 2 years ago

fluffycondor commented 2 years ago

Psalm 4.24.0@06dd975cb55d36af80f242561738f16c5f58264f and strictBinaryOperands="true" (thus can't be reproduced on psalm.dev)

https://psalm.dev/r/2b1b3686d6

On the 4th line RedundantIdentityWithTrue is triggered. But it's the way to use match recommended by PHP docs: https://www.php.net/manual/en/control-structures.match.php#example-137

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

I found these snippets:

https://psalm.dev/r/2b1b3686d6 ```php 'hi!', // RedundantIdentityWithTrue: The "=== true" part of this comparison is redundant default => throw new \BadMethodCallException(), }; ``` ``` Psalm output (using commit 6d45003): No issues! ```