frankvanhest / phpstan-rules-no-magic
PHPStan rules inspired by roave/dont https://github.com/Roave/Dont
Fund package maintenance!
frankvanhest
Installs: 43
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/frankvanhest/phpstan-rules-no-magic
Requires
- php: ~8.1.0 | ~8.2.0 | ~8.3.0
- nikic/php-parser: ^v4.15
- phpstan/phpstan: ^1.10
Requires (Dev)
- infection/infection: ^0.27
- phpunit/phpunit: ^9.5.5
- roave/security-advisories: dev-latest
README
Basically these rules prevent you from using PHP magic methods. If you are looking for a Runtime usage prevention of these methods, use https://github.com/Roave/Dont.
Installation
composer require frankvanhest/phpstan-rules-no-magic
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
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
See LICENCE