u/miglisoft

▲ 42 r/PHP

What PHPStan level and why? Your thoughts on the cost-benefit analysis

A simple question: at what level do you use PHPStan, and do you think it’s worth going beyond a certain threshold?

I’d like to understand where the point of diminishing returns lies between the time spent typing/rewriting and the bugs actually prevented.

  • Level 5-6: many projects stop there. Is this a good balance, or is it just laziness to go any higher?
  • Level 7-8: things start to get tricky with union types and nullables. Does this have a tangible impact on code quality, or does it mainly become a hunt for warnings?
  • Level 9-10: the war on mixed types. For those of you at this level, have you actually seen any concrete benefit? Bugs that would have slipped through the net at lower levels? Because on paper it’s stricter, but in practice, is the investment justified?

Do some of you use hybrid strategies (baseline + max level, or strict rules on only part of the code)?

I’m trying to gather a range of feedback to form an objective view. There are no right or wrong answers; I just want to know what you do in real life and why.

reddit.com
u/miglisoft — 5 days ago