Search by

bear / qatools

koriym

PHP QA Tools

Package info

github.com/bearsunday/BEAR.QATools

pkg:composer/bear/qatools

Statistics

Installs: 117 351

Dependents: 5

Suggesters: 0

Stars: 22

Open Issues: 0

1.13.0 2025-12-03 02:32 UTC

README

Collection of commonly used PHP QA tools.

Included in this package are:

Installation

Global install

composer global require bear/qatools

Local install

composer require --dev bear/qatools

QA Configs

cp vendor/bear/qatools/phpcs.xml .
cp vendor/bear/qatools/phpmd.xml .
cp vendor/bear/qatools/phpstan.neon .
psalm --init

For PHPUnit, copy the template matching your PHPUnit major version:

# PHPUnit 9
cp vendor/bear/qatools/phpunit.xml.dist phpunit.xml

# PHPUnit 10, 11 or 12
cp vendor/bear/qatools/phpunit10.xml.dist phpunit.xml

PHPUnit 10 replaced the configuration schema, and the two are not interchangeable — phpunit.xml.dist triggers a deprecation notice on PHPUnit 10 and later, while phpunit10.xml.dist is rejected by PHPUnit 9. PHPUnit 9 remains supported because PHPUnit 10, 11 and 12 require PHP 8.1, 8.2 and 8.3 respectively, so it is the only line installable on PHP 7.4 and 8.0.

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 ./phpmd.xml

phpmetrics

phpmetrics --report-html=build/metrics src

Code Standards

  • PSR-12 base with Doctrine Coding Standard
  • PHPStan level: max, over src and tests
  • Psalm errorLevel: 1, over src only
  • PHP compatibility: 7.4+

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.