mglaman/drupal-check
用于运行 Drupal 代码库检查的 CLI 工具
Requires
- php: ^7.2.5|^8.0
- composer/xdebug-handler: ^1.1 || ^2.0.1 || ^3.0
- jangregor/phpstan-prophecy: ^1.0
- jean85/pretty-package-versions: ^1.5.0 || ^2.0.1
- mglaman/phpstan-drupal: ^1.0.0
- nette/neon: ^3.1
- phpstan/phpstan-deprecation-rules: ^1.0.0
- symfony/console: ~3.4.5 || ^4.2|| ^5.0 || ^6.0 || ^7.0
- symfony/process: ~3.4.5 || ^4.2|| ^5.0 || ^6.0 || ^7.0
- webflo/drupal-finder: ^1.1
Requires (Dev)
- phpstan/phpstan: ^1.0.0
- phpstan/phpstan-strict-rules: ^1.0.0
- squizlabs/php_codesniffer: ^3.4
- dev-main
- 1.5.0
- 1.4.0
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.1
- 1.2.0
- 1.1.10
- 1.1.9
- 1.1.8
- 1.1.7
- 1.1.6
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.14
- 1.0.13
- 1.0.12
- 1.0.11
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-dependabot/composer/squizlabs/php_codesniffer-3.10.3
- dev-dependabot/composer/phpstan/phpstan-deprecation-rules-1.2.1
- dev-dependabot/composer/jean85/pretty-package-versions-2.0.6
- dev-dependabot/composer/jangregor/phpstan-prophecy-1.0.2
- dev-dependabot/composer/composer/xdebug-handler-3.0.5
- dev-mglaman-patch-3
- dev-terminal-width
- dev-remove-lock
- dev-mglaman-patch-2
- dev-mglaman-patch-1
- dev-gh204-failing-config_update_check
- dev-lightning-test
- dev-gh-164-phar-phpstan-path
- dev-gh-163-package-version-conflicts
- dev-gh-119-followups
- dev-increase-travis-testing
- dev-fix-global-require-in-testing
- dev-phar-self-update
- dev-gh55
- dev-examples-module
- dev-feature/phpcs-poc
This package is auto-updated.
Last update: 2024-09-23 12:29:33 UTC
README
建立在 PHPStan 之上,这个静态分析工具将检查正确性(例如使用不存在的类),弃用错误以及其他更多内容。
为什么?虽然现在有许多静态分析工具,但它们都没有考虑到 Drupal 的上下文。这允许检查由核心抛出的弃用错误。
你准备好迎接 Drupal 9 了吗?查看我们的 Drupal 9 准备情况 指令,了解此工具如何帮助。
赞助商
需求
- PHP >=7.2
安装
您可以使用 Composer 将此作为开发依赖项安装到您的项目中,如下所示
composer require mglaman/drupal-check --dev
您还可以使用 Composer 全局安装此工具,如下所示
composer global require mglaman/drupal-check
有关如何确保全局二进制文件在您的 PATH 中的信息,请参阅 Composer 的文档:https://getcomposer.org.cn/doc/00-intro.md#manual-installation。
用法
php vendor/bin/drupal-check [options] [--] <path>...
参数
path
- 要检查的 Drupal 代码路径
选项
--drupal-root[=DRUPAL-ROOT]
- Drupal 根路径。--format[=FORMAT]
- 要使用的格式化程序:raw、table、checkstyle、json 或 junit [默认: "table"]-d, --deprecations
- 检查弃用-a, --analysis
- 检查代码分析-s, --style
- 检查代码风格--php8
- 设置 PHPStan 的 phpVersion 为 8.1(Drupal 10 要求)--memory-limit[=MEMORY-LIMIT]
- 分析的内存限制-e, --exclude-dir[=EXCLUDE-DIR]
- 要排除的目录。使用逗号分隔多个目录,不要有空格。--no-progress
- 不显示进度条,只显示结果-h, --help
- 显示此帮助信息-q, --quiet
- 不输出任何消息-V, --version
- 显示此应用程序版本--ansi
- 强制 ANSI 输出--no-ansi
- 禁用 ANSI 输出-n, --no-interaction
- 不要询问任何交互式问题-v|vv|vvv, --verbose
- 增加消息的详细程度:1 为正常输出,2 为更详细的输出,3 为调试
示例
- 检查地址 contrib 模块
php vendor/bin/drupal-check web/modules/contrib/address
- 检查地址 contrib 模块中的弃用
php vendor/bin/drupal-check -d web/modules/contrib/address
- 检查地址 contrib 模块中的分析
php vendor/bin/drupal-check -a web/modules/contrib/address
将 PHPStan 更新回 2 级以进行弃用分析
drupal-check:1.4.0 将 PHPStan 的分析级别设置为 2 以进行弃用,并设置为 6 以进行分析。这确保了基本分析错误得到修复,以提供最佳弃用代码检测体验。您可以在此处了解更多关于 PHPStan 规则级别的信息:https://phpstan.org/user-guide/rule-levels
如果您不想在 2 级运行 PHPStan 并且只想报告弃用消息,请按照以下说明操作
composer remove mglaman/drupal-check composer require --dev phpstan/phpstan \ phpstan/extension-installer \ mglaman/phpstan-drupal \ phpstan/phpstan-deprecation-rules
创建一个 phpstan.neon
文件,内容如下
parameters: customRulesetUsed: true ignoreErrors: - '#\Drupal calls should be avoided in classes, use dependency injection instead#' - '#Plugin definitions cannot be altered.#' - '#Missing cache backend declaration for performance.#' - '#Plugin manager has cache backend specified but does not declare cache tags.#' # FROM mglaman/drupal-check/phpstan/base_config.neon reportUnmatchedIgnoredErrors: false excludePaths: - */tests/Drupal/Tests/Listeners/Legacy/* - */tests/fixtures/*.php - */settings*.php - */bower_components/* - */node_modules/*
您可以直接从升级状态模块复制此内容 https://git.drupalcode.org/project/upgrade_status/-/blob/8.x-3.x/deprecation_testing_template.neon
Drupal Check - VS Code 扩展
您可以使用此扩展程序在VSCode中运行Drupal Check: https://marketplace.visualstudio.com/items?itemName=bbeversdorf.drupal-check
代码可以在以下位置找到: https://github.com/bbeversdorf/vscode-drupal-check
许可证
问题
在此处提交问题和功能请求: https://github.com/mglaman/drupal-check/issues。
已知问题
与其他可能安装在Drupal项目上的库共享依赖项时存在冲突
- 此工具不与BLT 9兼容: #9
- 如果您遇到与其他库的问题,请为此项目提交一个问题。