diff options
| author | Lester Caine <lester@lsces.co.uk> | 2026-05-12 20:25:15 +0100 |
|---|---|---|
| committer | Lester Caine <lester@lsces.co.uk> | 2026-05-12 20:25:15 +0100 |
| commit | 9f07784bb817926d226a98684982c7f374688601 (patch) | |
| tree | 89be815deea91bec4038d818be8f1b50c6383711 | |
| parent | 2b5e7e2d1d77a722d41fceb02fbc570317f62db2 (diff) | |
| download | bitweaver-9f07784bb817926d226a98684982c7f374688601.tar.gz bitweaver-9f07784bb817926d226a98684982c7f374688601.tar.bz2 bitweaver-9f07784bb817926d226a98684982c7f374688601.zip | |
add php-cs-fixer config for code style modernisation
Excludes vendor, externals, webtrees, webtrees-upstream, and third-party
libs under util/includes/. Rules cover array short syntax, single quotes,
trailing commas, PHP 8.x casts/arrow functions/null coalescing, and dead
code cleanup.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
| -rw-r--r-- | .php-cs-fixer.php | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php new file mode 100644 index 0000000..8801d4e --- /dev/null +++ b/.php-cs-fixer.php @@ -0,0 +1,51 @@ +<?php + +$finder = PhpCsFixer\Finder::create() + ->in(__DIR__) + ->exclude('vendor') + ->exclude('externals') + ->exclude('webtrees') + ->exclude('webtrees-upstream') + ->exclude('util/includes/pear') + ->exclude('util/includes/getid3') + ->exclude('util/includes/simplepie') + ->exclude('util/includes/jpeg_metadata_tk') + ->exclude('util/includes/datasets') + ->exclude('util/includes/htmlpurifier-4.15.0') + ->exclude('util/includes/phpmailer') + ->exclude('util/includes/phpsniff') + ->exclude('util/includes/phpcoord') + ->exclude('util/includes/htmlparser') + ->exclude('util/includes/htmlpure') + ->exclude('util/includes/spyc') + ->exclude('util/includes/dBug') + ->exclude('util/includes/cufon') + ->exclude('utils/pear'); + +return (new PhpCsFixer\Config()) + ->setRiskyAllowed(true) + ->setRules([ + // Already applied + 'array_syntax' => ['syntax' => 'short'], + + // Code style & formatting + 'single_quote' => true, + 'trailing_comma_in_multiline' => ['elements' => ['arrays', 'arguments', 'parameters']], + 'no_trailing_whitespace' => true, + 'no_extra_blank_lines' => ['tokens' => ['extra', 'throw', 'use']], + 'ordered_imports' => ['sort_algorithm' => 'alpha'], + 'blank_line_after_namespace' => true, + 'no_whitespace_in_blank_line' => true, + + // PHP 8.x modernisation + 'modernize_types_casting' => true, // intval() → (int) etc. [risky] + 'get_class_to_class_keyword' => true, // get_class($x) → $x::class + 'ternary_to_null_coalescing' => true, // isset($x) ? $x : $y → $x ?? $y + 'use_arrow_functions' => true, // eligible closures → fn() => [risky] + + // Dead code cleanup + 'no_unused_imports' => true, + 'no_useless_else' => true, + 'no_useless_return' => true, + ]) + ->setFinder($finder); |
