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

ActiveLibrary[Testing &amp; Quality](/categories/testing)

frankvanhest/phpstan-rules-no-magic
===================================

PHPStan rules inspired by roave/dont https://github.com/Roave/Dont

v3.0.0(2y ago)043MITPHPPHP ~8.1.0 | ~8.2.0 | ~8.3.0CI failing

Since Sep 30Pushed 2y ago1 watchersCompare

[ Source](https://github.com/frankvanhest/phpstan-rules-no-magic)[ Packagist](https://packagist.org/packages/frankvanhest/phpstan-rules-no-magic)[ GitHub Sponsors](https://github.com/frankvanhest)[ RSS](/packages/frankvanhest-phpstan-rules-no-magic/feed)WikiDiscussions main Synced today

READMEChangelog (4)Dependencies (5)Versions (6)Used By (0)

PHPStan - Rules - No Magic
==========================

[](#phpstan---rules---no-magic)

Basically these rules prevent you from using PHP magic methods. If you are looking for a Runtime usage prevention of these methods, use .

- [Installation](#installation)
- [Usage](#usage)
- [Contribution](#contribution)
- [License](#license)

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

[](#installation)

```
composer require frankvanhest/phpstan-rules-no-magic

```

Usage
-----

[](#usage)

Just include the following in your `phpstan.neon` file to prevent the methods `__call`, `__callStatic`, `__clone`, `__wakeup`, `__unserialize`, `unserialize`, `__get`, `__sleep`, `__serialize`, `serialize`, `__set` and `__toString`.

```
includes:
    - vendor/frankvanhest/phpstan-rules-no-magic/config/no-magic.neon
```

Of course, you can customize which methods should be prevented by choosing the desired rules.

For `__call`:

```
rules:
    - FrankVanHest\PhpStanRulesNoMagic\NoMagicCallRule
```

For `__callStatic`:

```
rules:
    - FrankVanHest\PhpStanRulesNoMagic\NoMagicCallStaticRule
```

For `__clone`:

```
rules:
    - FrankVanHest\PhpStanRulesNoMagic\NoMagicCloneRule
```

For `__wakeup`, `__unserialize` and `unserialize` (use of `Serializable` interface):

```
rules:
    - FrankVanHest\PhpStanRulesNoMagic\NoMagicDeserializeRule
```

For `__get`:

```
rules:
    - FrankVanHest\PhpStanRulesNoMagic\NoMagicGetRule
```

For `__sleep`, `__serialize` and `serialize` (use of `Serializable` interface):

```
rules:
    - FrankVanHest\PhpStanRulesNoMagic\NoMagicSerializeRule
```

For `__set`:

```
rules:
    - FrankVanHest\PhpStanRulesNoMagic\NoMagicSetRule
```

For `__toString`:

```
rules:
    - FrankVanHest\PhpStanRulesNoMagic\NoMagicToStringRule
```

Contribution
------------

[](#contribution)

Feel free to submit an issue of pull request. When it comes to a pull request I'm curious of how it improves this packages of which problem it may solve.

There are some requirements:

- Use PSR-12 for code styling
- Write a test for every meaningful change

License
-------

[](#license)

See [LICENCE](LICENSE.md)

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity66

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 ~121 days

Total

5

Last Release

888d ago

Major Versions

v1.0.0 → v2.0.02022-12-20

v2.x-dev → v3.0.02024-01-26

PHP version history (3 changes)v1.0.0PHP ~7.4.0 | ~8.0.0 | ~8.1.0

v2.0.0PHP ~8.0.0 | ~8.1.0 | ~8.2.0

v3.0.0PHP ~8.1.0 | ~8.2.0 | ~8.3.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2206481?v=4)[Frank van Hest](/maintainers/FrankVanHest)[@frankvanhest](https://github.com/frankvanhest)

---

Top Contributors

[![frankvanhest](https://avatars.githubusercontent.com/u/2206481?v=4)](https://github.com/frankvanhest "frankvanhest (8 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/frankvanhest-phpstan-rules-no-magic/health.svg)

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

###  Alternatives

[larastan/larastan

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

6.5k55.4M8.3k](/packages/larastan-larastan)[behat/behat

Scenario-oriented BDD framework for PHP

4.0k101.8M2.2k](/packages/behat-behat)[phpstan/phpstan-symfony

Symfony Framework extensions and rules for PHPStan

79475.7M2.2k](/packages/phpstan-phpstan-symfony)[phpstan/phpstan-doctrine

Doctrine extensions for PHPStan

67272.8M1.4k](/packages/phpstan-phpstan-doctrine)[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)[phparkitect/phparkitect

Enforce architectural constraints in your PHP applications

9224.3M28](/packages/phparkitect-phparkitect)

PHPackages © 2026

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