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(4mo ago)16.6k↓18.8%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 1mo 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

48

—

FairBetter than 95% of packages

Maintenance80

Actively maintained with recent releases

Popularity27

Limited adoption so far

Community12

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

126d 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 (47 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

[larastan/larastan

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

6.4k43.5M5.2k](/packages/larastan-larastan)[wp-cli/wp-cli-tests

WP-CLI testing framework

422.7M87](/packages/wp-cli-wp-cli-tests)[leroy-merlin-br/coding-standard

The coding standard for PHP projects on LMBR

2137.0k10](/packages/leroy-merlin-br-coding-standard)

PHPackages © 2026

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