PHP Coding Tip: Linting Locally
At least once every couple weeks, almost every active PHP developer at Vanilla is likely to open a core PR on GitHub and have the build fail with "coding standards" errors. They're usually quick fixes, but it's annoying to have your build fail out of the gate (not to mention the associated costs of running unnecessary jobs in our CI service). Did you know you can run these same checks locally? Vanilla has a script to diff your changes against a branch (usually master) and perform code style checks on just those changes. It's the same script we use in CI. To run it, just execute the following command from the project directory:
./.circleci/scripts/diff-standards.sh
You'll see the same output you'd expect to see in the "Linting PHP" step of our CI builds. If you're particularly industrious, you might even be able to wire this up in a Git hook to prevent ever running into these issues again.