drupal-check
Analyze Drupal code for deprecations and errors
TLDR
Check the code in a specific directory for deprecations
Check the code excluding a comma-separated list of directories
Don't show a progress bar
Perform static analysis to detect bad coding practices
SYNOPSIS
drupal-check [OPTIONS] [PATHS]...
PARAMETERS
--core-version VERSION
Check against specific Drupal core version (e.g., 10.2.0, default: 10.2)
--module-version VERSION
Check module compatibility for given contrib version
--php VERSION
Target PHP version for analysis (e.g., 8.1)
--format FORMAT
Output format: console, json, checkstyle, junit, emacs, compact, summary (default: console)
--overview, -o
Show overview table instead of detailed sniffs
--summary
Show only summary statistics
--group-by-group
Group results by sniff group
--no-progress
Disable progress output
-v|-vv|-vvv, --verbose
Increase verbosity
-q, --quiet
Suppress non-error output
-h, --help
Show help
-V, --version
Show version
DESCRIPTION
drupal-check is a command-line tool for analyzing PHP code in Drupal projects to ensure compatibility with specific Drupal core versions. It scans modules, themes, and custom code for deprecated APIs, removed functions, and other breaking changes introduced in newer Drupal releases.
Ideal for developers preparing site upgrades (e.g., from Drupal 9 to 10), it identifies issues like incompatible hooks, services, or YAML configurations. The tool uses static analysis powered by PHP CodeSniffer with Drupal coding standards and Rector rules tailored for Drupal.
Run it on entire sites or specific directories to get a report with error counts, file paths, and fix suggestions. Supports progress bars, summaries, and various output formats for CI/CD integration. It's particularly useful in Composer-based workflows, helping maintain forward compatibility without manual audits.
CAVEATS
Requires PHP 8.1+ and Composer for installation. Scans only PHP/YAML files; may report false positives on third-party code. Not a full upgrade path—combine with manual testing.
INSTALLATION
Via Composer: composer global require drupal-composer/drupal-check. Add ~/.composer/vendor/bin to PATH.
EXAMPLE USAGE
drupal-check --core-version=10.2 web/modules/custom checks custom modules for Drupal 10.2 compatibility.
HISTORY
Created by Martin Scharrer in 2020 as drupal-rector companion. Evolved into standalone tool via Composer package drupal-composer/drupal-check. Actively maintained for Drupal 10/11 upgrades, with frequent updates matching core releases.


