mglaman/drupal-check 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

mglaman/drupal-check

Composer 安装命令:

composer create-project mglaman/drupal-check

包简介

CLI tool for running checks on a Drupal code base

README 文档

README

Built on PHPStan, this static analysis tool will check for correctness (e.g. using a class that doesn't exist), deprecation errors, and more.

Why? While there are many static analysis tools out there, none of them run with the Drupal context in mind. This allows checking contrib modules for deprecation errors thrown by core.

Are you ready for Drupal 9? Check out our Drupal 9 Readiness instructions for details on how this tool can help.

Sponsors

undpaul undpaul

Would you like to sponsor?

Requirements

  • PHP >=7.2

Installation

You install this in your project using Composer as a development dependency like so:

composer require mglaman/drupal-check --dev

Usage

php vendor/bin/drupal-check [options] [--] <path>...

Arguments:

  • path - The Drupal code path(s) to inspect

Options:

  • --drupal-root[=DRUPAL-ROOT] - Path to Drupal root.
  • --format[=FORMAT] - Formatter to use: raw, table, checkstyle, json, or junit [default: "table"]
  • -d, --deprecations - Check for deprecations
  • -a, --analysis - Check code analysis
  • -s, --style - Check code style
  • --php8 - Set PHPStan phpVersion for 8.1 (Drupal 10 requirement)
  • --memory-limit[=MEMORY-LIMIT] - Memory limit for analysis
  • -e, --exclude-dir[=EXCLUDE-DIR] - Directories to exclude. Separate multiple directories with a comma, no spaces.
  • --no-progress - Do not show progress bar, only results
  • -h, --help - Display this help message
  • -q, --quiet - Do not output any message
  • -V, --version - Display this application version
  • --ansi - Force ANSI output
  • --no-ansi - Disable ANSI output
  • -n, --no-interaction - Do not ask any interactive question
  • -v|vv|vvv, --verbose - Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Examples:

  • Check the address contrib module:
php vendor/bin/drupal-check web/modules/contrib/address
  • Check the address contrib module for deprecations:
php vendor/bin/drupal-check -d web/modules/contrib/address
  • Check the address contrib module for analysis:
php vendor/bin/drupal-check -a web/modules/contrib/address

Rollback update to PHPStan level 2 for deprecation analysis

drupal-check:1.4.0 set PHPStan's analysis level to 2 for deprecations and 6 for analysis. This ensures basic analysis errors are fixed to provide the best deprecated code detection experience. You can read more about PHPStan's rule levels here: https://phpstan.org/user-guide/rule-levels

If you do not want to run PHPStan at level 2 and only report deprecation messages, use the following instructions

composer remove mglaman/drupal-check
composer require  --dev phpstan/phpstan \
  phpstan/extension-installer \
  mglaman/phpstan-drupal \
  phpstan/phpstan-deprecation-rules

Create a phpstan.neon file with the following:

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/*

You can copy this from the Upgrade Status module directly https://git.drupalcode.org/project/upgrade_status/-/blob/8.x-3.x/deprecation_testing_template.neon

Drupal Check - VS Code Extension

You can run Drupal Check from VSCode using this extension: https://marketplace.visualstudio.com/items?itemName=bbeversdorf.drupal-check

The code can be found at: https://github.com/bbeversdorf/vscode-drupal-check

License

GPL v2

Issues

Submit issues and feature requests here: https://github.com/mglaman/drupal-check/issues.

Known Issues

There are conflicts with dependencies shared with other libraries that might be installed on a Drupal project:

  • This tool does not work with BLT 9: #9
  • If you run into issues with other libraries, please submit an issue to this project.

Contributing

See the CONTRIBUTING.md.

References

mglaman/drupal-check 适用场景与选型建议

mglaman/drupal-check 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6.82M 次下载、GitHub Stars 达 343, 最近一次更新时间为 2019 年 03 月 26 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 mglaman/drupal-check 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 mglaman/drupal-check 我们能提供哪些服务?
定制开发 / 二次开发

基于 mglaman/drupal-check 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 6.82M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 343
  • 点击次数: 22
  • 依赖项目数: 48
  • 推荐数: 0

GitHub 信息

  • Stars: 343
  • Watchers: 9
  • Forks: 71
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2019-03-26