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.
composer require frankvanhest/phpstan-rules-no-magic
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.neonOf course, you can customize which methods should be prevented by choosing the desired rules.
For __call:
rules:
- FrankVanHest\PhpStanRulesNoMagic\NoMagicCallRuleFor __callStatic:
rules:
- FrankVanHest\PhpStanRulesNoMagic\NoMagicCallStaticRuleFor __clone:
rules:
- FrankVanHest\PhpStanRulesNoMagic\NoMagicCloneRuleFor __wakeup, __unserialize and unserialize (use of Serializable interface):
rules:
- FrankVanHest\PhpStanRulesNoMagic\NoMagicDeserializeRuleFor __get:
rules:
- FrankVanHest\PhpStanRulesNoMagic\NoMagicGetRuleFor __sleep, __serialize and serialize (use of Serializable interface):
rules:
- FrankVanHest\PhpStanRulesNoMagic\NoMagicSerializeRuleFor __set:
rules:
- FrankVanHest\PhpStanRulesNoMagic\NoMagicSetRuleFor __toString:
rules:
- FrankVanHest\PhpStanRulesNoMagic\NoMagicToStringRuleFeel 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
See LICENCE