csoellinger / silverstripe-phpmd
为 SilverStripe 应用程序提供 phpmd 扩展的乱码检测规则。
v1.1.1
2022-06-27 10:13 UTC
Requires
- php: ^7.4 || ^8.0
Requires (Dev)
- ergebnis/composer-normalize: ^2
- php-parallel-lint/php-parallel-lint: @stable
- phpmd/phpmd: @stable
- phpstan/extension-installer: ^1
- phpstan/phpstan: @stable
- phpstan/phpstan-deprecation-rules: ^1
- phpstan/phpstan-phpunit: ^1
- phpstan/phpstan-strict-rules: ^1
- phpunit/phpunit: ^9.5
- psalm/plugin-phpunit: ^0.17.0
- squizlabs/php_codesniffer: ^3
- symfony/process: ^5.4
- vimeo/psalm: ^4
README
此仓库受到 https://github.com/helpfulrobot/chillu-phpmd-silverstripe 的极大启发并进行了分支。
为 SilverStripe (http://silverstripe.org) 应用程序提供 phpmd 扩展的乱码检测规则。
这些规则使开发者更容易遵守 SilverStripe 编码规范: https://docs.silverstripe.org/en/4/contributing/php_coding_conventions/
它主要使用标准的 PHPMD 规则,并进行了一些显著的修改
- 排除
CleanCode/StaticAccess
:静态访问是 SilverStripe 中的一个“特性”。 - 将
CamelCaseMethodName
替换为CamelCaseInstanceMethodName
:带有命名蛇形写的静态方法是 SilverStripe 中的一个“特性”。 - 将
CamelCasePropertyName
替换为CamelCaseInstancePropertyName
:带有蛇形写的静态属性是 SilverStripe 中的一个“特性”。 - 将
CamelCaseVariableName
替换为CamelCaseInstanceVariableName
:带有蛇形写的静态变量调用是 SilverStripe 中的一个“特性”。 - 将
UnusedPrivateField
替换为UnusedInstancePrivateField
:仅检查实例字段。在 SilverStripe 中,未使用的私有静态字段是按设计要求的。 - 修复了 $db、$id 和 $i 的短名称变量规则
- 添加了类名检查,因为 SilverStripe 设计的类名应与文件名匹配
安装
全局安装以跨项目使用
composer global require csoellinger/silverstripe-phpmd
在现有项目上的本地安装
composer require --dev csoellinger/silverstripe-phpmd
使用方法
对于全局安装
~/.composer/vendor/bin/phpmd <my-project> text ~/.composer/vendor/csoellinger/silverstripe-phpmd/silverstripe-ruleset.xml
对于本地安装
vendor/bin/phpmd <my-project> text vendor/csoellinger/silverstripe-phpmd/silverstripe-ruleset.xml
有关更多详细信息,请参阅 phpmd.org 上的 命令行使用 指南。