vimeo / psalm

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

Warn about unused results of unary/binary/conditional operands? #5386

Open TysonAndre opened 3 years ago

TysonAndre commented 3 years ago

https://psalm.dev/r/4bb488a86d

E.g. if the true and false branches of a conditional are pure, psalm should warn about $pure1 ?: $pure2 or expr ? $pure1 : $pure2

For unary operators other than @ and binary operators I'd usually expect an analyzer to warn if the result was unused (e.g. for (+unused; +unused, $actuallyUsed, unused))

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

I found these snippets:

https://psalm.dev/r/4bb488a86d ```php
weirdan commented 3 years ago

print is hardly pure though. Neither is rand().