Search by

johnatas-x / angry-bearded

johnatas-x

Pre-configured GrumPHP code quality toolkit for Drupal 12 projects.

Package info

github.com/johnatas-x/angry-bearded

Language:Shell

pkg:composer/johnatas-x/angry-bearded

Statistics

Installs: 9 965

Dependents: 0

Suggesters: 0

Stars: 4

Open Issues: 1

4.0.0-rc1 2026-12-05 17:31 UTC

README

Angry Bearded logo

CI Packagist License

A pre-configured GrumPHP for Drupal projects: one composer require brings PHPStan (level 10), PHP_CodeSniffer (Drupal + Slevomat), PHPMD, Mago, Twig linters and more, wired to your Git hooks.

The base configuration is intentionally strict. Your project extends it and only keeps its own adjustments.


πŸ“¦ Which version?

Version Drupal PHP Branch Tested in CI with
^4 12 8.5+ [ΒΉ] main Drupal 12.0 on PHP 8.5 and 8.6
^3 11.3+ 8.4+ [ΒΉ] 3.x Drupal 11.3 / PHP 8.4, 11.4 / PHP 8.5 and 8.6
^2 10.5+, 11 8.3+ 2.x Drupal 10.6 and 11.3 / PHP 8.3, 11.4 / PHP 8.4
^1 10.5+ 8.1, 8.2 1.x Drupal 10.6 on PHP 8.1 and 8.2

All four branches are maintained: dependencies are updated automatically, and each combination above is installed and checked against a real Drupal project on every change (see Maintenance).

[ΒΉ]: PHP 8.6 is experimental, see Known issues.

πŸ”§ Included tools

GrumPHP task Tool Default
phpstan PHPStan level 10, phpstan-drupal, strict, deprecation and banned code rules, dead code detector βœ…
phpcs PHP_CodeSniffer, Drupal Coder, Slevomat, PHPCompatibility βœ…
phpmd3 (phpmd in 1.x) PHPMD βœ…
mago_format, mago_lint Mago, with Mago for Drupal in 4.x. Lint is non-blocking. Not in 1.x. βœ…
mago_analyze, mago_guard Mago ❌
phpcpd PHP Copy/Paste Detector βœ…
phpmnd PHP Magic Number Detector βœ…
phpa PHP Assumptions (via grumphp-phpa) βœ…
phplint PHP Parallel Lint βœ…
twigcs, twigcsfixer Twigcs, Twig CS Fixer βœ…
composer, composer_normalize composer validate, composer-normalize βœ…
securitychecker_composeraudit composer audit βœ…
phpversion Fails when the running PHP version is older than the project's or end of life (warns only in 1.x) βœ…
jsonlint, yamllint, xmllint GrumPHP linters βœ…
git_branch_name, git_commit_message Branch and commit message conventions. The JIRA-123 pattern is an example: adapt it βœ…
composer_require_checker ComposerRequireChecker: needs an autoload section in your composer.json. Suggested (not installed) in 3.x and 4.x ❌
phpdd PhpDeprecationDetector: deprecated (PHP ≀ 8.1 only, PHPCompatibility covers it), removed in 4.0 ❌
git_blacklist, phpunit GrumPHP ❌

πŸš€ Installation

Requirements

  • A Composer-based Drupal project: web/ docroot, custom code in web/modules/custom and web/themes/custom.
  • PHP extension bcmath (included in DDEV and Docksal images).

1. Require the package

Some tools have no stable release yet: your project must accept these pre-releases explicitly (not needed if your minimum-stability is already dev). -W lets Composer adjust shared dependencies.

# Drupal 12
composer require --dev -W johnatas-x/angry-bearded:^4 "phpcompatibility/php-compatibility:*@alpha" "drupal/mago:*@beta"

# Drupal 11.3+
composer require --dev -W johnatas-x/angry-bearded:^3 phpcompatibility/php-compatibility:dev-develop

# Drupal 10.5+ / 11 on PHP 8.3+
composer require --dev -W johnatas-x/angry-bearded:^2 "phpcompatibility/php-compatibility:*@alpha"

# Drupal 10.5+ on PHP 8.1 / 8.2
composer require --dev -W johnatas-x/angry-bearded:^1 "phpcompatibility/php-compatibility:*@alpha"

If GrumPHP asks to create a grumphp.yml file, answer no.

2. Add the project configuration files

The package ships two kinds of files:

  • config/: the base configuration of each tool. It is updated with the package: don't edit it.
  • *.dist at the package root: small project files extending the base configuration, with commented examples.

Copy the project files to your project root without the .dist extension, then commit them:

for file in vendor/johnatas-x/angry-bearded/*.dist vendor/johnatas-x/angry-bearded/.*.dist; do
  cp "$file" "$(basename "$file" .dist)"
done
Project file Extends config/… Tool
grumphp.yml grumphp.yml GrumPHP tasks
phpstan.neon phpstan.neon PHPStan (the base includes phpstan-drupal.neon)
phpstan-drupal-deprecated.neon phpstan-drupal-deprecated.neon Soft alternative: Drupal and Symfony deprecations only
phpcs.xml phpcs.xml PHP_CodeSniffer
phpmd.xml phpmd.xml PHPMD
mago.toml mago.toml Mago (2.x and up; 4.x also extends Mago for Drupal)
.twig-cs-fixer.php twig-cs-fixer.php Twig CS Fixer
.editorconfig β€” Editors
qodana.yaml β€” Qodana template

Delete the files you don't need (e.g. qodana.yaml, phpstan-drupal-deprecated.neon).

Tip

Want full control instead? Copy the files of vendor/johnatas-x/angry-bearded/config/ (renaming twig-cs-fixer.php to .twig-cs-fixer.php): they work as standalone configurations, but you won't get the package updates anymore.

Optional: scaffolding

With drupal/core-composer-scaffold (present in projects created from drupal/recommended-project), the package can copy the .dist project files to your project root on each Composer operation, as a reference to compare your files with. Your own files are never touched.

{
  "extra": {
    "drupal-scaffold": {
      "allowed-packages": ["johnatas-x/angry-bearded"]
    }
  }
}

Add /*.dist and /.*.dist to your .gitignore. To skip some files, see "Excluding scaffold files".

🚧 Usage

Git hooks are installed by GrumPHP on composer install. If they don't trigger, run vendor/bin/grumphp git:init.

vendor/bin/grumphp run                         # Check the whole project.
vendor/bin/grumphp run --tasks=phpstan,phpcs   # Run some tasks only.
vendor/bin/mago lint                           # Details of mago_lint issues (GrumPHP only shows a summary).

Each tool also works on its own (vendor/bin/phpstan analyse, vendor/bin/phpcs, …) with the same configuration. See GrumPHP's documentation for more commands.

πŸ’ˆ Customising

Add your changes to your project files: the .dist templates contain commented examples. How each tool combines your file with the base configuration:

File Your changes…
grumphp.yml Override the base settings. A task declared here replaces the base task entirely: copy its whole block from config/grumphp.yml, then edit it.
phpstan.neon Override parameters; lists (paths, ignoreErrors…) are merged with the base ones.
phpcs.xml Add rules, exclusions, properties, files and paths on top of the base ruleset.
phpmd.xml Add rules; to tune a base rule, exclude it from the base reference and add it back with your properties.
mago.toml Tables are merged into the base ones, arrays are appended.
.twig-cs-fixer.php Change the $config object returned by the base file.

Local environment

Hooks run GrumPHP inside your container through grumphp.git_hook_variables.EXEC_GRUMPHP_COMMAND:

Environment Value
DDEV (default) ddev exec php
Docksal fin exec
PHP on your machine exec

Run vendor/bin/grumphp git:init after changing it. If your composer.json sets config.bin-dir, set parameters.bin_dir accordingly.

Commit message and branch name

git_commit_message and git_branch_name require a JIRA-123 issue key and forbid committing on master / develop. Set your own conventions, or disable them:

# grumphp.yml
grumphp:
  tasks:
    git_commit_message:
      enforce_capitalized_subject: true
      enforce_no_subject_trailing_period: true
      max_subject_width: 60
      matchers:
        Must contain issue number: /PROJ-\d+/
    git_branch_name:
      whitelist:
        - '/^(feature|bugfix|hotfix)\/PROJ-\d+/'
      blacklist:
        - main

Run some tasks only locally, or only in CI

Toggle tasks with environment variables, defaulting to false:

# grumphp.yml
parameters:
  env(IS_DDEV_PROJECT): 'false'
  env(IS_CI): 'false'
grumphp:
  fixer:
    enabled: '%env(bool:IS_DDEV_PROJECT)%'
  tasks:
    phpunit:
      metadata:
        enabled: '%env(bool:IS_CI)%'

Paths

Custom code paths are web/modules/custom and web/themes/custom; tests directories are excluded. For custom install profiles, add web/profiles/custom to phpstan.neon (parameters.paths), phpcs.xml (<file>), mago.toml (source.paths) and .twig-cs-fixer.php.

Deprecations only (soft mode)

For legacy projects, point the phpstan task to the soft configuration, which only reports Drupal and Symfony deprecations:

# grumphp.yml
grumphp:
  tasks:
    phpstan:
      configuration: phpstan-drupal-deprecated.neon
      memory_limit: "-1"
      use_grumphp_paths: false

Mago

In 4.x, mago.toml extends the Mago for Drupal preset, which brings Drupal coding standards rules (aiming for parity with Coder) and analyzer plugins aware of Drupal services, entities and plugins. In 2.x and 3.x, the base configuration follows the same settings without the extension. To use it: composer require --dev "drupal/mago:*@beta", then set extends = ["vendor/drupal/mago/drupal.mago.toml", "vendor/johnatas-x/angry-bearded/config/mago.toml"] in your mago.toml.

Commit banners

The Drupal logo celebrates successful runs, the grumpy one scolds failures (resources/happy.txt is also available). Use your own file, or disable them:

# grumphp.yml
grumphp:
  ascii:
    succeeded: .ddev/files/my-banner.txt
    failed: ~

ComposerRequireChecker

Disabled by default: it only works if your root composer.json declares an autoload section covering your custom code. In 3.x and 4.x, install it first: composer require --dev maglnet/composer-require-checker.

πŸ§ͺ PHPUnit

PHPUnit and drupal/core-dev are not bundled: their versions depend on your Drupal core.

  1. Require drupal/core-dev (same version as your Drupal core) as a dev dependency. 3.x only: drupal/core-dev 11 requires Coder 8 while 3.x ships Coder 9 (for PHP_CodeSniffer 4). Alias it first (Coder 9 is backward compatible):
    "require-dev": {
        "drupal/coder": "9.0.1 as 8.3.31"
    }
  2. Add your phpunit.xml at the project root.
  3. Enable (and configure) the phpunit task in your grumphp.yml.

⬆️ Upgrading

To 1.8 / 2.9 / 3.15 / 4.0

Your files are never overwritten, so nothing breaks, but you can now replace your full copies with the small project files: copy the new .dist templates (see Installation), then re-add only your own adjustments (compare your old files with vendor/johnatas-x/angry-bearded/config/). From then on, the base configuration improves with each update.

Notable base configuration changes:

  • phpcs: standard: [ ] (PHP_CodeSniffer finds phpcs.xml itself).
  • phpa: path: web/modules/custom (it crashed on missing directories).
  • twigcsfixer: paths: [ ], paths now live in .twig-cs-fixer.php (missing directories are skipped).
  • composer_require_checker, phpdd: disabled. Before upgrading to 4.0, remove the phpdd task and the GrumphpPhpdd\ExtensionLoader extension from your grumphp.yml.
  • composer_require_checker (3.x, 4.x): no longer installed, see ComposerRequireChecker.
  • process_timeout: 360, web/profiles/custom removed from paths, tests excluded from PHPStan.
  • phpcs.xml: lowercase {@inheritdoc} enforced, untyped parameters allowed in OOP hooks (*/Hook/*Hooks.php).
  • Mago: the configuration is actually read now (mago.toml.dist never was), aligned with the Mago for Drupal preset.

From 1.x ≀ 1.7 or 2.x ≀ 2.1 (PHPStan 1 era)

  • drupal-check is replaced by PHPStan + phpstan-drupal: remove GrumphpDrupalCheck\ExtensionLoader and the drupal_check task from grumphp.yml.
  • PHPStan 2: remove checkMissingIterableValueType and checkGenericClassInNonGenericObjectType from phpstan.neon (see the PHPStan 2 upgrade guide).
  • phpcs.xml: SlevomatCodingStandard.Files.FunctionLength is now SlevomatCodingStandard.Functions.FunctionLength.
  • Expect new findings from up-to-date Coder and Slevomat rules; most are fixed by vendor/bin/phpcbf.

⚠️ Known issues

  • PHP 8.6 + PHPMD: PHPMD's parallel workers crash on a deprecation raised by PDepend (pdepend/pdepend#996, phpmd/phpmd#1370). Until fixed upstream, disable the phpmd3 task or hide deprecations (error_reporting = E_ALL & ~E_DEPRECATED).
  • Drupal 12 + Drush: no stable Drush release supports Drupal 12 yet.
  • PHP 8.1 is end of life: 1.x keeps working, but phpversion warns and roave/security-advisories refuses PHP 8.1.

πŸ›  Maintenance

  • One branch per major: main (4.x), 3.x, 2.x, 1.x. Fix the oldest affected branch first, then port upward.
  • Dependencies are pinned and updated by Renovate on all branches, automerged when CI passes. Per-branch caps keep each branch compatible with its Drupal / PHP versions.
  • CI (ci.yml) installs the package in a real Drupal project for each supported combination, copies the project files as documented above, then checks that GrumPHP passes on clean code and catches known violations.
  • Run the same test locally with Docker (tests/docker.sh <php> <drupal constraint>), e.g. on main:
    EXTRA_REQS='phpcompatibility/php-compatibility:*@alpha drupal/mago:*@beta' tests/docker.sh 8.5 '^12@rc'