ely/php-code-style
Opinionated PHP-CS-Fixer rule set from Ely.by for PHP 7.4+ projects. Install alongside friendsofphp/php-cs-fixer, add a .php-cs-fixer.php using Ely\CS\Config, optionally override rules, then run php-cs-fixer to lint and fix code style.
Start by installing the package alongside PHP-CS-Fixer as a development dependency:
composer require --dev friendsofphp/php-cs-fixer ely/php-code-style
Then create .php-cs-fixer.php using the provided config helper:
<?php
$finder = \PhpCsFixer\Finder::create()->in(__DIR__);
return \Ely\CS\Config::create()->setFinder($finder);
Run dry-run to preview style fixes:
vendor/bin/php-cs-fixer --diff --dry-run fix
Apply fixes:
vendor/bin/php-cs-fixer fix
This is the fastest path to get automatic formatting for Ely.by’s opinionated PSR-2/PSR-12-adjacent style.
\Ely\CS\Config::create() with no arguments for standard Ely.by rules—works with PHP 7.4+.create() for minor tweaks, e.g., to enable trailing commas in method arguments and arrays:
\Ely\CS\Config::create([
'trailing_comma_in_multiline' => ['elements' => ['arrays', 'arguments']],
])
php-cs-fixer --dry-run in CI pipelines to fail builds on style violations.husky or manual hook) to run php-cs-fixer fix before commits.php-cs-fixer as the formatter for PHP files—set to vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --path-mode=override --using-cache=no $FileDir$/$FileName$.braces_fixer, self_accessor)—these have been moved to separate repo. Do not expect them in current releases.class Foo {), but for methods it goes on the next line (function bar() {), violating typical PSR conventions—watch for merge conflicts during adoptations.return only if there are multiple preceding statements (per blank_line_before_return), and a blank line after control structures (if, for, etc.). These are easily missed in diffs.Ely\align_multiline_parameters disabled by default)—rely on natural indentation instead of equals-sign alignment.declare(strict_types=1), readonly properties) are opinionated. Confirm compatibility with your target runtime.--parallel and configure cache manually for larger repos to improve performance.-vvv to see which fixers are applied and why, especially helpful when unexpected formatting occurs (e.g., comment_to_phpdoc preserves PHPStan suppressions and @todo).How can I help you explore Laravel packages today?