wunderio / code-quality
Code Quality checker wrapper for GrumPHP
Installs: 101 239
Dependents: 1
Suggesters: 0
Security: 0
Stars: 3
Watchers: 27
Forks: 6
Open Issues: 34
Type:phpcodesniffer-standard
pkg:composer/wunderio/code-quality
Requires
- dealerdirect/phpcodesniffer-composer-installer: *
- drupal/coder: ^8
- mglaman/phpstan-drupal: ^1.1
- nette/finder: ^2.5
- pheromone/phpcs-security-audit: ^2.0
- phpcompatibility/php-compatibility: ^9.3
- phpro/grumphp: ^2.5
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- squizlabs/php_codesniffer: ^3.4
- symfony/polyfill-iconv: ^1
- tomasvotruba/cognitive-complexity: ^0.1.1
- webflo/drupal-finder: ^1.3
Requires (Dev)
- phpunit/phpunit: ^8.3
- dev-main
- 3.0.2
- 3.0.1
- 3.0.0
- 2.x-dev
- 2.4.0
- 2.3.0
- 2.2.2
- 2.2.1
- 2.2.0
- 2.1.0
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 1.x-dev
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- 0.2.0
- 0.1.7
- 0.1.6
- 0.1.5
- 0.1.4
- 0.1.3
- 0.1.2
- 0.1.1
- 0.1.0
- dev-feature/+116-add-help-how-to-configure-phpcs-in-cursor
- dev-feature/89-Upgrade-Psalm
- dev-sonar-scanner
- dev-feature/108-Integrate-vscode-and-PhpStorm
- dev-hotfix/106-Change-yaml-and-json-task-default-paths
- dev-feature/72-Re-add-code-complexity
- dev-hotfix/99-fix-php_stan-error-with-DrupalAutoloader
- dev-hotfix/+99-fix-php_stan-error-with-DrupalAutoloader
- dev-feature/72-Re-add-ecs-and-code-complexity-for-D10
- dev-feature/93-add-phpstan-extension-installer
- dev-feature/+91-finder-version
- dev-feature/91-finder-version
- dev-fix-autoloader
- dev-feature/+86-Adjust-coding-standards-so-that-it-would-be-possible-to-run-phpcs-with-Lando-PhpStorm
- dev-feature/+84-add-eslint-task
- dev-feature/84-add-eslint-task
- dev-feature/+78-Add-info-to-readme-how-to-run-task-specific-tasks
- dev-feature/+79-Change-the-default-PHP-code-checker-version-to-8.0
- dev-feature/+79-Change-the-default-PHP-code-checker-version-to-8.1
- dev-feature/62-add-psalm-task
- dev-feature/69-Use-local-phpstan.neon
- dev-feature/68-Update-PHPStan
- dev-feature/67-Update-ECS-to-latest-possible-version
- dev-feature/+59-support-drupal-8-and-composer-2
- dev-feature/grumphp-upgrade
- dev-feature/+41-legacy-support
This package is auto-updated.
Last update: 2025-11-03 18:09:42 UTC
README
This composer package will provide some basic code quality checks before committing code by using https://github.com/phpro/grumphp.
It checks only modified files or new files on git commit, but check on all configured
paths can be executed running vendor/bin/grumphp run
This tool only extends GrumPHP. Please read its documentation on how to configure tool itself.
Checks performed
This repository currently has the following checks:
- Shell script exec bits - check_file_permissions
- PHP Drupal CS and PHP Code security - phpcs
- PHP 8.1 Compatibility - php_compatibility
- PHP syntax - php_check_syntax
- Cognitive complexity and other ecs sniffs - ecs
- Yaml syntax - yaml_lint
- Json syntax - json_lint
- Deprecation testing - php_stan
Pre-requisites
- Composer
- PHP >= 8.1
Installation
This needs to be done only once either while creating a project or enabling code checks in existing project.
composer require wunderio/code-quality --dev
cp vendor/wunderio/code-quality/config/grumphp.yml ./grumphp.yml
cp vendor/wunderio/code-quality/config/phpstan.neon ./phpstan.neon
cp vendor/wunderio/code-quality/config/psalm.xml ./psalm.xml
The commit hook for GrumPHP is automatically installed on composer require.
Customization
Configuration
Details of the configuration are broken down into the following sections.
- Parameters – Configuration settings for GrumPHP itself.
- Tasks – External tasks performing code validation and their respective configurations.
- TestSuites
- Extensions
- Events
- Conventions checker
Task parameters
If you need to customize the rules for PHP CodeSniffer then drop in phpcs.xml in the same folder as composer.json and configure grumphp.yml:
parameters: tasks: phpcs: standard: - phpcs.xml
Same applies to any task that uses other configuration file (easy-coding-standards).
Each code quality tool allows you to define at least 3 things:
run_on- Multiple paths that will be checked and files staged must be from same pathignore_patterns- path parts that will exclude files from checkextensions- file extensions of files that should be checked
Please see individual task documentation for more information on what are other configurable options.
Commands
Since GrumPHP is just a CLI tool, these commands can be triggered:
Usage
The pre-commit hook will be automatically run upon executing git commit.
The code scanning can be avoided by git commit --no-verify or git commit -n but is only meant for rare occasions.
You can run the checks manually with: ./vendor/bin/grumphp run
To run specific task from the defined tasks in grumphp.yml, you can define it with --tasks parameter. Example:
./vendor/bin/grumphp run --tasks=phpcs
Usage in Continuous Integration
You can easily use the code quality checkers on your CI (CircleCi/Jenkins/GitLab CI) by adding this line:
./vendor/bin/grumphp run --no-ansi --no-interaction
IDE Integration (optional)
Prerequisites
Minimally Code Quality 2.2.1 is needed because it contains the WunderAll ruleset that groups all Wunder rulesets.
Ubuntu
To install the necessary PHP components without Apache:
sudo apt install php-cli php-tokenizer
macOS
- Install Homebrew if you don't have it installed already (see instructions on https://brew.sh/)
- Install PHP with Homebrew
brew install php
Configuration
Visual Studio Code
- Install the Drupal extension.
- Open the Drupal extension configuration.
- Find "Drupal > Phpcs: Args" and "Drupal > Phpcbf: Args".
- Click "Edit in settings.json" and add:
{
"drupal.phpcs.args": [
"--standard=WunderAll"
],
"drupal.phpcbf.args": [
"--standard=WunderAll"
]
}
PHPCS usage Example in Visual Studio Code:

PhpStorm
Open settings and look for PHP_Codesniffer. Make sure these settings are the same:
Warnings are underlined and you can choose to fix them by right clicking:
Choose the "PHP Code Beautifier and Fixer: fix the whole file"