skukunin/phpstan-rules
最新稳定版本:v1.0.0
Composer 安装命令:
composer require skukunin/phpstan-rules
包简介
Custom PHPStan rules for static analysis
README 文档
README
This library provides a collection of custom PHPStan rules to help you enforce best practices in your PHP projects. It includes rules that will catch common anti-patterns and misuses, such as using deprecated methods, misusing container methods, and error silencing practices.
How to Use
- Installation: Install this library via Composer:
composer require skukunin/phpstan-rules --dev
- Configuration: Register the custom rules in your PHPStan configuration file (e.g.,
phpstan.neonorextension.neon).
You can add all the rules in your PHPStan configuration file:
includes: - phpstan-baseline.neon - vendor/skukunin/phpstan-rules/extension.neon parameters: level: 6 ...
or add only needed rules:
rules: - SKukunin\PHPStanRules\Rules\NoControllerGetParameterRule
- Running PHPStan: Run PHPStan on your project to report any detected issues:
vendor/bin/phpstan analyse src tests
Use Cases
- Symfony Projects: This library is designed with Symfony projects in mind. It provides rules to enforce best practices such as avoiding the use of
getParameterin controllers, encouraging better dependency injection practices. - Legacy Codebases: Gradually refactor and improve legacy code by integrating these rules to catch common pitfalls.
- CI/CD Integration: Ensure code quality across your projects by integrating these custom PHPStan rules into your automated build pipelines.
Existing Rules
NoContainerGetRule: Prevents misuse of container get methods.NoControllerGetParameterRule: Flags the usage ofgetParameterwithin controllers.NoErrorSilencingRule: Disallows use of PHP's error suppression operator (@).
Contributing
Contributions are welcome! If you encounter issues or have ideas for enhancements, please open an issue or submit a pull request on GitHub.
License
This project is licensed under the MIT License.
统计信息
- 总下载量: 28
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-06-01