PHPackages                             lipemat/wp-phpcs - 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. lipemat/wp-phpcs

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

lipemat/wp-phpcs
================

PHP Codesniffer for a WordPress plugin

4.6.1(3w ago)559.9k↓42.8%3MITPHPPHP &gt;=7.4.0CI passing

Since Dec 20Pushed 3w ago1 watchersCompare

[ Source](https://github.com/lipemat/wp-phpcs)[ Packagist](https://packagist.org/packages/lipemat/wp-phpcs)[ GitHub Sponsors](https://github.com/lipemat)[ RSS](/packages/lipemat-wp-phpcs/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (33)Versions (55)Used By (0)

WP PHPCS
========

[](#wp-phpcs)

[![package version](https://camo.githubusercontent.com/e82edbe72cf0fdaa191cbb5e1de115a25653b8af13cd4619f2d5eb5218fb6915/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c6970656d61742f77702d70687063732e7376673f6c6162656c3d76657273696f6e)](https://github.com/lipemat/wp-phpcs/releases) [![required WordPress version](https://camo.githubusercontent.com/b9e87a495812217da5213360a59a07c91c9120545bb718ab7f318e4b915eb673/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f776f726470726573732d3e3d342e382e302d677265656e2e737667)](https://camo.githubusercontent.com/b9e87a495812217da5213360a59a07c91c9120545bb718ab7f318e4b915eb673/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f776f726470726573732d3e3d342e382e302d677265656e2e737667) [![required PHP version](https://camo.githubusercontent.com/aa6f80a01a67d529358d1d6f3ac58287960123ecb6d28ea5e54ddc038e05ca43/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6c6970656d61742f77702d70687063732e7376673f636f6c6f723d62726f776e)](https://camo.githubusercontent.com/aa6f80a01a67d529358d1d6f3ac58287960123ecb6d28ea5e54ddc038e05ca43/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6c6970656d61742f77702d70687063732e7376673f636f6c6f723d62726f776e) [![Packagist version](https://camo.githubusercontent.com/626eda78c85106c429cbe5d1337a398d330e7e26d8e20e7d36055b6bf4388e89/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6c6970656d61742f77702d70687063732e737667)](https://camo.githubusercontent.com/626eda78c85106c429cbe5d1337a398d330e7e26d8e20e7d36055b6bf4388e89/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6c6970656d61742f77702d70687063732e737667)

PHP Codesniffer setup for a WordPress plugin.

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

[](#installation)

Use composer to install. Although this may be added directly to your plugins composer.json, it is recommended to install somewhere globally to reuse across projects.

If not using as a global library, your local `composer.json` will need to include the following config.

```
{
  "config": {
    "allow-plugins": {
      "dealerdirect/phpcodesniffer-composer-installer": true
    }
  }
}
```

Install via composer

```
composer require lipemat/wp-phpcs
```

Copy the `phpcs-sample.xml` file to the root of your plugin and rename to `phpcs.xml`. Adjust the configuration as desired.

Running
-------

[](#running)

The vendor/bin folder includes the scripts to run on either Windows or Unix. You may either add that directory to your PATH or call it verbosely like so:

```
{project dir}/vendor/bin/phpcs ./
```

OR

```
{project dir}/vendor/bin/phpcbf ./
```

You may also create your own script somewhere on your PATH. Here is an example phpcs.bat for Windows. This assumes you created a folder named wp-phpcs in your root and ran composer require there.

```
@echo off
C:\wp-phpcs\vendor\bin\phpcs %*

```

Automating
----------

[](#automating)

Once you have scripts added to your path for phpcs and phpcbf, you can use the included `git-hooks/pre-commit` to run PHP lint and PHPCS automatically before making any commit.

Copy the pre-commit file to your plugin's .git/hooks directory, and the rest is automatic.

Included Sniffs
---------------

[](#included-sniffs)

1. [WordPress Coding Standards](https://github.com/WordPress/WordPress-Coding-Standards#rulesets)
2. [WordPress VIP Coding Standards](https://github.com/Automattic/VIP-Coding-Standards)
3. [PHPCompatibilityWP](https://github.com/PHPCompatibility/PHPCompatibilityWP)
4. [PHPCSExtra](https://github.com/PHPCSStandards/PHPCSExtra#sniffs)

Lipe Sniffs
-----------

[](#lipe-sniffs)

This package ships with some *optional* `Lipe` namespaced sniffs.

1. `` for all our default configurations and sniffs.
    1. @note This configuration is opinionated, you probably just want to include desired sniff namespaces.
2. `` for detecting the deprecated uses of MySQL `SQL_CALC_FOUND_ROWS`.
3. `` for detecting using `??` in conditions.
4. `` for detecting using `??` in for loops.
5. `` for detecting slow meta queries.
    1. Like `WordPress.DB.SlowDBQuery.slow_db_query_meta_query` but supports using `EXISTS` and `NOT_EXISTS` meta queries.
6. `` for detecting slow `ORDER BY` clauses in WP\_Query.
7. `` for detecting uses of `post__not_in` clauses in WP\_Query.
8. `` for detecting missing uses of `suppress_filters` clauses in get\_posts.

LipePlugin Sniffs
-----------------

[](#lipeplugin-sniffs)

This package ships with some *optional* `LipePlugin` namespaced sniffs designed to be used with a distributed plugin or library.

1. `` for all the default configurations and sniffs.
    1. @note This configuration is opinionated, you probably just want to include desired sniff namespaces.
2. `` force using `static` instead of `self` to improve extensibility.
    1. 'ReturnType' - return type of methods.
    2. 'InstanceOf' - self instance for static calls.
    3. 'NewInstance' - Constructing via `new self()`.
    4. 'ScopeResolution' - Local constants via `self::`.
3. `` for distributed packages, which should not use `private` to improve extensibility.
4. `` for distributed packages, which should not use `strict_type` to improve compatibility.

Performance
-----------

[](#performance)

These standards are tuned to keep scans fast:

1. `Generic.PHP.Syntax` is excluded. It shells out to `php -l` once per file, making it by far the most expensive sniff (it accounted for ~26% of total scan time in profiling). Syntax errors are already surfaced by the PHP runtime, your IDE, CI, and the included `git-hooks/pre-commit` lint step, so the sniff is redundant.
2. Enable caching in your project ruleset so unchanged files are skipped between runs: ```

    ```
3. `phpcs -p` (parallel) requires the `pcntl` extension, which is not available on Windows, so it silently runs serially there. Rely on caching for repeat-run speed instead.

> Note: narrowing `testVersion` (e.g. `8.4` vs an open-ended `8.4-`) does **not** speed up scans. `PHPCompatibility` registers and runs every one of its sniffs against every token regardless of `testVersion`; the setting only filters which detected issues get reported. Profiling confirmed the two are equivalent within run-to-run noise.

To profile your own project, run `phpcs --report=performance --no-cache` to see per-sniff timings.

Other Notes
-----------

[](#other-notes)

The `phpcs-sample.xml` has many things excluded. This is because some things don't really fit in with WordPress standards. You can remove any of `` items to make more strict. Remove them all if you really want to make your code strict.

###  Health Score

60

—

FairBetter than 98% of packages

Maintenance95

Actively maintained with recent releases

Popularity37

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity77

Established project with proven stability

 Bus Factor1

Top contributor holds 98.6% 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 ~60 days

Recently: every ~72 days

Total

52

Last Release

23d ago

Major Versions

1.4.0 → 2.0.02019-07-19

2.8.0 → 3.0.0-beta.12023-02-13

3.2.0 → 4.0.02023-10-12

PHP version history (5 changes)2.0.0PHP &gt;=5.4

v2.2.0PHP &gt;=5.6.20

3.0.0PHP &gt;=7.0.0

3.1.3PHP &gt;=7.2.0

4.3.0PHP &gt;=7.4.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1688181?v=4)[Mat Lipe](/maintainers/lipemat)[@lipemat](https://github.com/lipemat)

---

Top Contributors

[![lipemat](https://avatars.githubusercontent.com/u/1688181?v=4)](https://github.com/lipemat "lipemat (288 commits)")[![migueliriano](https://avatars.githubusercontent.com/u/5392202?v=4)](https://github.com/migueliriano "migueliriano (4 commits)")

### Embed Badge

![Health badge](/badges/lipemat-wp-phpcs/health.svg)

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

###  Alternatives

[humanmade/coding-standards

Human Made Coding Standards

160443.1k59](/packages/humanmade-coding-standards)[slevomat/coding-standard

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

1.5k134.0M2.3k](/packages/slevomat-coding-standard)[wp-cli/wp-cli-tests

WP-CLI testing framework

423.1M142](/packages/wp-cli-wp-cli-tests)[yoast/yoastcs

PHP\_CodeSniffer rules for Yoast projects

221.2M34](/packages/yoast-yoastcs)[drupal/coder

Coder is a library to review Drupal code.

3045.9M577](/packages/drupal-coder)[youwe/testing-suite

Contains Youwe's default testing packages for php.

13191.0k8](/packages/youwe-testing-suite)

PHPackages © 2026

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