PHPackages                             orrison/meliorstan - 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. orrison/meliorstan

ActivePhpstan-extension[Testing &amp; Quality](/categories/testing)

orrison/meliorstan
==================

Provides PHPStan rules for improved code quality by detecting code smells and possible issues. In addition to enforcing particular naming and code style conventions to reduce bike-shedding.

v1.0.7(4d ago)1915.9k↑106.5%[1 issues](https://github.com/Orrison/MeliorStan/issues)[2 PRs](https://github.com/Orrison/MeliorStan/pulls)1MITPHPPHP ^8.3CI passing

Since Aug 16Pushed 2w ago2 watchersCompare

[ Source](https://github.com/Orrison/MeliorStan)[ Packagist](https://packagist.org/packages/orrison/meliorstan)[ Docs](https://github.com/Orrison/MeliorStan)[ RSS](/packages/orrison-meliorstan/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (10)Dependencies (20)Versions (27)Used By (1)

MeliorStan
==========

[](#meliorstan)

**Advanced PHPStan Rules for Code Quality and Consistency**

*Enhance your PHP codebase with intelligent static analysis rules that detect code smells, enforce naming conventions, and promote best practices.*

[![Latest Stable Version](https://camo.githubusercontent.com/21c776776edb33c8419466092d75f61b66ebba0bf0891abcb725405b91a3370d/68747470733a2f2f706f7365722e707567782e6f72672f6f727269736f6e2f6d656c696f727374616e2f762f737461626c65)](https://packagist.org/packages/orrison/meliorstan)[![Total Downloads](https://camo.githubusercontent.com/fa6a34ef42a62fe2252fa6ae5c65064c201a07c36f3660fe1ce6d30aea0af1be/68747470733a2f2f706f7365722e707567782e6f72672f6f727269736f6e2f6d656c696f727374616e2f646f776e6c6f616473)](https://packagist.org/packages/orrison/meliorstan/stats)[![License](https://camo.githubusercontent.com/4a5c8bc9aff8a63cab84ee184cdb1c393f7dd5dc4fee6906d3959f26739b8a7b/68747470733a2f2f706f7365722e707567782e6f72672f4f727269736f6e2f4d656c696f725374616e2f6c6963656e7365)](https://choosealicense.com/licenses/mit/)[![PHP Version](https://camo.githubusercontent.com/83d697baa78e4225d630587096ed1b0d8a0ece94e9b2ebab599fc9bb986477ac/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e332b2d626c75652e737667)](https://php.net/)[![PHPStan](https://camo.githubusercontent.com/13ceb54b92000efc4331360a4f2930a19759ed9be1f4d4ae965ef0f06eee024a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d322e312b2d6f72616e67652e737667)](https://phpstan.org/)

---

Table of Contents
-----------------

[](#table-of-contents)

- [Features](#-features)
- [Configuration and Usage](#-configuration-and-usage)
- [Available Rules](#-available-rules)
- [License](#-license)
- [AI Disclosure](#-ai-disclosure)
- [Acknowledgments](#-acknowledgments)

Features
--------

[](#features)

- **Code Analysis**: Detect code smells and potential issues
- **Naming Convention Enforcement**: Ensure consistent naming across your codebase
- **Highly Configurable**: Customize rules to match your project's standards
- **Modern PHP Support**: Built for PHP 8.3+ with PHPStan 2.1+
- **Extensive Documentation**: Detailed guides for each rule
- **Well Tested**: Comprehensive test suite ensuring reliability

Configuration and Usage
-----------------------

[](#configuration-and-usage)

Install the package:

```
composer require --dev orrison/meliorstan
```

MeliorStan does not auto-register any rules. Including `vendor/orrison/meliorstan/config/extension.neon` only loads the parameter schemas and config services that the rules need. There is no [phpstan/extension-installer](https://github.com/phpstan/extension-installer) integration, so every rule you want to run must be listed explicitly under `rules:` in your PHPStan config. This is intentional: each rule is opt-in so you can pick only the ones that fit your project.

A minimal `phpstan.neon` enabling and configuring two rules looks like this:

```
includes:
    - vendor/orrison/meliorstan/config/extension.neon

rules:
    - Orrison\MeliorStan\Rules\PascalCaseClassName\PascalCaseClassNameRule
    - Orrison\MeliorStan\Rules\CamelCaseMethodName\CamelCaseMethodNameRule

parameters:
    meliorstan:
        pascal_case_class_name:
            allow_consecutive_uppercase: false
        camel_case_method_name:
            allow_consecutive_uppercase: false
            allow_underscore_prefix: false
```

Add or remove entries under `rules:` to control which checks run. Each rule's available options, defaults, and behavior are documented on its own page, linked from [Available Rules](#-available-rules) below.

Available Rules
---------------

[](#available-rules)

### Naming Conventions

[](#naming-conventions)

RuleDescriptionTarget**[BooleanGetMethodName](docs/BooleanGetMethodName.md)**Prevents `get*` methods from returning boolean valuesMethods**[CamelCaseMethodName](docs/CamelCaseMethodName.md)**Enforces camelCase for method namesMethods**[CamelCaseParameterName](docs/CamelCaseParameterName.md)**Enforces camelCase for parameter namesParameters**[CamelCasePropertyName](docs/CamelCasePropertyName.md)**Enforces camelCase for property namesProperties**[CamelCaseVariableName](docs/CamelCaseVariableName.md)**Enforces camelCase for variable namesVariables**[ConstantNamingConventions](docs/ConstantNamingConventions.md)**Enforces UPPERCASE for constantsConstants**[ConstructorWithNameAsEnclosingClass](docs/ConstructorWithNameAsEnclosingClass.md)**Prevents methods with same name as their classMethods**[LongClassName](docs/LongClassName.md)**Limits class/interface/trait/enum name lengthClasses, Interfaces, Traits, Enums**[PascalCaseClassName](docs/PascalCaseClassName.md)**Enforces PascalCase for class namesClasses**[ShortClassName](docs/ShortClassName.md)**Enforces minimum class/interface/trait/enum name lengthClasses, Interfaces, Traits, Enums**[TraitConstantNamingConventions](docs/TraitConstantNamingConventions.md)**Enforces UPPERCASE for trait constantsTrait Constants### Code Quality

[](#code-quality)

RuleDescriptionTarget**[BooleanArgumentFlag](docs/BooleanArgumentFlag.md)**Detects boolean parameters in functions and methods that may indicate multiple responsibilitiesMethods, Functions, Closures**[LongVariable](docs/LongVariable.md)**Limits variable name lengthVariables**[MissingClosureParameterTypehint](docs/MissingClosureParameterTypehint.md)**Requires type hints on closure parametersClosures**[MissingImport](docs/MissingImport.md)**Detects types referenced by fully qualified name instead of being imported with a `use` statementType-reference positions**[ShortMethodName](docs/ShortMethodName.md)**Enforces minimum method name lengthMethods**[ShortVariable](docs/ShortVariable.md)**Enforces minimum variable name lengthVariables**[ForbidPestPhpOnly](docs/ForbidPestPhpOnly.md)**Prevents committed Pest tests from using the `only()` filterTests**[Superglobals](docs/Superglobals.md)**Discourages use of PHP superglobalsSuperglobal Usage**[UnusedFormalParameter](docs/UnusedFormalParameter.md)**Detects function/method/closure parameters that are declared but never usedFunction/method/closure parameters**[UnusedLocalVariable](docs/UnusedLocalVariable.md)**Detects local variables assigned but never read inside a function/method/closureLocal Variables### Control Flow

[](#control-flow)

RuleDescriptionTarget**[ElseExpression](docs/ElseExpression.md)**Discourages `else` expressionsControl Flow**[IfStatementAssignment](docs/IfStatementAssignment.md)**Detects assignments inside `if` and `elseif` conditionsControl Flow### Design

[](#design)

RuleDescriptionTarget**[DevelopmentCodeFragment](docs/DevelopmentCodeFragment.md)**Detects calls to development/debug functions like var\_dump, print\_r, etc.Function Calls**[EmptyCatchBlock](docs/EmptyCatchBlock.md)**Detects and reports empty catch blocks in exception handlingCatch Blocks**[ErrorControlOperator](docs/ErrorControlOperator.md)**Detects use of the error control operator (@), which silently suppresses errors instead of handling them properlyError Suppression**[ForbidCountInLoopExpressions](docs/ForbidCountInLoopExpressions.md)**Detects usage of count() or sizeof() in loop conditionsLoop Conditions**[ForbidEvalExpressions](docs/ForbidEvalExpressions.md)**Detects and reports usage of eval expressionsEval Expressions**[ForbidExitExpressions](docs/ForbidExitExpressions.md)**Detects and reports usage of exit and die expressionsExit Expressions**[ForbidGotoStatements](docs/ForbidGotoStatements.md)**Detects and reports usage of goto statementsGoto Statements**[CouplingBetweenObjects](docs/CouplingBetweenObjects.md)**Detects classes with too many type dependenciesClasses, Interfaces, Traits, Enums**[DepthOfInheritance](docs/DepthOfInheritance.md)**Detects classes with excessively deep inheritance chainsClasses**[ExcessiveClassLength](docs/ExcessiveClassLength.md)**Detects classes, interfaces, traits, and enums with excessive line countsClasses, Interfaces, Traits, Enums**[ExcessiveMethodLength](docs/ExcessiveMethodLength.md)**Detects methods, functions, and closures with excessive line countsMethods, Functions, Closures**[ExcessiveClassComplexity](docs/ExcessiveClassComplexity.md)**Detects classes with excessive total cyclomatic complexity (Weighted Method Count)Classes, Interfaces, Traits, Enums**[ExcessiveParameterList](docs/ExcessiveParameterList.md)**Detects functions, methods, closures, and arrow functions with too many parametersFunctions, Methods, Closures, Arrow Functions**[ExcessivePublicCount](docs/ExcessivePublicCount.md)**Detects classes with an excessive public API surface (public methods + properties)Classes, Interfaces, Traits, Enums**[CyclomaticComplexity](docs/CyclomaticComplexity.md)**Detects methods, functions, and classes with high cyclomatic complexityMethods, Functions, Classes**[NpathComplexity](docs/NpathComplexity.md)**Detects methods and functions with high NPath complexity (number of acyclic execution paths)Methods, Functions**[CognitiveComplexity](docs/CognitiveComplexity.md)**Detects methods, functions, and classes with high Cognitive Complexity, the SonarSource understandability metric with a nesting penaltyMethods, Functions, Classes**[NumberOfChildren](docs/NumberOfChildren.md)**Detects classes with too many direct child classesClass Hierarchy**[StaticAccess](docs/StaticAccess.md)**Detects static method calls and optionally static property access that create tight couplingStatic Access**[TooManyFields](docs/TooManyFields.md)**Detects classes and traits with an excessive number of instance fieldsClasses, Traits**[TooManyMethods](docs/TooManyMethods.md)**Detects classes with too many methodsClasses, Interfaces, Traits, Enums**[TooManyPublicMethods](docs/TooManyPublicMethods.md)**Detects classes with too many public methodsClasses, Interfaces, Traits, EnumsContributing
------------

[](#contributing)

We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.

License
-------

[](#license)

This project is licensed under the **MIT License** - see the [LICENSE](LICENSE) file for details.

AI Disclosure
-------------

[](#ai-disclosure)

AI assistants (Claude and similar tools) are used variably in the development and maintenance of this project, including for research, planning, drafting documentation, and at times generating or refactoring code. A significant portion of the code is still written by hand, and **all** code, tests, and documentation are reviewed, edited, and approved by human maintainers and contributors before being committed or released. The maintainers and contributors are the authors of, and are fully accountable for, everything in this repository. If you find a bug or quality issue, treat it as a project issue and report it normally; AI involvement is never an excuse.

Acknowledgments
---------------

[](#acknowledgments)

- [**PHPStan**](https://phpstan.org/): the foundation of modern PHP static analysis that MeliorStan builds on.
- [**PHPMD - PHP Mess Detector**](https://phpmd.org/): the original inspiration for many of the code quality rules. MeliorStan is not a direct 1:1 port; overlapping rules have diverged in behavior and configuration. See [MeliorStan and PHPMD](docs/reference/PHPMD.md) for more information.

---

[Documentation](docs/) • [Report Issues](https://github.com/orrison/meliorstan/issues)

###  Health Score

56

—

FairBetter than 97% of packages

Maintenance97

Actively maintained with recent releases

Popularity35

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 95.9% 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 ~16 days

Recently: every ~8 days

Total

20

Last Release

4d ago

Major Versions

v0.6.0 → v1.0.02026-05-03

### Community

Maintainers

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

---

Top Contributors

[![Orrison](https://avatars.githubusercontent.com/u/6799341?v=4)](https://github.com/Orrison "Orrison (260 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (9 commits)")[![claude](https://avatars.githubusercontent.com/u/81847?v=4)](https://github.com/claude "claude (2 commits)")

---

Tags

PHPStanphpstan-rules

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/orrison-meliorstan/health.svg)

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

###  Alternatives

[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.5k55.4M8.4k](/packages/larastan-larastan)[phpstan/phpstan-symfony

Symfony Framework extensions and rules for PHPStan

79475.7M2.2k](/packages/phpstan-phpstan-symfony)[shipmonk/dead-code-detector

Dead code detector to find unused PHP code via PHPStan extension. Can automatically remove dead PHP code. Supports libraries like Symfony, Doctrine, PHPUnit etc. Detects dead cycles. Can detect dead code that is tested.

4853.5M91](/packages/shipmonk-dead-code-detector)[phpstan/phpstan-doctrine

Doctrine extensions for PHPStan

67272.8M1.4k](/packages/phpstan-phpstan-doctrine)[wp-cli/wp-cli-tests

WP-CLI testing framework

423.1M142](/packages/wp-cli-wp-cli-tests)[voku/phpstan-rules

Provides additional rules for phpstan/phpstan.

3396.0k8](/packages/voku-phpstan-rules)

PHPackages © 2026

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