定制 skukunin/phpstan-rules 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

  1. Installation: Install this library via Composer:
composer require skukunin/phpstan-rules --dev
  1. Configuration: Register the custom rules in your PHPStan configuration file (e.g., phpstan.neon or extension.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
  1. 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 getParameter in 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 of getParameter within 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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-06-01