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.

Installs: 175

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 0

Forks: 0

Open Issues: 42

Type:phpstan-extension

v0.2.2 2025-08-31 04:08 UTC

README

Provides custom PHPStan rules for different enforcements throughout your codebase to look for potential problems and enforce particular programmatic or naming style.

Inspiration

Originally inspired by PHPMD - PHP Mess Detector, this project attempts to provide equivalent rules with modern interpretation and maintenance.

Note that all rules inspired by PHPMD are simply that, inspired. They are often similar in their enforcements. But they are not complete 1-to-1 replications, in that they provided different or additional customization via different parameters.

Not every rule in this extention is inspired by PHPMD. Additional rules beyond those that replicate PHPMD enforcements are also provided.

Rules

BooleanGetMethodName

Enforces that methods with boolean return types should not start with "get".

CamelCase Method Name

Enforces that method names should follow camelCase naming convention.

CamelCase Parameter Name

Enforces that function and method parameter names should follow camelCase naming convention.

CamelCase Property Name

Enforces that class property names should follow camelCase naming convention.

CamelCase Variable Name

Enforces that local variable names should follow camelCase naming convention.

ConstantNamingConventions

Enforces that constant names should be in UPPERCASE.

MissingClosureParameterTypehint

Enforces that all parameters in anonymous functions (closures) have type declarations.

PascalCase Class Name

Enforces that class names should follow PascalCase naming convention.

ShortMethodName

Enforces that method names must be of a minimum length.

ShortVariable

Enforces that variable names must be of a minimum length.

Superglobals

Enforces that PHP superglobals should not be used.

TraitConstantNamingConventions

Enforces that all trait constants use UPPERCASE naming convention.

ElseExpression

Enforces avoidance of else expressions, with optional elseif flagging.