hipsterjazzbo / php-style
Shared PHP-CS-Fixer configuration for HipsterJazzbo projects.
Requires
- php: ^8.3
- friendsofphp/php-cs-fixer: ^3.95
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Shared PHP-CS-Fixer rules for my PHP projects.
The package owns the common rules. Each project still owns its own Finder, so repositories can decide which directories should be formatted.
Install
Once the package is available on Packagist:
composer require --dev hipsterjazzbo/php-style:^0.1
Before the first Packagist release is indexed, Composer can install directly from GitHub by adding this repository as a VCS source and requiring dev-main.
Use
Create .php-cs-fixer.dist.php in the consuming project:
<?php declare(strict_types=1); use HipsterJazzbo\PhpStyle\PhpStyle; use PhpCsFixer\Finder; $finder = Finder::create()->in([ __DIR__ . '/src', __DIR__ . '/tests', __DIR__ . '/examples', ]); return PhpStyle::config($finder);
Project-specific overrides
A project can replace individual shared rules without copying the whole configuration:
return PhpStyle::config($finder, [ 'blank_line_before_statement' => [ 'statements' => ['return', 'throw'], ], ]);
Or use PhpStyle::rules() directly when a repository needs to build a more unusual Config.
What this does not enforce
PHP-CS-Fixer can format declaration docblocks, but it does not prove that every declaration has a useful human-readable description.
Repositories that require descriptive PHPDoc should keep a separate parser/AST-based documentation check for that policy.