bear / qatools
PHP QA Tools
Package info
github.com/bearsunday/BEAR.QATools
Type:phpcodesniffer-standard
pkg:composer/bear/qatools
Requires
- php: ^8.2.27
- doctrine/coding-standard: ^14.0
- phpmd/phpmd: ^2.11
- phpmetrics/phpmetrics: ^2.7
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^11.3 || ^12.0
- squizlabs/php_codesniffer: ^4.0
- vimeo/psalm: ^6.11
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
- dev-master
- 1.14.0
- 1.13.0
- 1.12.0
- 1.11.0
- 1.10.0
- 1.9.12
- 1.9.11
- 1.9.10
- 1.9.9
- 1.9.8
- 1.9.7
- 1.9.6
- 1.9.5
- 1.9.4
- 1.9.3
- 1.9.2
- 1.9.1
- 1.9.0
- 1.8.0
- 1.7.3
- 1.7.2
- 1.7.1
- 1.7.0
- 1.6.1
- 1.6.0
- 1.5.0
- 1.4.9
- 1.4.8
- 1.4.7
- 1.4.6
- 1.4.5
- 1.4.4
- 1.4.3
- 1.4.2
- 1.4.1
- 1.4.0
- 1.3.0
- 1.2.0
- 1.1.2
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0
- dev-widen-tool-constraints
- dev-claude/improvement-ideas-3q6bny
This package is auto-updated.
Last update: 2026-11-05 17:12:12 UTC
README
Collection of commonly used PHP QA tools.
Included in this package are:
- phpunit/phpunit The PHP Unit Testing framework.
- phpmd/phpmd PHPMD is a spin-off project of PHP Depend and aims to be a PHP equivalent of the well known Java tool PMD.
- squizlabs/php_codesniffer PHP_CodeSniffer tokenises PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.
- doctrine/coding-standard The PHP_CodeSniffer ruleset the bundled
BearSundaystandard builds on. - phpstan/phpstan A PHP Static Analysis Tool.
- vimeo/psalm A static analysis tool for PHP.
- phpmetrics/phpmetrics Static analysis tool for PHP.
Installation
Global install
composer global require bear/qatools
Local install
composer require --dev bear/qatools
QA Configs
PHP_CodeSniffer, PHPStan and PHPMD are configured by reference rather than by
copying, so fixes to the shared rules reach your project with composer update.
The vendor/bear/qatools/ paths below assume the local install above. A global
install puts the package outside your project, so adjust the paths to wherever
composer global config home reports, or install locally. A globally registered
PHP_CodeSniffer standard is also invisible to a project-local vendor/bin/phpcs,
which is what editors usually pick up.
PHP_CodeSniffer — bear/qatools registers itself as a standard named
BearSunday, so your phpcs.xml only needs to name it:
<ruleset>
<config name="php_version" value="80200"/>
<file>src</file>
<file>tests</file>
<exclude-pattern>*/tests/Fake/*</exclude-pattern>
<exclude-pattern>*/tests/tmp/*</exclude-pattern>
<rule ref="BearSunday"/>
</ruleset>
Registration happens through dealerdirect/phpcodesniffer-composer-installer,
which Composer only runs if your project allows it:
composer config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
Without that, composer install fails with a blocked-plugin error, or — if the
plugin is explicitly denied — installs quietly and leaves phpcs reporting
Referenced sniff "BearSunday" does not exist. Standard names are global with no
namespacing; phpcs -e --standard=BearSunday shows what the name resolved to.
PHPStan — include the shared settings and add your own paths:
includes:
- vendor/bear/qatools/phpstan-base.neon
parameters:
paths:
- src
- tests
PHPMD — point at the shipped ruleset directly, no local file needed:
phpmd src text vendor/bear/qatools/phpmd.xml
Ready-made versions of the first two are in the package root if you would rather start from a copy than write your own:
cp vendor/bear/qatools/phpcs.xml .
cp vendor/bear/qatools/phpstan.neon .
Psalm — copy-based; Psalm has no mechanism for including an external config:
cp vendor/bear/qatools/psalm.xml .
PHPUnit — copy-based; the template is project-local by nature:
cp vendor/bear/qatools/phpunit.xml.dist phpunit.xml
CI Configs
cp vendor/bear/qatools/.scrutinizer.yml .
Usage
Composer Scripts
Composer does not inherit scripts from dependencies, so copy the scripts block from
vendor/bear/qatools/composer.json into your own composer.json to get these:
composer tests # Run cs, sa, and test in sequence
composer test # Run PHPUnit tests
composer cs # Run PHP_CodeSniffer
composer cs-fix # Auto-fix coding standard violations with phpcbf
composer sa # Run all static analysis (phpstan, psalm, phpmd)
composer coverage # Generate test coverage report
composer metrics # Generate PHPMetrics HTML report
Direct Commands
phpunit
phpunit
phpcs
phpcs --standard=./phpcs.xml src
phpstan
phpstan analyse -c phpstan.neon
psalm
psalm
phpmd
phpmd src text vendor/bear/qatools/phpmd.xml
phpmetrics
phpmetrics --report-html=build/metrics src
Code Standards
- PSR-12 base with Doctrine Coding Standard
- PHPStan level: max, over
srcandtests - Psalm errorLevel: 1, over
srconly - PHP compatibility: 8.2.27+, and 8.3.16+ on PHP 8.3
The 8.3 floor comes from Psalm 6, which requires ~8.2.27 || ~8.3.16 || ~8.4.3 || ~8.5.0;
Composer refuses to install on PHP 8.3.0–8.3.15, including Ubuntu 24.04's stock 8.3.6.
Psalm is deliberately kept off tests: errorLevel 1 is too strict for test code,
where rules such as ClassMustBeFinal work against normal PHPUnit practice.
UnusedClass is suppressed as a consequence — with only src analysed, a class
reached through the framework or used only from tests looks unused. Test code is
still covered by phpcs and PHPStan.