Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Baseline #1045

Unanswered
salacr asked this question in Q&A
Apr 24, 2025 · 2 comments
Discussion options

Hi,
We have pretty big and old project and we want to start using phpcs to somehow control formatting. The problem is that there are a LOT of violations and fixing it in one go is impossible :/
Is there a feature something similar to this one https://phpstan.org/user-guide/baseline ? I can see that the original project had
squizlabs/PHP_CodeSniffer#3387.

Thanks!

You must be logged in to vote

Replies: 2 comments

Comment options

@salacr No, as nobody has come up with a good design for such a feature. Also see #137.
Keep in mind that PHPCS includes a fixer and in most codebases, over 80% of violations can be auto-fixed in one go by running phpcbf over the codebase.

If the "LOT of violations" bit is about non-auto-fixable issues, there are still a couple of things you could do to get started without blocking builds:

  • You could use the --file-list=... feature - this allows you to scan a subset of the code base, so you can clean up files one by one until the whole codebase is clean.
  • You could start with the errors and ignore warnings completely for the time being by passing the -n flag. Then once the errors are fixed, enable warnings.
  • You could choose to still show errors/warnings, but not let them influence the exit code of PHPCS.
  • You could add a pre-commit hook for a project using the --filter=GitStaged feature. That way you force files which are actively being worked on to be cleaned up, while being tolerant about files which haven't been touched.

The Wiki contains more information about these options.

Hope this helps.

You must be logged in to vote
0 replies
Comment options

Got it thanks!

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants

AltStyle によって変換されたページ (->オリジナル) /