csoellinger/silverstripe-phpmd

为 SilverStripe 应用程序提供 phpmd 扩展的乱码检测规则。

安装: 3

依赖项: 0

建议者: 0

安全性: 0

星标: 0

关注者: 0

分支: 2

开放问题: 0

类型:silverstripe-vendormodule

v1.1.1 2022-06-27 10:13 UTC

This package is auto-updated.

Last update: 2024-09-27 19:50:04 UTC


README

Build Status

此仓库受到 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 上的 命令行使用 指南。