PHPackages                             otgs/phpcs-diff - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. otgs/phpcs-diff

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

otgs/phpcs-diff
===============

07PHP

Since Jan 18Pushed 1y agoCompare

[ Source](https://github.com/OnTheGoSystems/phpcs-diff)[ Packagist](https://packagist.org/packages/otgs/phpcs-diff)[ RSS](/packages/otgs-phpcs-diff/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (2)Used By (0)

PHPCS Diff
==========

[](#phpcs-diff)

The purpose of this project is to provide a mean of running [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) (aka PHPCS) checks on top of file(s) stored in a version control system and reporting issues introduced only in specific revision(s).

[![phpcs-diff demonstration](./anim.gif)](./anim.gif)

Reporting only new issues for specific revision migth be important in case the PHPCS is being introduced later in the development cycle and there are no resources for cleaning up all existing issues.

There are several different ways of installing and using the tool.

Standalone
==========

[](#standalone)

You can run phpcs-diff from a commandline without further requirements, you just need PHP and Composer.

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

[](#installation)

```
git clone https://github.com/zaantar/phpcs-diff.git phpcs-diff
cd phpcs-diff
composer install --no-dev
```

Usage
-----

[](#usage)

Run the script from the directory of the git repository you want to inspect.

`../phpcs-diff/bin/phpcs-diff [options]`

Functionality options:

- `--start_revision=`: First (older) revision number/commit hash.
- `--end_revision=`: Second (newer) revision number/commit hash. If this argument is not provided, unstaged changes in the working directory will be used.
- `--tolerance[=]`: Last level of issues that will be tolerated. Accepted values are blockers | warnings | notes | none.
- `--standard[=]`: Name of the phpcs standard to use, for example: WordPress, WordPress-VIP, WordPress-Core, WordPress-Docs, WordPress-Extra, [VariableAnalysis](https://github.com/sirbrillig/phpcs-variable-analysis) or Toolset. It can also be a path to the configuration file, e.g. `./phpcsdiff.xml`.

    If you omit this argument, a [default configuration file](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#using-a-default-configuration-file)will be used.
- `--sniff_unstaged`: Inspect unstaged changes in the working directory against the latest commit (HEAD). `--start_revision` and `--end_revision` will be ignored in this case.

Output options:

- `--log_level[=]`: Control verbosity by passing a number from 0 (most verbose) to 2 (least verbose, only errors).
- `--ignore_space_changes`: Whitespace changes will be ignored when git is used to produce the diff.
- `--no_colours`: Do not use coloured output when printing the list of issues.
- `--colourt_primary=`, `--colour_secondary=`: Specify primary and secondary colours for the list of issues. [Accepted values](https://misc.flogisoft.com/bash/tip_colors_and_formatting):

    > default, black, red, green, yellow, blue, magenta, cyan, lightgray, darkgray, lightred, lightgreen, lightyellow, lightblue, lightmagenta, lightcyan, white

    These arguments will be ignored if `--no_colours` is used.

Limitations:

- Subversion is not supported.
- Can be only used on a git repository in the current directory.

Output:

The script will print found issues and set an exit code if any issues not ignored by the current tolerance level have occurred.

As a wp-cli command
===================

[](#as-a-wp-cli-command)

This repository is also a WordPress plugin that, when activated, provides a WP-CLI command `phpcs-diff`.

Pre-requisities
---------------

[](#pre-requisities)

Along a working [WordPress](wordpress.org) installation you'll need a [WP CLI](wp-cli.org) installed since you can interact with the plugin via WP CLI only for now.

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

[](#installation-1)

1. Checkout this repository to your plugins directory.
2. Run `composer install --no-dev` in the root of the repository.
3. Activate the plugin via standard WordPress administration.

Usage
-----

[](#usage-1)

Example command run:

```
wp phpcs-diff --vcs="svn" --repo="hello-dolly" --start_revision=99998 --end_revision=100000
```

For more params of the command, please, run `wp help phpcs-diff` or [check the inline documentation directly](https://github.com/zaantar/phpcs-diff/blob/master/wp-cli-command.php#L17).

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

[](#configuration)

### PHPCS

[](#phpcs)

If default values for running PHPCS command does not match your environment (see  ), you need to override those via constants located in wp-config.php of your WordPress installation:

```
define( 'PHPCS_DIFF_COMMAND', 'phpcs' );
define( 'PHPCS_DIFF_STANDARDS', 'path/to/phpcs/standards' );
```

### SVN

[](#svn)

Originally, this tool has been working with Subversion only, but that functionality had since been somewhat sidelined. Please report any features you're missing for SVN or bugs.

Note: Among other things, you will need to provide the plugin SVN credentials. This can be done using following constants put into `wp-config.php` file of your WordPress installation:

```
define( 'PHPCS_DIFF_SVN_USERNAME', 'my_svn_username' );
define( 'PHPCS_DIFF_SVN_PASSWORD', 'my_svn_password' );
```

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity26

Early-stage or recently created project

 Bus Factor1

Top contributor holds 58.8% 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.

### Community

Maintainers

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

---

Top Contributors

[![zaantar](https://avatars.githubusercontent.com/u/6987234?v=4)](https://github.com/zaantar "zaantar (60 commits)")[![david-binda](https://avatars.githubusercontent.com/u/3651036?v=4)](https://github.com/david-binda "david-binda (35 commits)")[![dgwatkins](https://avatars.githubusercontent.com/u/16476944?v=4)](https://github.com/dgwatkins "dgwatkins (3 commits)")[![kmgalanakis](https://avatars.githubusercontent.com/u/1268089?v=4)](https://github.com/kmgalanakis "kmgalanakis (2 commits)")[![displaynone](https://avatars.githubusercontent.com/u/4666067?v=4)](https://github.com/displaynone "displaynone (1 commits)")[![gregWierzba](https://avatars.githubusercontent.com/u/372048?v=4)](https://github.com/gregWierzba "gregWierzba (1 commits)")

### Embed Badge

![Health badge](/badges/otgs-phpcs-diff/health.svg)

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

###  Alternatives

[alexis-magina/cmb2-field-post-search-ajax

CMB2 field type to attach posts to each others. Search with Ajax.

3913.5k1](/packages/alexis-magina-cmb2-field-post-search-ajax)[affordablemobiles/g-serverless-support-laravel

Google Serverless runtime support for Laravel apps

3313.5k](/packages/affordablemobiles-g-serverless-support-laravel)[tomverran/robots-txt-checker

Given a robots.txt file, user agent and URL path will tell you whether you're allowed to access a page

1264.1k3](/packages/tomverran-robots-txt-checker)[oriceon/laravel-settings

Laravel 5 persistent settings

207.2k1](/packages/oriceon-laravel-settings)

PHPackages © 2026

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