PHPackages                             nelson6e65/code-sniffer-helpers - 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. nelson6e65/code-sniffer-helpers

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

nelson6e65/code-sniffer-helpers
===============================

Helpers for PHP Code Sniffer

v1.1.0(1y ago)512.8k↓50%MITPHPPHP &gt;=7.2

Since Mar 14Pushed 1y ago1 watchersCompare

[ Source](https://github.com/nelson6e65/php-code-sniffer-helpers)[ Packagist](https://packagist.org/packages/nelson6e65/code-sniffer-helpers)[ Fund](https://paypal.me/n6e65)[ Patreon](https://www.patreon.com/nelson6e65)[ RSS](/packages/nelson6e65-code-sniffer-helpers/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (3)Versions (3)Used By (0)

PHP Code Sniffer Helpers
========================

[](#php-code-sniffer-helpers)

[![Commitizen friendly](https://camo.githubusercontent.com/c287c27407d94c6772fe44d84ee2281971e70c36bf5a28dfe6f2c31f66ea096a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f6d6d6974697a656e2d667269656e646c792d627269676874677265656e2e737667)](http://commitizen.github.io/cz-cli/)[![semantic-release](https://camo.githubusercontent.com/5f3b57745af83409bc673dec57e3eb360e1ec53b37ac29f81a319e347fa351c6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f2532302532302546302539462539332541362546302539462539412538302d73656d616e7469632d2d72656c656173652d6531303037392e737667)](https://github.com/nelson6e65/code-sniffer-helpers)[![Packagist PHP Version Support](https://camo.githubusercontent.com/aedf1b8d6ce91bf23d48856599bffd5ed62f8c62cfbcc48d5e779c6cdded5f2c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6e656c736f6e366536352f636f64652d736e69666665722d68656c70657273)](https://camo.githubusercontent.com/aedf1b8d6ce91bf23d48856599bffd5ed62f8c62cfbcc48d5e779c6cdded5f2c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6e656c736f6e366536352f636f64652d736e69666665722d68656c70657273)

[![GitHub release](https://camo.githubusercontent.com/0d4c568600f17b58d8290c26947d56f33d55719b82e24be7f7996e37e08f6327/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7461672f6e656c736f6e366536352f7068702d636f64652d736e69666665722d68656c706572732e7376673f6c6f676f3d676974687562)](https://github.com/nelson6e65/php-code-sniffer-helpers/tags)[![Latest Version](https://camo.githubusercontent.com/4a9ae1b629fd474d29f0d76aed68c6dfae4b2540da5ecc0062c0208979852990/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e656c736f6e366536352f636f64652d736e69666665722d68656c706572732e7376673f6c6162656c3d737461626c65)](https://packagist.org/packages/nelson6e65/code-sniffer-helpers)[![Latest unstable Version](https://camo.githubusercontent.com/60985f3f8b135031cd7667165bd58f73364147520b94b5c04d878cdffb1270a4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f767072652f6e656c736f6e366536352f636f64652d736e69666665722d68656c706572732e7376673f6c6162656c3d756e737461626c65)](https://packagist.org/packages/nelson6e65/code-sniffer-helpers#dev-main)

[![License](https://camo.githubusercontent.com/d7021117d26e607eef81efdf47de3b3091eb637782887167e42342dd1c6877ee/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6e656c736f6e366536352f7068702d636f64652d736e69666665722d68656c706572732e737667)](LICENSE)[![time tracker](https://camo.githubusercontent.com/3c0d7cbcc8df3c0472ad1e758e1fa18ed843cf2c4fad437ecf5afeff2908186f/68747470733a2f2f77616b6174696d652e636f6d2f62616467652f6769746875622f6e656c736f6e366536352f7068702d636f64652d736e69666665722d68656c706572732e737667)](https://wakatime.com/badge/github/nelson6e65/php-code-sniffer-helpers)

Helpers for PHP Code Sniffer.

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

[](#installation)

```
composer require --dev nelson6e65/code-sniffer-helpers
```

Features
--------

[](#features)

### Composer scripts

[](#composer-scripts)

#### `phpcbf` for lint-staged

[](#phpcbf-for-lint-staged)

A wrapper to fix your staged code (or argumented files/folders) using the **PHP Code Sniffer** auto-fixer.

There is a bug that does not allows you to use it directly as autofixer ([squizlabs/PHP\_CodeSniffer#1818](https://github.com/squizlabs/PHP_CodeSniffer/issues/1818)). There is [a workarround for using it as a composer script](https://github.com/squizlabs/PHP_CodeSniffer/issues/1818#issuecomment-735620637), but does not works for using it in a [lint-staged](https://github.com/okonet/lint-staged) pre-commit hook.

This helper is designed to be run with lint-staged, but you can also use it directly in your composer script.

##### Setup with lint-staged

[](#setup-with-lint-staged)

Add the script to your composer.json:

```
{
  "scripts": {
    "cs:fix-filtered": ["NelsonMartell\\PhpCodeSniffer\\ComposerScripts::phpcbf"]
  }
}
```

> I used `"cs:fix-filtered"` name, but you can use any script name you like.

Configure your Husky + lint-staged in your package.json

```
{
  "husky": {
    "hooks": {
      "pre-commit": "lint-staged"
    }
  },
  "lint-staged": {
    "*.php": "composer cs:fix-filtered"
  }
}
```

> Example for Husky 4. Adapt it if you use Husky 5.

##### Usage

[](#usage)

You can also run it directly with composer by using `composer cs:fix-filtered {PATHS}`. Example:

```
composer cs:fix-filtered src/ tests/ config/my-config-file.php
```

> Note: Non exixtent files/directories are ignored.

##### Output

[](#output)

The output is inspired on [pretty-quick](https://github.com/azz/pretty-quick) output:

```
composer cs:fix-filtered config/ src/Example.php src/non-existent-file.php
```

[![output1](.github/screenshots/output1.png)](.github/screenshots/output1.png)

License
-------

[](#license)

[![License](https://camo.githubusercontent.com/d7021117d26e607eef81efdf47de3b3091eb637782887167e42342dd1c6877ee/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6e656c736f6e366536352f7068702d636f64652d736e69666665722d68656c706572732e737667)](LICENSE)

Copyright (c) 2021 Nelson Martell

Read the [`LICENSE` file](LICENSE) for details.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance31

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 91.3% 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 ~1179 days

Total

2

Last Release

712d ago

### Community

Maintainers

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

---

Top Contributors

[![nelson6e65](https://avatars.githubusercontent.com/u/9272498?v=4)](https://github.com/nelson6e65 "nelson6e65 (21 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![oliver-la](https://avatars.githubusercontent.com/u/5559501?v=4)](https://github.com/oliver-la "oliver-la (1 commits)")

---

Tags

composercomposer-scriptslint-stagedphpphpcbfphpcs

###  Code Quality

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/nelson6e65-code-sniffer-helpers/health.svg)

```
[![Health](https://phpackages.com/badges/nelson6e65-code-sniffer-helpers/health.svg)](https://phpackages.com/packages/nelson6e65-code-sniffer-helpers)
```

###  Alternatives

[phpspec/prophecy

Highly opinionated mocking framework for PHP 5.3+

8.5k551.7M682](/packages/phpspec-prophecy)[brianium/paratest

Parallel testing for PHP

2.5k118.8M754](/packages/brianium-paratest)[beberlei/assert

Thin assertion library for input validation in business models.

2.4k96.9M570](/packages/beberlei-assert)[mikey179/vfsstream

Virtual file system to mock the real file system in unit tests.

1.4k108.0M2.7k](/packages/mikey179-vfsstream)[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k39.1M32.1k](/packages/orchestra-testbench)[phpspec/phpspec

Specification-oriented BDD framework for PHP 7.1+

1.9k36.7M3.1k](/packages/phpspec-phpspec)

PHPackages © 2026

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