PHPStan compared to other static analysis tools #8986
Replies: 1 comment 1 reply
-
"Should I use Psalm or PHPStan?" is one of the hardest questions you can ask :) So the easiest answer to that is "use both" :) Both tools have completely different internals and in this world implementation details matter. Yes, for 90 % of code the findings will be the same, but the difference lies in the other 10 %. So using both can give you a bit of extra confidence in your code. Also sometimes the default settings are different for both, I encourage you to go through here https://phpstan.org/config-reference#stricter-analysis to get some idea. Do you want PHPStan on the strictest setting? I recommend this:
Of course at that point the analysis is really brutal, maybe even unusable. To give you an idea, PHPStan itself uses just level 8 and strict-rules. About comparing Psalm vs. PHPStan - I really liked the answer from @lptn given a few days ago on Symfony Devs Slack, so I'm gonna copy it here:
To clarify some of the points:
And about the other question:
If you're not interested in code formatting (where whitespace matters), but only in code semantics (what the code does), then yeah, writing custom rules with AST and Reflection (which PHPStan has access to) will always be easier :) You can start here: https://phpstan.org/developing-extensions/core-concepts |
Beta Was this translation helpful? Give feedback.
-
Is there a good write-up somewhere of the differences between the major static analysis tools, including PHPStan? A feature-by-feature comparison would be great to see, but right now I'm trying to answer two questions, specifically:
Beta Was this translation helpful? Give feedback.
All reactions