Need help with drupal-check?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

mglaman
245 Stars 43 Forks GNU General Public License v2.0 186 Commits 40 Opened issues

Description

Check Drupal code for deprecations and discover bugs via static analysis

Services available

!
?

Need anything else?

Contributors list

# 130,183
PHP
phpstan
php7
drupal-...
110 commits
# 350,036
HTML
PHP
drupal-...
hyper-v
6 commits
# 505,046
PHP
drupal-...
Shell
phpstan
3 commits
# 179,205
PHP
Compose...
drupal
drupal-...
2 commits
# 572,576
PHP
drupal-...
Shell
phpstan
2 commits
# 585,811
PHP
drupal-...
Shell
phpstan
2 commits
# 503,672
JavaScr...
Chrome
Shell
HTML
1 commit
# 225,712
HTML
PHP
drupal-...
Ansible
1 commit
# 91,119
CSS
Deploye...
sudo
tailwin...
1 commit
# 255,462
PHP
drupal-...
Shell
Compose...
1 commit
# 113,673
PHP
lambda
Markdow...
drupal-...
1 commit
# 653,931
PHP
drupal-...
Shell
phpstan
1 commit
# 20,596
Markdow...
phpstor...
captcha...
captcha...
1 commit
# 532,536
PHP
drupal-...
Shell
phpstan
1 commit
# 87,947
drupal-...
Shell
phpstan
Swift
1 commit
# 640,131
PHP
drupal-...
Shell
phpstan
1 commit
# 577,797
PHP
Shell
drupal-...
phpstan
1 commit

drupal-check Build Status CircleCI Latest release

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.

Requirements

  • PHP >=7.2

Installation

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

composer require mglaman/drupal-check --dev

You can also install this globally using Composer like so:

composer global require mglaman/drupal-check

Refer to Composer's documentation on how to ensure global binaries are in your PATH: https://getcomposer.org/doc/00-intro.md#manual-installation.

Usage

This tool works on all Drupal code, but must be executed within the root directory of a Drupal project..

1. cd into a Drupal Directory

You can run this tool within any Drupal project. But, for best results, create a fresh Drupal directory on the latest Drupal:

composer create-project drupal-composer/drupal-project:8.x-dev drupal --no-interaction --stability=dev
cd drupal

2. Run drupal-check

Usage:

  drupal-check [OPTIONS] [DIRS]

Arguments:

  • OPTIONS
    - See "Options" for allowed values. Specify multiples in sequence, e.g.
    -ad
    .
  • DIRS
    - One or more directories within the root of a Drupal project.

Options:

  • -a
    Check analysis
  • -d
    Check deprecations (default)
  • -e
    Exclude directories. Wildcards work. Separate multiple excluded directories with commas, no spaces. e.g.: */tests/codeception/acceptance/*.php
  • --drupal-root
    Path to Drupal root. Fallback option if drupal-check could not identify Drupal root from the provided path(s).

Examples:

  • Check the address contrib module:
  drupal-check web/modules/contrib/address
  • Check the address contrib module for deprecations:
  drupal-check -d web/modules/contrib/address
  • Check the address contrib module for analysis:
  drupal-check -a web/modules/contrib/address
  • Check the address contrib module for both deprecations and analysis:
  drupal-check -ad web/modules/contrib/address

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

Roadmap

See what feature requests are most popular in the Issue queue: https://github.com/mglaman/drupal-check/issues.

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: https://github.com/mglaman/drupal-check/issues/9
  • If you run into issues with other libraries, please submit an issue to this project.

Contributing

See the CONTRIBUTING.md.

References

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.