lakshmaji/phpmd
Composer 安装命令:
composer create-project lakshmaji/phpmd
包简介
PHPMD is a spin-off project of PHP Depend and aims to be a PHP equivalent of the well known Java tool PMD.
README 文档
README
PHPMD is a spin-off project of PHP Depend and aims to be a PHP equivalent of the well known Java tool PMD. PHPMD can be seen as an user friendly frontend application for the raw metrics stream measured by PHP Depend.
Installation
See https://phpmd.org/download/index.html
Command line usage
Type phpmd [filename|directory] [report format] [ruleset file], i.e:
mapi@arwen ~ $ phpmd PHP/Depend/DbusUI/ xml rulesets/codesize.xml
While the rulesets/codesize.xml ruleset file could look like this:
<?xml version="1.0" encoding="UTF-8" ?>
<pmd version="0.0.1" timestamp="2009-12-19T22:17:18+01:00">
<file name="/projects/pdepend/PHP/Depend/DbusUI/ResultPrinter.php">
<violation beginline="67"
endline="224"
rule="TooManyMethods"
ruleset="Code Size Rules"
package="PHP_Depend\DbusUI"
class="PHP_Depend_DbusUI_ResultPrinter"
priority="3">
This class has too many methods, consider refactoring it.
</violation>
</file>
</pmd>
You can pass a file name or a directory name containing PHP source code to PHPMD.
The PHPMD Phar distribution includes the rule set files inside its archive, even if the "rulesets/codesize.xml" parameter above looks like a filesystem reference.
Command line options
Notice that the default output is in XML, so you can redirect it to a file and XSLT it or whatever
You can also use shortened names to refer to the built-in rule sets, like this:
phpmd PHP/Depend/DbusUI/ xml codesize
The command line interface also accepts the following optional arguments:
--minimumpriority- The rule priority threshold; rules with lower priority than they will not be used.--reportfile- Sends the report output to the specified file, instead of the default output targetSTDOUT.--suffixes- Comma-separated string of valid source code filename extensions, e.g. php,phtml.--exclude- Comma-separated string of patterns that are used to ignore directories.--strict- Also report those nodes with a @SuppressWarnings annotation.--ignore-violations-on-exit- will exit with a zero code, even if any violations are found.
An example command line:
phpmd PHP/Depend/DbusUI xml codesize --reportfile phpmd.xml --suffixes php,phtml
Using multiple rule sets
PHPMD uses so called rule sets that configure/define a set of rules which will be applied against the source under test. The default distribution of PHPMD is already shipped with a few default sets, that can be used out-of-box. You can call PHPMD's cli tool with a set's name to apply this configuration:
~ $ phpmd /path/to/source text codesize
But what if you would like to apply more than one rule set against your source? You can also pass a list of rule set names, separated by comma to PHPMD's cli tool:
~ $ phpmd /path/to/source text codesize,unusedcode,naming
You can also mix custom rule set files with build-in rule sets:
~ $ phpmd /path/to/source text codesize,/my/rules.xml
That's it. With this behavior you can specify you own combination of rule sets that will check the source code.
Using multiple source files and folders
PHPMD also allowes you to specify multiple source directories in case you want to create one output for certain parts of your code
~ $ phpmd /path/to/code,index.php,/another/place/with/code text codesize
Exit codes
PHPMD's command line tool currently defines three different exit codes.
- 0, This exit code indicates that everything worked as expected. This means there was no error/exception and PHPMD hasn't detected any rule violation in the code under test.
- 1, This exit code indicates that an error/exception occured which has interrupted PHPMD during execution.
- 2, This exit code means that PHPMD has processed the code under test
without the occurence of an error/exception, but it has detected rule
violations in the analyzed source code. You can also prevent this behaviour
with the
--ignore-violations-on-exitflag, which will result to a 0 even if any violations are found.
Renderers
At the moment PHPMD comes with the following three renderers:
- xml, which formats the report as XML.
- text, simple textual format.
- html, single HTML file with possible problems.
API docs
You find the up to date class API docs at codedoc.pub.
lakshmaji/phpmd 适用场景与选型建议
lakshmaji/phpmd 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 30 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 12 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「phpmd」 「pdepend」 「pmd」 「mess detection」 「mess detector」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 lakshmaji/phpmd 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 lakshmaji/phpmd 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 lakshmaji/phpmd 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Official version of pdepend to be handled with Composer
PHPMD is a spin-off project of PHP Depend and aims to be a PHP equivalent of the well known Java tool PMD.
The tool converts different error reporting standards for deep integration with popular CI systems (TeamCity, IntelliJ IDEA, GitHub Actions, etc)
Turns PMD style XML reports into Github pull-request annotations via the Checks API. This script is meant for use within your Github Action.
Shim repository for phpmd/phpmd
This is the ZooRoyal coding standard.
统计信息
- 总下载量: 30
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2017-12-30