edmondscommerce / phpqa
Simple PHP QA pipeline and scripts. Largely just a collection of dependencies with configuration and scripts to run them together
Installs: 22 277
Dependents: 13
Suggesters: 0
Security: 0
Stars: 6
Watchers: 2
Forks: 2
Open Issues: 14
Type:project
Requires
- php: ^7.2|^8.0
- ext-json: *
- edmondscommerce/php-parallel-lint: ~1.0.1
- friendsofphp/php-cs-fixer: ^2.16
- funkyproject/reflection-file: ^0.1.0
- infection/infection: ^0.10|^0.20
- jakub-onderka/php-console-highlighter: ^0.3.2
- maglnet/composer-require-checker: ^2.0
- phploc/phploc: ^4.0|^5.0|^6.0|^7.0
- phpmd/phpmd: ^2.8
- phpstan/extension-installer: ^1.0
- phpstan/phpstan: ^0.12
- phpstan/phpstan-strict-rules: ^0.12
- phpunit/phpunit: ^8.0|^9.0
- sllh/composer-versions-check: ^2.0
- squizlabs/php_codesniffer: ~3
Requires (Dev)
- phpstan/phpstan-phpunit: ^0.12
Suggests
- nunomaduro/larastan: Laravel specific checks (PHPStan Wrapper)
- phpstan/phpstan-deprecation-rules: Checks for deprecated functions and methods
- phpstan/phpstan-doctrine: Adds checks for Doctrine
- phpstan/phpstan-mockery: Prevents Mockery from failing on Stan
- phpstan/phpstan-phpunit: Adds checks for PHPUnit tests
- phpstan/phpstan-symfony: Symfony specific checks
- dev-master
- 4.2.3
- 4.2.2
- 4.2.1
- 4.2.0
- 4.1.1
- 4.1.0
- 4.0.3
- 4.0.2
- 4.0.1
- 4.0.0
- 3.1.0
- 3.0.0
- 2.0.x-dev
- 2.0.11
- 2.0.10
- 2.0.9
- 2.0.8
- 2.0.7
- 2.0.6
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 1.2.x-dev
- 1.2.13
- 1.2.12
- 1.2.11
- 1.2.10
- 1.2.9
- 1.2.8
- 1.2.7
- 1.2.6
- 1.2.5
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.1.1
- 1.1.0
- 1.0.1
- 1.0.0
- 0.0.3
- 0.0.2
- 0.0.1
- dev-php8
- dev-xdebug-readme-install
- dev-symfony5
- dev-FixLaravelSetPaths
- dev-PhpStanAutoLoadExtension
- dev-ParallelLintFork
- dev-ForkOfParallelLint
- dev-HotFix
This package is auto-updated.
Last update: 2024-10-23 19:20:50 UTC
README
By Edmonds Commerce
Version 4 Updates
Brings in PHPStan 0.12 which is great
However you will need to do the following:
Remove PHPStan symlinks before upgrading
rm -f bin/phpstan*
Ensuring Correct PHPStan Configs
If you are overriding phpstan.neon
in your qaConfig
folder, then you need to make sure you have this in there:
parameters: level: max inferPrivatePropertyTypeFromConstructor: true
Version 3 Updates
You should update your phpunit.xml file to use printerClass="\PHPUnit\Util\TestDox\CliTestDoxPrinter"
Introduction
PHPQA is a quality assurance pipeline written in BASH that can be run both on the desktop as part of your development process and then also as part of a continuous integration (CI) pipeline.
It runs tools in a logical order and will fail as quickly as possible.
PHPQA has only been tested on Linux.
Installing
You can follow dev-master which should generally be pretty stable (all features are developed in feature branches and must pass CI before making it into master. Alternatively if you want real stability, you can track a release version of your choice.
composer require edmondscommerce/phpqa:dev-master@dev --dev
Your project's composer.json
needs to specify a bin folder. If it's not already present, add this:
...
"config": {
"bin-dir": "bin"
}
...
Running
To run the full pipline, simply execute in your BASH terminal:
./bin/qa
Usage:
$ ./bin/qa -h
Usage:
bin/qa [-t tool to run ] [ -p path to scan ]
Defaults to using all tools and scanning whole project based on platform
- use -h to see this help
- use -p to specify a specific path to scan
- use -t to specify a single tool:
psr|psr4 psr4 validation
com|composer composer validation
st|stricttypes strict types validation
lint|phplint phplint
stan|phpstan phpstan
unit|phpunit phpunit
infect|infection infection
md|messdetector php mess detector
ma|markdown markdown validation
bf|phpbf php beautifier and fixer
cs|phpcs php code sniffer
l|loc lines of code and other stats
By default, PHPQA will run against the entire project root.
Single Tool:
If you want to run a single tool, use the -t
option. See the usage above to get the shortcuts for the tools
./bin/qa -t stan
Specified Path:
Some of the tools allow us to restrict the scan to a specified path. To specify the path, use the -p
option.
./bin/qa -p ./src/specified/path.php
Combined
You can combine both options
./bin/qa -t stan -p ./src/specified/path.php
Configuration
Please see the Configuration docs
The Pipeline
Please see the Pipeline docs
The QA Tools
For full details and configuration instructions for all fo the tools, please see the PHPQA Tools
Platform Detection
PHPQA comes with a set of generic tools and configs, but also has some inbuilt profiles.
Information on how this works can be found on the platform detection page
Specific platforms' docs are at:
Using for Continuous Integration (CI)
Please see the CI docs
Git Hooks
Have a look in gitHooks for git hooks that can be used in your project
The suggested way to use these is to symlink. Note that your actual git hook should not include the .bash
file extension
To use the pre-commit
hook, for example, you would do:
#cd to project root cd /var/www/project/root #cd to hooks folder cd .git/hooks/ #create relative symlink ln -s ../../vendor/edmondscommerce/phpqa/gitHooks/pre-commit.bash pre-commit
Then ensure the hook is executable by running it:
#cd to project root cd /var/www/project/root ./git/hooks/pre-commit
And you should then see
===========================================
PHPQA Pre Commit Hook
===========================================