jbzoo / codestyle
Collection of QA tools and JBZoo code standards
Installs: 1 104 787
Dependents: 5
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/jbzoo/codestyle
Requires
- php: ^8.2
- friendsofphp/php-cs-fixer: >=3.88.2
- jbzoo/data: ^7.1.1
- kubawerlos/php-cs-fixer-custom-fixers: >=3.35.0
- nikic/php-parser: >=5.6.1
- pdepend/pdepend: >=2.16.2
- phan/phan: >=5.5.1
- phpmd/phpmd: >=2.15.0
- phpmetrics/phpmetrics: >=2.9.1
- phpstan/phpstan: >=2.1.29
- phpstan/phpstan-strict-rules: >=2.0.7
- povils/phpmnd: >=3.6.0
- squizlabs/php_codesniffer: >=4.0.0
- symfony/console: >=7.3.4
- symfony/finder: >=7.3.2
- symfony/yaml: >=7.3.3
- vimeo/psalm: >=6.7.0
Requires (Dev)
- jbzoo/phpunit: ^7.1
- jbzoo/utils: ^7.2.2
- symfony/var-dumper: >=7.3.4
- dev-master / 7.x-dev
- 7.2.0
- 7.1.6
- 7.1.5
- 7.1.4
- 7.1.3
- 7.1.2
- 7.1.1
- 7.1.0
- 7.0.3
- 7.0.2
- 7.0.1
- 7.0.0
- 5.0.0
- 4.1.0
- 4.0.2
- 4.0.1
- 4.0.0
- 3.4.0
- 3.3.4
- 3.3.3
- 3.3.2
- 3.3.1
- 3.3.0
- 3.2.3
- 3.2.2
- 3.2.1
- 3.2.0
- 3.1.0
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0
- 2.19.0
- 2.18.2
- 2.18.1
- 2.18.0
- 2.17.0
- 2.16.1
- 2.16.0
- 2.15.0
- 2.14.0
- 2.13.0
- 2.12.0
- 2.11.1
- 2.11.0
- 2.10.0
- 2.9.4
- 2.9.3
- 2.9.2
- 2.9.1
- 2.9.0
- 2.8.1
- 2.8.0
- 2.7.7
- 2.7.6
- 2.7.5
- 2.7.4
- 2.7.3
- 2.7.2
- 2.7.1
- 2.7.0
- 2.6.1
- 2.6.0
- 2.5.5
- 2.5.4
- 2.5.3
- 2.5.2
- 2.5.1
- 2.5.0
- 2.4.1
- 2.4.0
- 2.3.2
- 2.3.1
- 2.3.0
- 2.2.0
- 2.1.1
- 2.1.0
- 2.0.0
- 1.1.1
- 1.1.0
- 1.0.0
- dev-badges
- dev-fix-perms
- dev-fix-tests
- dev-phpstan-config
- dev-bump-versions
- dev-migrate-phpunit-config
This package is auto-updated.
Last update: 2025-09-28 11:19:37 UTC
README
Comprehensive collection of QA tools and code quality standards for PHP 8.2+ projects. Provides configurations and wrappers for PHPStan, Psalm, PHP-CS-Fixer, PHPUnit, PHPMD, Phan and other popular code analysis tools.
Requirements
- PHP 8.2+ - Modern PHP version with strict typing support
- Composer - For dependency management
- Make - Build automation tool
Installation
composer require --dev jbzoo/codestyle
Quick Start
Add the following to your project's Makefile
to get access to all QA tools:
ifneq (, $(wildcard ./vendor/jbzoo/codestyle/src/init.Makefile)) include ./vendor/jbzoo/codestyle/src/init.Makefile endif update: ##@Project Install/Update all 3rd party dependencies $(call title,"Install/Update all 3rd party dependencies") @echo "Composer flags: $(JBZOO_COMPOSER_UPDATE_FLAGS)" @composer update $(JBZOO_COMPOSER_UPDATE_FLAGS) test-all: ##@Project Run all project tests at once @make test @make codestyle
Available Tools
This package includes configurations for:
- PHPStan - Static analysis tool with strict rules
- Psalm - Advanced static analysis with type coverage
- PHP-CS-Fixer - Code style fixer with PSR-12 and custom rules
- PHPCS - Code sniffer for PSR-12 and PHP compatibility
- PHPMD - Mess detector for code quality issues
- PHPUnit - Unit testing framework with coverage reporting
- Phan - Super strict static analyzer
- PHPMND - Magic number detector
- PHPCPD - Copy-paste detector
Common Commands
Development
make update # Install/update dependencies make autoload # Dump optimized autoloader make clean # Cleanup build directory
Testing
make test # Run PHPUnit tests make test-all # Run all tests and code style checks make codestyle # Run all code style linters
Individual QA Tools
make test-phpstan # Static analysis with PHPStan make test-psalm # Static analysis with Psalm make test-phpcs # Code sniffer (PSR-12 + compatibility) make test-phpcsfixer # Check PHP-CS-Fixer rules make test-phpcsfixer-fix # Auto-fix with PHP-CS-Fixer make test-phpmd # Mess detector make test-phan # Phan static analyzer
Reports
make report-all # Generate all reports make report-phpmetrics # PHP Metrics report make report-pdepend # PHP Depend report
Complete Command Reference
Usage:
- `make [target]`
- `make [target] OPTION=value`
- `ENV_VAR=value make [target]`
Misc:
help Show this text
list Full list of targets
Project:
autoload Dump optimized autoload file for PHP
build-phar Compile phar file
clean Cleanup only build directory
clean-vendor Cleanup all
test-all Run all project tests at once
update Install/Update all 3rd party dependencies
Tests:
codestyle Launch all codestyle linters at once
test Launch PHPUnit Tests (alias "test-phpunit")
test-composer Validates composer.json and composer.lock
test-composer-reqs Checks composer.json the defined dependencies against your code
test-performance Run benchmarks and performance tests
test-phan Phan - super strict static analyzer for PHP
test-phpcpd PHPcpd - Find obvious Copy&Paste
test-phpcs PHPcs - Checking PHP Code Sniffer (PSR-12 + PHP Compatibility)
test-phpcsfixer PhpCsFixer - Check code to follow stylish standards
test-phpcsfixer-fix PhpCsFixer - Auto fix code to follow stylish standards
test-phpmd PHPmd - Mess Detector Checker
test-phpmd-strict PHPmd - Mess Detector Checker (strict mode)
test-phpmnd PHPmnd - Magic Number Detector
test-phpstan PHPStan - Static Analysis Tool
test-phpunit PHPUnit - Launch General Tests
test-psalm Psalm - static analysis tool for PHP
Reports:
report-all Build all reports at once
report-composer-diff What has changed after a composer update
report-composer-graph Build composer graph of dependencies
report-coveralls Send coverage report to coveralls.io
report-merge-coverage Merge all coverage reports in one clover file
report-pdepend Build PHP Depend Report
report-performance Build performance summary report
report-phploc PHPloc - Show code stats
report-phpmetrics Build PHP Metrics Report
update-extend Checks new compatible versions of 3rd party libraries
Trick: Add into your "~/.bash_aliases" the line "complete -W "\`make list\`" make" to use TAB
Integration with IDEs
The package provides configurations that work seamlessly with:
- PhpStorm - Built-in support for all tools
- VS Code - Extensions available for all included tools
- Vim/Neovim - LSP support through various plugins
Advanced Usage
Custom PHP-CS-Fixer Rules
Extend the base configuration in your .php-cs-fixer.php
:
use JBZoo\Codestyle\PhpCsFixer\PhpCsFixerCodingStandard; return (new PhpCsFixerCodingStandard(__DIR__)) ->addCustomRules([ 'your_custom_rule' => true, ]) ->getFixerConfig();
PHPUnit Base Classes
Use the provided base test classes for consistent testing:
use JBZoo\Codestyle\PHPUnit\AbstractPackageTest; class YourPackageTest extends AbstractPackageTest { protected string $packageName = 'your-package-name'; }
Contributing
Contributions are welcome! Please ensure:
- All tests pass:
make test-all
- Code follows our standards:
make codestyle
- Coverage remains high:
make report-all
License
MIT License. See LICENSE file for details.