PHP_CodeSniffer (PHPCS) is a tool that helps software professionals write performant and safe PHP code. PHPCS is an independent utility that scans code using the PHPCS standards specified, and multiple such standards exist. Each PHPCS standard is composed of one or more PHPCS sniffs that does the actual identification of issues. The standards used by VIP are designed to reinforce the VIP best practices for writing secure, performant, and future-friendly code.
The VIP Code Analysis Bot is configured to run PHPCS using two standards:
- WordPress-VIP-Go – standard developed by VIP
- PHPCompatibilityWP – standard maintained by a third party, reviewed by VIP
A more detailed explanation of errors and warnings for each severity level is available for interpreting PHPCS feedback.
Additions cannot be made to the available PHPCS standards, but suggestions for PHPCS standards can be submitted through VIP’s Feedback Portal.
Local PHPCS analysis
VIP recommends installing the PHPCS utility locally, and using the PHPCS
WordPress-VIP-Go standard. Scanning code locally with PHPCS will allow developers to identify and address issues, and minimize or suppress any remaining errors or warnings, prior to submitting a pull request.
Adding PHPCS scans to a local workflow helps developers learn VIP best practices, leads to better experiences with the Bot, and less errors generated on submission to GitHub.