Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Static Analyzer (PHPStan) Integration #671

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

UlrichEckhardt
Copy link
Contributor

Greetings,

this PR integrates PHPStan into the Clockwork sources. The analyzer is automatically executed on every push using a Github action. As alternatives to PHPStan, there would be Psalm and perhaps SonarQube. I have worked with Psalm before and it works similarly to PHPStan. About SonarQube, I can't say much, but it seems to have a much larger scope. In particular, it provides a multi-language (not just PHP) framework and also includes support for making code reviews.

If you look at the README, there is a section on how to work with PHPStan, also the commit messages should contain some interesting context infos.

As for what drove me to develop this

  • It helps find bugs (two of them just recently fixed as byproducts from this integration).
  • It prevents regressions.
  • It gives the devs more time to work on the important stuff. ;)

Cheers!

Uli

Specifically that is
- phpstan/phpstan - the linter itself
- phpstan/extension-installer - convenience package for loading extensions
- spaze/phpstan-disallowed-calls - an extension that checks for some additional flaws
The baseline lists the existing flaws that were found. This has two uses:
- We can use a high sensitivity for scanning, without having to fix all
  issues right away.
- It still prevents new issues from coming up and also tracks resolved
  issues.
This should prevent regressions in code flaws detected by PHPStan. Also,
PHPStan complains when the baseline is not advanced after fixing a flaw.
This should prevent a flaw from reappearing later on.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant