automattic/vipwpcs
PHPCS sniffs and rulesets for validating code built for WordPress VIP. Includes WordPressVIPMinimum and WordPress-VIP-Go standards, based on WPCS and VariableAnalysis. Install via Composer; supports PHP 5.4+ and PHPCS 3.13.2+.
Start by installing the package as a dev dependency in your project using Composer:
composer config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
composer require --dev automattic/vipwpcs
This automatically registers the WordPress-VIP-Go and WordPressVIPMinimum standards with PHPCS. After installation, run:
./vendor/bin/phpcs -i
to confirm WordPress-VIP-Go and WordPressVIPMinimum appear in the list of installed standards. Your first real use case is linting your codebase:
./vendor/bin/phpcs --standard=WordPress-VIP-Go path/to/your/plugin.php
Check the VIP docs on PHPCS reports to understand error/warning severity and how to interpret results.
CI Integration: Use in GitHub Actions or GitLab CI to fail builds on violations. A typical workflow step:
- name: Run VIP Coding Standards
run: ./vendor/bin/phpcs --standard=WordPress-VIP-Go --extensions=php --severity=5 .
Adjust --severity and --warning-severity to balance strictness and developer feedback.
Editor Integration: Configure VS Code (with PHPCS extension) or PHPStan/PSR support to use the VIP ruleset via phpcs.standard: "WordPress-VIP-Go".
Custom Ruleset: Extend the provided rulesets for project-specific tweaks: create phpcs.xml with:
<?xml version="1.0"?>
<ruleset name="MyVIP">
<rule ref="WordPress-VIP-Go"/>
<exclude name="WordPressVIPMinimum.Security.EscapeOutput.OutputNotEscaped"/>
</ruleset>
⚠️ As of v2.3.0, do not override the escaping_function property in custom rulesets—it’s disallowed.
Test Suite Integration: Run PHPCS as part of your test suite via ./vendor/bin/phpcs in composer test scripts or phpunit.xml via phpcs test runner.
Legacy Projects: Use WordPressVIPMinimum for old wp.com VIP projects; prefer WordPress-VIP-Go for modern VIP Go deployments (the default).
WordPressVIPMinimum.Variables.Variables references in config or inline @phpcs:ignore, replace with VariableAnalysis.CodeAnalysis.VariableAnalysis.ProperEscapingFunction sniff was improved but now doesn’t allow overriding of escaping_function—remove any such config.VariableAnalysis: Silence UnusedVariable per PR #620 to reduce noise—this is already done by default in the ruleset.IncludingNonPHPFile now recognizes .phar and interpolated strings—be precise with constants used in include/require to avoid false positives. Use $allowedKeywords to tune.WPQueryParams now flags 'exclude'—verify usage; it may be legitimate for complex tax queries.ProperEscapingFunction for action attributes on <form> tags and URL/HTML attribute context detection—it’s strict but covers common XSS pitfalls.phpcs -i to verify VIP standards are registered—Composer plugins may conflict if multiple PHPCS standards are used.--debug with PHPCS to see which sniffs fire and why:
./vendor/bin/phpcs --standard=WordPress-VIP-Go --debug file.php 2>&1 | grep -A1 'fired'
How can I help you explore Laravel packages today?