PHPackages                             olivertappin/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. [Testing &amp; Quality](/categories/testing)
4. /
5. olivertappin/phpcs-diff

ActiveLibrary[Testing &amp; Quality](/categories/testing)

olivertappin/phpcs-diff
=======================

Detects violations of a defined coding standard based on a git diff.

2.0.1(3y ago)12159.7k↓28.1%15[4 issues](https://github.com/olivertappin/phpcs-diff/issues)PHPPHP ^7.3 || ^8.0CI failing

Since Aug 14Pushed 3y ago2 watchersCompare

[ Source](https://github.com/olivertappin/phpcs-diff)[ Packagist](https://packagist.org/packages/olivertappin/phpcs-diff)[ RSS](/packages/olivertappin-phpcs-diff/feed)WikiDiscussions master Synced yesterday

READMEChangelog (10)Dependencies (4)Versions (11)Used By (0)

[![Latest Version](https://camo.githubusercontent.com/db41eef0c3b72ad13050d931011e78afad678933dfda9ffd9c32e1e26ce0b06b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7461672f6f6c6976657274617070696e2f70687063732d646966662e7376673f7374796c653d666c6174266c6162656c3d72656c65617365)](https://github.com/olivertappin/phpcs-diff/tags)[![Software License](https://camo.githubusercontent.com/f251623e510f5909f16ae3f4e6e548dac11340b9fde1a99be26b015b39272c00/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c6174)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/dcbf3999c7fd01e97b10bd10f485257b0e83f4a853bf361314707a7909cd7f38/68747470733a2f2f7472617669732d63692e6f72672f6f6c6976657274617070696e2f70687063732d646966662e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/olivertappin/phpcs-diff)[![Quality Score](https://camo.githubusercontent.com/eef4445d2ea6b0df31421025e2fefbfbb8b374be2edd7e32d3c893bd4a863cde/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6f6c6976657274617070696e2f70687063732d646966662e7376673f7374796c653d666c6174)](https://scrutinizer-ci.com/g/olivertappin/phpcs-diff)[![GitHub issues](https://camo.githubusercontent.com/be93beb86eb4cff5ab69c3221cb39a167f0f27485408f78f0c49aa958af5741c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f6f6c6976657274617070696e2f70687063732d646966662e737667)](https://github.com/olivertappin/phpcs-diff/issues)[![Total Downloads](https://camo.githubusercontent.com/2e0e304f492ed5c6e8077afc241a51c65fa57b811bad0d9c5678eff340f53477/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f6c6976657274617070696e2f70687063732d646966662e7376673f7374796c653d666c6174)](https://packagist.org/packages/olivertappin/phpcs-diff)

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

[](#installation)

The recommended method of installing this library is via [Composer](https://getcomposer.org/).

### Composer

[](#composer)

#### Global Installation

[](#global-installation)

Run the following command from your project root:

```
composer global require olivertappin/phpcs-diff

```

#### Manual Installation

[](#manual-installation)

Alternatively, you can manually include a dependency for `olivertappin/phpcs-diff` in your `composer.json` file. For example:

```
{
    "require-dev": {
        "olivertappin/phpcs-diff": "^2.0"
    }
}
```

And run `composer update olivertappin/phpcs-diff`.

### Git Clone

[](#git-clone)

You can also download the `phpcs-diff` source and create a symlink to your `/usr/bin` directory:

```
git clone https://github.com/olivertappin/phpcs-diff.git
ln -s phpcs-diff/bin/phpcs-diff /usr/bin/phpcs-diff
cd /var/www/project
phpcs-diff master -v

```

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

```
phpcs-diff   -v
```

Where the current branch you are on is the branch you are comparing with, and `develop` is the base branch. In this example, `phpcs-diff` would run the following diff statement behind the scenes:

```
git diff my-current-branch develop
```

*Please note:*

- The `-v` flag is optional. This returns a verbose output during processing.
- The `current-branch` parameter is optional. If this is not defined, `phpcs-diff` will use the current commit hash via `git rev-parse --verify HEAD`.
- You must have a `ruleset.xml` defined in your project base directory.

After running `phpcs-diff`, the executable will return an output similar to the following:

```
########## START OF PHPCS CHECK ##########
module/Poject/src/Console/Script.php
 - Line 28 (WARNING) Line exceeds 120 characters; contains 190 characters
 - Line 317 (ERROR) Blank line found at end of control structure
########### END OF PHPCS CHECK ###########

```

Currently this is the only supported format however, I will look into adding additional formats (much like `phpcs`) in the near future.

### Travis CI Usage

[](#travis-ci-usage)

To use this as part of your CI/CD pipeline, create a script with the following:

```
#!/bin/bash
set -e
if [ ! -z "$TRAVIS_PULL_REQUEST_BRANCH" ]; then
  git fetch `git config --get remote.origin.url` $TRAVIS_BRANCH\:refs/remotes/origin/$TRAVIS_BRANCH;
  composer global require olivertappin/phpcs-diff;
  ~/.composer/vendor/bin/phpcs-diff $TRAVIS_BRANCH;
else
  echo "This test does not derive from a pull-request."
  echo "Unable to run phpcs-diff (as there's no diff)."

  # Here you might consider running phpcs instead:
  # composer global require squizlabs/php_codesniffer;
  # ~/.composer/vendor/bin/phpcs .
fi;
```

Which will allow you to run `phpcs-diff` against the diff of your pull-request.

Here's a sample of how this might look within Travis CI:

[![Travis CI Example](https://user-images.githubusercontent.com/9773040/70551339-43bcfc00-1b6f-11ea-90c7-bc660e8dea28.png)](https://user-images.githubusercontent.com/9773040/70551339-43bcfc00-1b6f-11ea-90c7-bc660e8dea28.png)

About
-----

[](#about)

`phpcs-diff` detects violations of a defined set of coding standards based on a `git diff`. It uses `phpcs` from the [PHP\_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) project.

This project helps by achieving the following:

- Speeds up your CI/CD pipeline validating changed files only, rather than the whole code base.
- Allows you to migrate legacy code bases that cannot risk changing everything at once to become fully compliant to a coding standard.

This executable works by only checking the changed lines, compared to the base branch, against all failed violations for those files, so you can be confident that any new or changed code will be compliant.

This will hopefully put you in a position where your codebase will become more compliant to that coding standard over time, and maybe you will find the resource to eventually change everything, and just run `phpcs` on its own.

Requirements
------------

[](#requirements)

The latest version of `phpcs-diff` requires PHP version 5.6.0 or later.

This project also depends on `squizlabs/php_codesniffer` which is used internally to fetch the failed violations via `phpcs`.

Finally, the `league/climate` package is also installed. This is to deal with console output, but this dependency may be removed in a future release.

Contributing
------------

[](#contributing)

See [CONTRIBUTING.md](CONTRIBUTING.md) for information.

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance13

Infrequent updates — may be unmaintained

Popularity43

Moderate usage in the ecosystem

Community15

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor1

Top contributor holds 70.4% 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 ~178 days

Recently: every ~394 days

Total

10

Last Release

1274d ago

Major Versions

1.1.0 → 2.0.02023-01-06

PHP version history (2 changes)1.0.1PHP ^5.6|^7.0

2.0.0PHP ^7.3 || ^8.0

### Community

Maintainers

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

---

Top Contributors

[![olivertappin](https://avatars.githubusercontent.com/u/9773040?v=4)](https://github.com/olivertappin "olivertappin (19 commits)")[![TotalWipeOut](https://avatars.githubusercontent.com/u/1478524?v=4)](https://github.com/TotalWipeOut "TotalWipeOut (7 commits)")[![zen1t](https://avatars.githubusercontent.com/u/9872888?v=4)](https://github.com/zen1t "zen1t (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[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)[youwe/testing-suite

Contains Youwe's default testing packages for php.

13191.0k8](/packages/youwe-testing-suite)[hyva-themes/hyva-coding-standard

A set of Hyvä specific PHP CodeSniffer rules extending the Magento Coding Standard

2927.5k](/packages/hyva-themes-hyva-coding-standard)

PHPackages © 2026

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