PHP_CodeSniffer standard enforcing snake_case naming for local variables and function/method parameters. Class properties are intentionally excluded.
composer require --dev drevops/phpcs-standardThe standard is automatically registered via phpcodesniffer-composer-installer.
Verify: vendor/bin/phpcs -i (should list DrevOps)
# Check code
vendor/bin/phpcs --standard=DrevOps path/to/code
# Auto-fix
vendor/bin/phpcbf --standard=DrevOps path/to/codeCreate phpcs.xml:
<?xml version="1.0"?>
<ruleset name="Project Standards">
<rule ref="DrevOps"/>
<file>src</file>
<file>tests</file>
</ruleset>Use individual sniffs:
<ruleset name="Custom Standards">
<rule ref="DrevOps.NamingConventions.LocalVariableSnakeCase"/>
<rule ref="DrevOps.NamingConventions.ParameterSnakeCase"/>
</ruleset>Enforces snake_case for local variables inside functions/methods.
function processOrder() {
$order_id = 1; // ✓ Valid
$orderId = 1; // ✗ Error: VariableNotSnakeCase
}Excludes:
- Function/method parameters (handled by
ParameterSnakeCase) - Class properties (not enforced)
- Reserved variables (
$this,$_GET,$_POST, etc.)
DrevOps.NamingConventions.LocalVariableSnakeCase.NotSnakeCase
// phpcs:ignore DrevOps.NamingConventions.LocalVariableSnakeCase.NotSnakeCase
$myVariable = 'value';Enforces snake_case for function/method parameters.
function processOrder($order_id, $user_data) { // ✓ Valid
function processOrder($orderId, $userData) { // ✗ Error: ParameterNotSnakeCaseExcludes:
- Parameters inherited from interfaces/parent classes
- Parameters in interface/abstract method declarations
- Class properties (including promoted constructor properties)
DrevOps.NamingConventions.ParameterSnakeCase.NotSnakeCase
// phpcs:ignore DrevOps.NamingConventions.ParameterSnakeCase.NotSnakeCase
function process($legacyParam) {}composer install # Install dependencies
composer test # Run tests
composer test-coverage # Run tests with coverage
composer lint # Check code standards
composer lint-fix # Fix code standardsGPL-3.0-or-later
This repository was created using the Scaffold project template
