Skip to content

drupal analyze

Paulo Maia Carvalho edited this page May 20, 2026 · 1 revision

drupal-analyze

Run static analysis on your custom Drupal code using PHPStan and PHPCS (Drupal Coder).

Usage

/drupal-analyze
/drupal-analyze path=web/modules/custom/my_module

What it checks

PHPCS — Drupal Coding Standards

Checks code style against the Drupal and DrupalPractice standards:

  • Indentation (2 spaces, no tabs)
  • Doc comment format
  • Naming conventions (hooks, classes, functions)
  • PHP 8 compatibility patterns
  • Drupal-specific patterns (hook implementations, render arrays)

PHPStan — Static Analysis

Detects logic errors and type mismatches:

  • Undefined variables and methods
  • Incorrect return types
  • Dead code
  • Type incompatibilities

Default level: 5 (balanced between noise and thoroughness).

Scope

By default scans:

web/modules/custom/
web/themes/custom/

Pass path= to narrow the scope to a specific module or theme.

Prerequisites

The tools must be installed in the project:

composer require --dev drupal/coder phpstan/phpstan

The skill checks for these and offers to install them if missing.

Related skills

  • drupal-fix — auto-fix the PHPCS issues that PHPCBF can correct
  • drupal-module — scaffold a new module that starts clean

Clone this wiki locally