PHPackages                             mi-schi/phpmd-extension - 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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. mi-schi/phpmd-extension

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

mi-schi/phpmd-extension
=======================

Contains extra phpmd rules from clean code book and the best practices of my experiences.

4.3.0(7y ago)40882.0k↑105.2%7[1 issues](https://github.com/mi-schi/phpmd-extension/issues)5MITPHP

Since Jun 30Pushed 7y ago4 watchersCompare

[ Source](https://github.com/mi-schi/phpmd-extension)[ Packagist](https://packagist.org/packages/mi-schi/phpmd-extension)[ Docs](https://github.com/mi-schi/phpmd-extension)[ RSS](/packages/mi-schi-phpmd-extension/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (35)Used By (5)

phpmd-extension
===============

[](#phpmd-extension)

[![GitHub license](https://camo.githubusercontent.com/074b89bca64d3edc93a1db6c7e3b1636b874540ba91d66367c0e5e354c56d0ea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e737667)](https://raw.githubusercontent.com/mi-schi/phpmd-extension/master/LICENSE)[![Build Status](https://camo.githubusercontent.com/d046d8ec3bbdd4a7a28cb87fc963b0c87e5435863ed466ef3508ab0e561da88c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d692d736368692f7068706d642d657874656e73696f6e2f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/mi-schi/phpmd-extension/build-status/master)[![Code Coverage](https://camo.githubusercontent.com/b66ebeca704387e198428be3499b446b7698ae69b326e35c4c8bc05b322efa78/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d692d736368692f7068706d642d657874656e73696f6e2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/mi-schi/phpmd-extension/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/2893b5cf57f4812bfc1cd5a6a8c281ffae39093029354d4ecb3feaca3a7e0309/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d692d736368692f7068706d642d657874656e73696f6e2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/mi-schi/phpmd-extension/?branch=master)[![Github All Releases](https://camo.githubusercontent.com/b8bac1c83ae92fa0c8c836253fdfbdf8f2f5448b476e26f96dbf02425c8457bc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f646f776e6c6f6164732f6d692d736368692f7068706d642d657874656e73696f6e2f746f74616c2e7376673f6d61784167653d32353932303030)](https://github.com/mi-schi/phpmd-extension)

Features
--------

[](#features)

Contains extra phpmd rules from clean code book and the best practices of my experiences.

- CleanCode
    - [ConditionalExpression](https://github.com/mi-schi/phpmd-extension/blob/master/rulesets/cleancode.xml#L14-L15) - increase readability
    - [ConstructorNewOperator](https://github.com/mi-schi/phpmd-extension/blob/master/rulesets/cleancode.xml#L37-L40) - decouple classes, see open-close principle
    - [DataStructureConstants](https://github.com/mi-schi/phpmd-extension/blob/master/rulesets/cleancode.xml#L78-L80) - increase maintainability
    - [DataStructureMethods](https://github.com/mi-schi/phpmd-extension/blob/master/rulesets/cleancode.xml#L114-L116) - increase extensibility, see single-responsibility principle
    - [MemberPrimaryPrefix](https://github.com/mi-schi/phpmd-extension/blob/master/rulesets/cleancode.xml#L167-L168) - supports low coupling, increase testability, see law of demeter
    - [PublicFieldDeclaration](https://github.com/mi-schi/phpmd-extension/blob/master/rulesets/cleancode.xml#L217-L218) - increase maintainability, see encapsulation/information hiding
    - [ReturnStatement](https://github.com/mi-schi/phpmd-extension/blob/master/rulesets/cleancode.xml#L244-L245) - increase reading rate, increase extensibility
    - [SwitchStatement](https://github.com/mi-schi/phpmd-extension/blob/master/rulesets/cleancode.xml#L291-L295) - increase extensibility, see open-close principle
    - [TraitPublicMethod](https://github.com/mi-schi/phpmd-extension/blob/master/rulesets/cleancode.xml#L347-L350) - increase maintainability, see encapsulation/information hiding
    - [TryStatement](https://github.com/mi-schi/phpmd-extension/blob/master/rulesets/cleancode.xml#L383) - increase readability
    - [PrivateFieldDeclaration](https://github.com/mi-schi/phpmd-extension/blob/master/rulesets/cleancode.xml#L433-L435) - supports high cohesion, see DRY and single-responsibility principle
- Naming
    - [ClassNameSuffix](https://github.com/mi-schi/phpmd-extension/blob/master/rulesets/naming.xml#L15-L18) - increase extensibility, see single-responsibility principle
    - [CommentDescription](https://github.com/mi-schi/phpmd-extension/blob/master/rulesets/naming.xml#L47-L50) - reduce unused declarations, increase comprehensibility
    - [MethodName](https://github.com/mi-schi/phpmd-extension/blob/master/rulesets/naming.xml#L138-L140) - increase readability, increase comprehensibility
- Test
    - [NumberOfMocks](https://github.com/mi-schi/phpmd-extension/blob/master/rulesets/test.xml#L14-L17) - increase testability, supports low coupling, see single-responsibility principle
    - [NumberOfAsserts](https://github.com/mi-schi/phpmd-extension/blob/master/rulesets/test.xml#L56-L58) - increase maintainability, speed up debugging, see single-responsibility principle
    - [MethodName](https://github.com/mi-schi/phpmd-extension/blob/master/rulesets/test.xml#L98-L99) - increase readability, increase comprehensibility

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

[](#installation)

Download the `phpmd-extension.phar`:

```
$ curl -OsL https://github.com/mi-schi/phpmd-extension/releases/download/stable/phpmd-extension.phar

```

Alternatively you can use [tooly-composer-script](https://github.com/tommy-muehle/tooly-composer-script) for installation.

It is also possible to use composer (not recommended, see [\#5](https://github.com/mi-schi/phpmd-extension/issues/5)):

```
composer require mi-schi/phpmd-extension --dev

```

Usage
-----

[](#usage)

1. Create a `phpmd.xml` file and import the basic rules from phpmd. The example below contains some useful changes. Afterwards you can extend the configuration with rules from this repository.
2. Then execute the mess detection with `phpmd-extension.phar [path/to/src] xml [path/to/phpmd.xml]`. The `phpmd-extension.phar` pass all arguments to the basic phpmd command. You don't have to install phpmd. `phpmd-extension.phar` includes phpmd.

### Basic Rules

[](#basic-rules)

```

    mess detection

```

### Add extra rules

[](#add-extra-rules)

```

```

You can also customize the rules with own properties or use only specific rules. Just take a look in the xml files. It works as the basic ruleset logic.

### Exclude or customize extra rule

[](#exclude-or-customize-extra-rule)

If you don't want the Law-of-Demeter rule MemberPrimaryPrefix exclude it.

```

```

If you want to customize it, use the following code:

```

```

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity49

Moderate usage in the ecosystem

Community24

Small or concentrated contributor base

Maturity75

Established project with proven stability

 Bus Factor1

Top contributor holds 96.5% 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 ~34 days

Recently: every ~168 days

Total

34

Last Release

2834d ago

Major Versions

1.1.8 → 2.0.02015-09-22

2.1.1 → 3.0.02016-07-31

3.1.2 → 4.0.02016-08-21

### Community

Maintainers

![](https://www.gravatar.com/avatar/b21f249f3d6ec2961e46ff81b9093caf83a33b659eeeaecda0038e6cff0384d4?d=identicon)[mi-schi](/maintainers/mi-schi)

---

Top Contributors

[![mi-schi](https://avatars.githubusercontent.com/u/8821732?v=4)](https://github.com/mi-schi "mi-schi (139 commits)")[![akovalyov](https://avatars.githubusercontent.com/u/2339101?v=4)](https://github.com/akovalyov "akovalyov (1 commits)")[![cedricziel](https://avatars.githubusercontent.com/u/418970?v=4)](https://github.com/cedricziel "cedricziel (1 commits)")[![paulKliemann](https://avatars.githubusercontent.com/u/20775610?v=4)](https://github.com/paulKliemann "paulKliemann (1 commits)")[![tommy-muehle](https://avatars.githubusercontent.com/u/1351840?v=4)](https://github.com/tommy-muehle "tommy-muehle (1 commits)")[![zakivanovic](https://avatars.githubusercontent.com/u/7568609?v=4)](https://github.com/zakivanovic "zakivanovic (1 commits)")

---

Tags

phpmdmess detectionextensionrulesclean codeBest-Practices

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mi-schi-phpmd-extension/health.svg)

```
[![Health](https://phpackages.com/badges/mi-schi-phpmd-extension/health.svg)](https://phpackages.com/packages/mi-schi-phpmd-extension)
```

###  Alternatives

[cleverage/ruler

A business rules engine

229.5k](/packages/cleverage-ruler)

PHPackages © 2026

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