PHPackages                             pekral/phpstan-rules - 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. pekral/phpstan-rules

ActivePhpstan-extension[Validation &amp; Sanitization](/categories/validation)

pekral/phpstan-rules
====================

Extensible package of custom rules for PHPStan.

0.4.5(5mo ago)19.1k↑541.7%[1 issues](https://github.com/pekral/phpstan-rules/issues)3MITPHPPHP ^8.4CI passing

Since Jan 6Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/pekral/phpstan-rules)[ Packagist](https://packagist.org/packages/pekral/phpstan-rules)[ Docs](https://github.com/pekral/phpstan-rules)[ RSS](/packages/pekral-phpstan-rules/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (10)Dependencies (6)Versions (12)Used By (3)

phpstan-rules
=============

[](#phpstan-rules)

[![Latest Version](https://camo.githubusercontent.com/7e85b4f053cd70fe50487a72ea134d6ad6d784fdf8207c25f065281beb6a3e99/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f70656b72616c2f7068707374616e2d72756c65732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/pekral/phpstan-rules)[![MIT License](https://camo.githubusercontent.com/942e017bf0672002dd32a857c95d66f28c5900ab541838c6c664442516309c8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Downloads](https://camo.githubusercontent.com/8a94a2743a130ac57f16977a00f05a249b0d5083ec6069d8cc9c032417b526f5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f70656b72616c2f7068707374616e2d72756c65733f7374796c653d666c61742d737175617265)](https://packagist.org/packages/pekral/phpstan-rules)

---

🚀 Introduction
--------------

[](#-introduction)

**phpstan-rules** is an extensible package of custom rules for [PHPStan](https://phpstan.org/) that helps you maintain high code quality and consistency in your PHP projects.

---

📦 Installation
--------------

[](#-installation)

```
composer require --dev pekral/phpstan-rules
```

---

⚙️ Usage
--------

[](#️-usage)

1. Add `phpstan.neon` or extend your existing configuration file with this package.
2. Run PHPStan with this extension:

```
vendor/bin/phpstan analyse src/
```

---

📝 Example configuration (phpstan.neon)
--------------------------------------

[](#-example-configuration-phpstanneon)

```
includes:
    - vendor/pekral/phpstan-rules/extension.neon

parameters:
    level: max
    paths:
        - src
```

---

🔒 Strict and Deprecation Rules
------------------------------

[](#-strict-and-deprecation-rules)

This package is designed to work seamlessly with [phpstan/phpstan-strict-rules](https://github.com/phpstan/phpstan-strict-rules) and [phpstan/phpstan-deprecation-rules](https://github.com/phpstan/phpstan-deprecation-rules). These packages provide extra strict and deprecation-related rules for PHPStan, helping you enforce best practices and avoid deprecated code usage.

To enable these rules, make sure you have both packages installed (they are included in the dependencies) and add them to your `phpstan.neon` configuration:

```
includes:
    - vendor/phpstan/phpstan-strict-rules/rules.neon
    - vendor/phpstan/phpstan-deprecation-rules/rules.neon
    - vendor/pekral/phpstan-rules/extension.neon
```

You can then configure strict rules in the `parameters > strictRules` section of your `phpstan.neon` file. For a full list of available strict rules, see the [phpstan-strict-rules documentation](https://github.com/phpstan/phpstan-strict-rules#rules).

---

❓ FAQ
-----

[](#-faq)

**Q: How do I add a custom rule?**A: Create your own rule class and add it to the PHPStan configuration.

**Q: How do I run PHPStan only on specific folders?**A: Adjust the path in the PHPStan command, e.g. `src/`, `app/`.

**Q: How can I contribute?**A: Open an issue or pull request on [GitHub](https://github.com/pekral/phpstan-rules).

---

🔗 Further resources
-------------------

[](#-further-resources)

- [PHPStan](https://phpstan.org/)
- [Official PHPStan documentation](https://phpstan.org/user-guide/getting-started)

---

📝 License
---------

[](#-license)

This package is licensed under the MIT license.

---

About
-----

[](#about)

A package for extending PHPStan with custom rules. Suitable for teams and individuals who want to maintain high PHP code quality.

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance57

Moderate activity, may be stable

Popularity27

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~110 days

Recently: every ~40 days

Total

11

Last Release

172d ago

PHP version history (3 changes)0.1PHP ^8.1

0.3PHP ^8.3

0.4PHP ^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/820760fa5b2ca7e1c749f0e15c0fb9b0881ddc54ce924cb083f4bb6ae2490948?d=identicon)[pekral](/maintainers/pekral)

---

Top Contributors

[![pekral](https://avatars.githubusercontent.com/u/9308589?v=4)](https://github.com/pekral "pekral (48 commits)")

---

Tags

phpPHPStanstatic analysisqualityrulesCoding Standard

### Embed Badge

![Health badge](/badges/pekral-phpstan-rules/health.svg)

```
[![Health](https://phpackages.com/badges/pekral-phpstan-rules/health.svg)](https://phpackages.com/packages/pekral-phpstan-rules)
```

###  Alternatives

[wp-cli/wp-cli-tests

WP-CLI testing framework

423.1M142](/packages/wp-cli-wp-cli-tests)[larastan/larastan

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

6.5k55.4M8.4k](/packages/larastan-larastan)[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)[drupal/core-dev

require-dev dependencies from drupal/drupal; use in addition to drupal/core-recommended to run tests from drupal/core.

2022.6M343](/packages/drupal-core-dev)[calebdw/larastan

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

15118.7k4](/packages/calebdw-larastan)

PHPackages © 2026

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