Running phpstan in the framework code #56203
Unanswered
8000
victornoleto
asked this question in
General
Replies: 1 comment
-
The magic of laravel is not getting along with these code analyzers. We also encountered same type of results when running code analyzers on the framework. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I recently found out about phpstan/larastan and decided to apply it to my code. I was shocked when I ran it at max level and then followed the strategy of running the level 0, fixing the errors, leveling up and continuing in this loop.
I reached level 7, with the level 8 errors already mapped. Honestly, after level 6 it got really annoying because the errors start to be like "be as specific as possible". But ok, I get the idea and I'm honestly happy to have found such a simple tool to show me the way to develop better code.
Out of curiosity, I would like to know if the framework code (this repository here) would be suitable with phpstan at some level. I was confident that it would be max level, but it would "accept" something around 5~6. The surprise for me was to see that at level 0 it presents 958 errors. At level 6, this number increases to 9,364.
Of course, the framework is very complete and has many files (according to phpstan validation, 1,441 specifically), but this raised a curiosity in me: if phpstan is "not important to them", should it be to me? I have laravel and all its other tools/applications as a reference. I want to develop the way they do.
And please, don't get me wrong. I'm not here to badmouth the framework (or phpstan itself). It's really just a curiosity to understand how "quality/standardization metrics" work in the development and maintenance of the framework, because I would like to follow them.
To complement the discussion in this post, I would like to share the results I also did with laravel/pint and nunomaduro/phpinsights.
Pint found only one tweak in the entire code.
PHP Insights results:
Beta Was this translation helpful? Give feedback.
All reactions