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

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

extdn/phpcs
===========

A set of PHP\_CodeSniffer rules and sniffs.

8146.4k10[36 issues](https://github.com/extdn/extdn-phpcs/issues)[2 PRs](https://github.com/extdn/extdn-phpcs/pulls)PHP

Since May 15Pushed 7y ago17 watchersCompare

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

READMEChangelogDependenciesVersions (6)Used By (0)

ExtDN PHP\_CodeSniffer rules for Magento 2
==========================================

[](#extdn-php_codesniffer-rules-for-magento-2)

[![Build Status](https://camo.githubusercontent.com/ac360787f7054c3958cb6de3fecbca15b389f8144d45779254f8d3741999e11b/68747470733a2f2f7472617669732d63692e6f72672f657874646e2f657874646e2d70687063732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/extdn/extdn-phpcs)

### Introduction

[](#introduction)

There are already many PHP CodeSniffer rules out there to aid in Magento 2 development:

- Magento core ruleset (in folder `dev/tests/static/framework/Magento`)
- [Magento Extension Quality Program](https://github.com/magento/marketplace-eqp) (in short: MEQP)
- [Magento Expert Consultancy Group](https://github.com/magento-ecg/coding-standard) (in short: ECG)
- PSR-1, PSR-2, possibly PSR-12

However, some best practices still need to be integrated and/or some rules do need to be improved. This repository forms an effort to come up with more advanced rulesets than there currently are. Additionally, one of the underlying goals is to create rules that fit Magento core, Magento third party extensions and Magento implements, while they all have different needs.

### Usage

[](#usage)

To install this package, go to your Magento 2 root and use the following:

```
composer require extdn/phpcs:dev-master

```

If this fails because the dependency with `magento/marketplace-eqp` fails to load, first add the EQP repo to your configuration and then repeat:

```
composer config repositories.magento-marketplace-eqp vcs https://github.com/magento/marketplace-eqp
composer require magento/marketplace-eqp:dev-master
composer require extdn/phpcs:dev-master

```

Once installed, you can run PHPCS from the command-line to analyse your code `XYZ`:

```
vendor/bin/phpcs --standard=./vendor/extdn/phpcs/Extdn app/code/XYZ
vendor/bin/phpcs --standard=./vendor/extdn/phpcs/Extdn vendor/XYZ

```

If you have a Composer Installer Plugin for PHPCS coding standards (such as ) configured in the project, you can refer to this standard simply by its name:

```
vendor/bin/phpcs --standard=Extdn app/code/XYZ
vendor/bin/phpcs --standard=Extdn vendor/XYZ

```

Where to contribute
-------------------

[](#where-to-contribute)

We need help in the following areas:

- Documentation of existing EQP rules (where each EQP rule could be included in this repository its `ruleset.xml`)
- Creation of new PHPCS rules (see below **How to contribute**)
- Braindumps on where PHPCS lacks and other tools might come in more handy (PhpStan, Phan)
- Discussions on new rules (through periodic hangouts or discussions per GitHub Issue)

Please note that you are also welcome to contribute to the Magento rulesets directly (core, MEQP, ECG - see links above). Likewise, we will try to get ExtDN rules into Magento rulesets as well, which is part of this ExtDN project.

How to contribute
-----------------

[](#how-to-contribute)

Any contribution is welcome. However, don't start coding just yet. Make sure first that the work is worth the effort.

1. Add a new issue under **Issues** to address new rulesets that are needed or report other issues.
2. Once the creation of the new rule has been accepted by adding a label `Accepted` under **Issues**, we're good to go.
3. If a similar rule already exists in the core or MEQP or ECG, simply try to include this rule within the ExtDN ruleset.
4. If no rule exists yet, let's create it. As an example, you can use the `SetTemplateInBlockSniff` within the folder `Extdn/Sniffs/Blocks`. It can be tested upon a sample file under `Extdn/Samples/Blocks`:

```
vendor/bin/phpcs --standard=./vendor/extdn/phpcs/Extdn vendor/extdn/phpcs/Extdn/Samples
```

5. Once this all works, feel free to create a Pull Request (PR) including the addition of this rule to the `ruleset.xml` file.

### Using labels with GitHub issues

[](#using-labels-with-github-issues)

Some important labels, used for Github issues:

- `accepted`: The rule is accepted by extdn. If nobody claimed it yet, you may start working on it
- `experimental`: The rule can be implemented as well, but we will try it out with a low severity first before integrating it into the official ruleset
- `non-PHPCS`: The rule is not feasibly implementable with phpcs, will need additional tools. We keep it for later.
- `organizational`: Non-code related issues
- `on agenda of hangout`: The rule/issue will be discussed in the next community hangout

How to create a Sniffer Rule
----------------------------

[](#how-to-create-a-sniffer-rule)

We recommend to get started by creating a couple of sniffs for your own. The official [PHPCS wiki](https://github.com/squizlabs/PHP_CodeSniffer/wiki) already gives good information. Likewise, the other sniffs in our repos (and the repos of Magento) will give lots of samples anyway.

Testing
-------

[](#testing)

All rules should be accompanied with tests.

### Within a Magento installation

[](#within-a-magento-installation)

To run the sniff unit tests from a main repository, where the rules are installed via `composer`, first configure `phpcs` to find the rules:

```
vendor/bin/phpcs --config-set installed_paths vendor/extdn/phpcs/Extdn,vendor/magento/marketplace-eqp/MEQP2

```

Then tests can be run like this:

```
phpunit -c vendor/extdn/phpcs/phpunit-vendor.xml vendor/extdn/phpcs/Extdn/Tests

```

### In a standalone installation

[](#in-a-standalone-installation)

If you have cloned this GitHub repository on its own for development, use `composer` to install things and run the tests:

```
composer install
composer test

```

Each `Test.php` class should be accompanied by a `Test.inc` file to allow for unit testing based upon the PHPCS parent class `AbstractSniffUnitTest`. Make sure to include a `Test.md` Markdown description which addresses the issue at hand, explains what the rule check for and then also suggests the improvement to be made.

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance11

Infrequent updates — may be unmaintained

Popularity42

Moderate usage in the ecosystem

Community21

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 55.1% 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/942a10f0de015bb200270a04809d0cff1b16f02da8e0458d885db16feb02ecf7?d=identicon)[extdn](/maintainers/extdn)

---

Top Contributors

[![jissereitsma](https://avatars.githubusercontent.com/u/7670482?v=4)](https://github.com/jissereitsma "jissereitsma (38 commits)")[![schmengler](https://avatars.githubusercontent.com/u/367320?v=4)](https://github.com/schmengler "schmengler (25 commits)")[![macieklewkowicz](https://avatars.githubusercontent.com/u/3532870?v=4)](https://github.com/macieklewkowicz "macieklewkowicz (2 commits)")[![mikewhitby](https://avatars.githubusercontent.com/u/798002?v=4)](https://github.com/mikewhitby "mikewhitby (2 commits)")[![avstudnitz](https://avatars.githubusercontent.com/u/662059?v=4)](https://github.com/avstudnitz "avstudnitz (1 commits)")[![ryantfowler](https://avatars.githubusercontent.com/u/2093288?v=4)](https://github.com/ryantfowler "ryantfowler (1 commits)")

### Embed Badge

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

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

###  Alternatives

[dms/phpunit-arraysubset-asserts

This package provides ArraySubset and related asserts once deprecated in PHPUnit 8

14429.2M360](/packages/dms-phpunit-arraysubset-asserts)

PHPackages © 2026

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