PHPackages                             drevops/phpcs-standard - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. drevops/phpcs-standard

ActivePhpcodesniffer-standard[Testing &amp; Quality](/categories/testing)

drevops/phpcs-standard
======================

DrevOps PHP\_CodeSniffer rules: enforce consistent naming (snakeCase or camelCase) for variables and parameters, PHPUnit data provider conventions.

0.7.0(2mo ago)351.7k—8.3%17GPL-2.0-or-laterPHPPHP &gt;=8.2CI passing

Since Nov 1Pushed 2mo agoCompare

[ Source](https://github.com/drevops/phpcs-standard)[ Packagist](https://packagist.org/packages/drevops/phpcs-standard)[ Docs](https://github.com/drevops/phpcs-standard)[ GitHub Sponsors](https://github.com/drevops)[ Patreon](https://www.patreon.com/drevops)[ RSS](/packages/drevops-phpcs-standard/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (9)Dependencies (16)Versions (12)Used By (17)

  ![DrevOps PHP_CodeSniffer Standard logo](logo.png)

DrevOps PHP\_CodeSniffer Standard
=================================

[](#drevops-php_codesniffer-standard)

[![GitHub Issues](https://camo.githubusercontent.com/4af0076c9b7b5048e8539670bcdd2d3129cf1d34f5f19d9f45cc4db005c79708/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f647265766f70732f70687063732d7374616e646172642e737667)](https://github.com/drevops/phpcs-standard/issues)[![GitHub Pull Requests](https://camo.githubusercontent.com/218017b85d5ccb118aeb56e70ce3406d582ccef732773158d37197e37e118b16/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732d70722f647265766f70732f70687063732d7374616e646172642e737667)](https://github.com/drevops/phpcs-standard/pulls)[![Test PHP](https://github.com/drevops/phpcs-standard/actions/workflows/test-php.yml/badge.svg)](https://github.com/drevops/phpcs-standard/actions/workflows/test-php.yml)[![codecov](https://camo.githubusercontent.com/332982db3889b086f35de52086ca86fd12ab46c523b841bd47a4e014e63accb8/68747470733a2f2f636f6465636f762e696f2f67682f647265766f70732f70687063732d7374616e646172642f67726170682f62616467652e7376673f746f6b656e3d37574542314958425954)](https://codecov.io/gh/drevops/phpcs-standard)[![GitHub release (latest by date)](https://camo.githubusercontent.com/af20db1042ddd14fb1109ffeab6e6065de6f06140a2135ff366e2d5976a2bfe6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f647265766f70732f70687063732d7374616e64617264)](https://camo.githubusercontent.com/af20db1042ddd14fb1109ffeab6e6065de6f06140a2135ff366e2d5976a2bfe6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f647265766f70732f70687063732d7374616e64617264)[![LICENSE](https://camo.githubusercontent.com/b71345ee2fd74ab5542b22c91aef7c9e83c4c9e4b8334fb871f7ee9837a8332a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f647265766f70732f70687063732d7374616e64617264)](https://camo.githubusercontent.com/b71345ee2fd74ab5542b22c91aef7c9e83c4c9e4b8334fb871f7ee9837a8332a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f647265766f70732f70687063732d7374616e64617264)[![Renovate](https://camo.githubusercontent.com/35389190ce58a3690fe850342c1c3fd4f54e4c10ba8996741c8558ee24bf50dc/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f72656e6f766174652d656e61626c65642d677265656e3f6c6f676f3d72656e6f76617465626f74)](https://camo.githubusercontent.com/35389190ce58a3690fe850342c1c3fd4f54e4c10ba8996741c8558ee24bf50dc/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f72656e6f766174652d656e61626c65642d677265656e3f6c6f676f3d72656e6f76617465626f74)

[![Vortex Ecosystem](https://camo.githubusercontent.com/08d2ce6f52424a739d03c7df3f08b096f591c5198618d51756c11b2b69bde397/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f2546302539462538432538302d566f7274657825323045636f73797374656d2d3243354136383f7374796c653d666f722d7468652d6261646765266c6162656c436f6c6f723d363541434243)](https://github.com/drevops/vortex)

---

[PHP\_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) standard enforcing:

- Consistent naming conventions for local variables and function/method parameters (configurable: `snakeCase` or `camelCase`)
- PHPUnit data provider naming conventions and organization

Installation
------------

[](#installation)

```
composer require --dev drevops/phpcs-standard
```

The standard is automatically registered via [phpcodesniffer-composer-installer](https://github.com/PHPCSStandards/composer-installer).

Verify: `vendor/bin/phpcs -i` (should list `DrevOps`)

Usage
-----

[](#usage)

```
# Check code
vendor/bin/phpcs --standard=DrevOps path/to/code

# Auto-fix
vendor/bin/phpcbf --standard=DrevOps path/to/code
```

Configuration
-------------

[](#configuration)

Create `phpcs.xml`:

```

  src
  tests

```

Use individual sniffs:

```

```

### Configure naming convention

[](#configure-naming-convention)

By default, both sniffs enforce `snakeCase`. Configure to use `camelCase`:

```

```

`LocalVariableNaming`
---------------------

[](#localvariablenaming)

Enforces consistent naming convention for local variables inside functions/methods.

**With `snakeCase` (default):**

```
function processOrder() {
    $order_id = 1;        // ✓ Valid
    $orderId = 1;         // ✗ Error: NotSnakeCase
}
```

**With `camelCase`:**

```
function processOrder() {
    $orderId = 1;         // ✓ Valid
    $order_id = 1;        // ✗ Error: NotCamelCase
}
```

Excludes:

- Function/method parameters (handled by `ParameterNaming`)
- Class properties (not enforced)
- Reserved variables (`$this`, `$_GET`, `$_POST`, etc.)

### Error codes

[](#error-codes)

- `DrevOps.NamingConventions.LocalVariableNaming.NotSnakeCase` (when `format="snakeCase"`)
- `DrevOps.NamingConventions.LocalVariableNaming.NotCamelCase` (when `format="camelCase"`)

### Ignore

[](#ignore)

```
// phpcs:ignore DrevOps.NamingConventions.LocalVariableNaming.NotSnakeCase
$myVariable = 'value';
```

`ParameterNaming`
-----------------

[](#parameternaming)

Enforces consistent naming convention for function/method parameters.

**With `snakeCase` (default):**

```
function processOrder($order_id, $user_data) {  // ✓ Valid
function processOrder($orderId, $userData) {    // ✗ Error: NotSnakeCase
```

**With `camelCase`:**

```
function processOrder($orderId, $userData) {    // ✓ Valid
function processOrder($order_id, $user_data) {  // ✗ Error: NotCamelCase
```

Excludes:

- Parameters inherited from interfaces/parent classes
- Parameters in interface/abstract method declarations
- Class properties (including promoted constructor properties)

### Error codes

[](#error-codes-1)

- `DrevOps.NamingConventions.ParameterNaming.NotSnakeCase` (when `format="snakeCase"`)
- `DrevOps.NamingConventions.ParameterNaming.NotCamelCase` (when `format="camelCase"`)

### Ignore

[](#ignore-1)

```
// phpcs:ignore DrevOps.NamingConventions.ParameterNaming.NotSnakeCase
function process($legacyParam) {}
```

`DataProviderPrefix`
--------------------

[](#dataproviderprefix)

Enforces consistent naming prefix for PHPUnit data provider methods.

```
class MyTest extends TestCase {
    /**
     * @dataProvider dataProviderUserLogin
     */
    public function testUserLogin($data) {}

    public function dataProviderUserLogin() {  // ✓ Valid
        return [];
    }

    public function providerUserLogin() {      // ✗ Error: InvalidPrefix
        return [];
    }
}
```

### Configuration

[](#configuration-1)

Customize the required prefix:

```

```

### Error code

[](#error-code)

`DrevOps.TestingPractices.DataProviderPrefix.InvalidPrefix`

### Ignore

[](#ignore-2)

```
// phpcs:ignore DrevOps.TestingPractices.DataProviderPrefix.InvalidPrefix
public function providerCustom() {}
```

### Auto-fixing

[](#auto-fixing)

This sniff supports auto-fixing with `phpcbf`:

- Renames provider methods to use the correct prefix
- Updates all `@dataProvider` annotations to reference the new name

`DataProviderMatchesTestName`
-----------------------------

[](#dataprovidermatchestestname)

Ensures data provider method names match their test method names.

```
class MyTest extends TestCase {
    /**
     * @dataProvider dataProviderUserLogin
     */
    public function testUserLogin($data) {}

    public function dataProviderUserLogin() {  // ✓ Valid - ends with "UserLogin"
        return [];
    }

    public function dataProviderLogin() {      // ✗ Error: InvalidProviderName
        return [];                              //   Expected: ends with "UserLogin"
    }
}
```

Supported formats:

- `@dataProvider` annotations
- `#[DataProvider('methodName')]` attributes (PHP 8+)

Excludes:

- External providers (`ClassName::methodName`)
- Non-test methods
- Non-test classes

### Error code

[](#error-code-1)

`DrevOps.TestingPractices.DataProviderMatchesTestName.InvalidProviderName`

### Ignore

[](#ignore-3)

```
// phpcs:ignore DrevOps.TestingPractices.DataProviderMatchesTestName.InvalidProviderName
public function dataProviderCustomName() {}
```

`DataProviderOrder`
-------------------

[](#dataproviderorder)

Enforces structural organization of test and data provider methods.

```
class MyTest extends TestCase {
    // ✓ Valid - provider after test (default)
    /**
     * @dataProvider dataProviderUserLogin
     */
    public function testUserLogin($data) {}

    public function dataProviderUserLogin() {
        return [];
    }
}
```

Helper methods between tests and providers are allowed:

```
class MyTest extends TestCase {
    /**
     * @dataProvider dataProviderUserLogin
     */
    public function testUserLogin($data) {}

    private function helperMethod() {}  // ✓ Allowed

    public function dataProviderUserLogin() {
        return [];
    }
}
```

### Configuration

[](#configuration-2)

Reverse the ordering (provider before test):

```

```

Options:

- `after` (default) - Providers must appear after their test methods
- `before` - Providers must appear before their test methods

### Error codes

[](#error-codes-2)

- `DrevOps.TestingPractices.DataProviderOrder.ProviderBeforeTest` - Provider appears before test (when `providerPosition="after"`)
- `DrevOps.TestingPractices.DataProviderOrder.ProviderAfterTest` - Provider appears after test (when `providerPosition="before"`)

### Ignore

[](#ignore-4)

```
// phpcs:ignore DrevOps.TestingPractices.DataProviderOrder.ProviderBeforeTest
public function dataProviderUserLogin() {}
```

Development
-----------

[](#development)

```
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 standards
```

License
-------

[](#license)

GPL-3.0-or-later

---

*This repository was created using the [Scaffold](https://getphpcs-standard.dev/) project template*

###  Health Score

48

—

FairBetter than 95% of packages

Maintenance87

Actively maintained with recent releases

Popularity35

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~16 days

Recently: every ~27 days

Total

9

Last Release

67d ago

PHP version history (2 changes)0.1.0PHP &gt;=8.3

0.3.0PHP &gt;=8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/b57b0fd0b96f77f2efa1a1889af0ae607fa139bcc1256e809ee3ebbb30907364?d=identicon)[alexdrevops](/maintainers/alexdrevops)

---

Top Contributors

[![AlexSkrypnyk](https://avatars.githubusercontent.com/u/378794?v=4)](https://github.com/AlexSkrypnyk "AlexSkrypnyk (19 commits)")

---

Tags

codesnifferphpphpcsphpcs-standardsnake-casestandardsphpcsphpunitcode qualityPHPCodeSniffercamelcasesnakecasenaming-conventionsdata-providers

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Type Coverage Yes

### Embed Badge

![Health badge](/badges/drevops-phpcs-standard/health.svg)

```
[![Health](https://phpackages.com/badges/drevops-phpcs-standard/health.svg)](https://phpackages.com/packages/drevops-phpcs-standard)
```

###  Alternatives

[dealerdirect/phpcodesniffer-composer-installer

PHP\_CodeSniffer Standards Composer Installer Plugin

598161.9M1.9k](/packages/dealerdirect-phpcodesniffer-composer-installer)[slevomat/coding-standard

Slevomat Coding Standard for PHP\_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.

1.5k123.5M1.8k](/packages/slevomat-coding-standard)[wp-coding-standards/wpcs

PHP\_CodeSniffer rules (sniffs) to enforce WordPress coding conventions

2.8k42.5M1.6k](/packages/wp-coding-standards-wpcs)[phpcompatibility/phpcompatibility-wp

A ruleset for PHP\_CodeSniffer to check for PHP cross-version compatibility issues in projects, while accounting for polyfills provided by WordPress.

22130.6M587](/packages/phpcompatibility-phpcompatibility-wp)[phpcsstandards/phpcsextra

A collection of sniffs and standards for use with PHP\_CodeSniffer.

10324.3M44](/packages/phpcsstandards-phpcsextra)[drupal/coder

Coder is a library to review Drupal code.

3043.6M461](/packages/drupal-coder)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
