Add PHP CS Fixer for consistent code style

This commit is contained in:
Ramon Caballero 2026-04-09 14:11:22 +01:00
parent ba5a8dc8ea
commit 4b23dfd18b
4 changed files with 2640 additions and 2 deletions

3
.gitignore vendored
View File

@ -13,3 +13,6 @@ var/
# PHPUnit caches:
.phpunit.cache/
.phpunit.result.cache
# PHP CS Fixer caches:
.php-cs-fixer.cache

34
.php-cs-fixer.dist.php Normal file
View File

@ -0,0 +1,34 @@
<?php
use PhpCsFixer\Config;
use PhpCsFixer\Finder;
$finder = Finder::create()
->in(__DIR__ . '/src')
->in(__DIR__ . '/tests')
->in(__DIR__ . '/public')
->in(__DIR__ . '/config')
->exclude('vendor')
->name('*.php')
->ignoreDotFiles(true)
->ignoreVCS(true);
return (new Config())
->setIndent("\t")
->setRiskyAllowed(true)
->setRules([
'@PSR12' => true,
'array_syntax' => ['syntax' => 'short'],
'blank_line_before_statement' => ['statements' => ['return', 'throw', 'break', 'continue', 'exit']],
'braces_position' => ['control_structures_opening_brace' => 'next_line_unless_newline_at_signature_end'],
'control_structure_continuation_position' => ['position' => 'next_line'],
'indentation_type' => true,
'no_extra_blank_lines' => true,
'no_trailing_whitespace' => true,
'no_unused_imports' => true,
'ordered_imports' => true,
'single_blank_line_at_eof' => true,
'single_import_per_statement' => true,
'trailing_comma_in_multiline' => ['elements' => ['arrays', 'arguments']],
])
->setFinder($finder);

View File

@ -13,6 +13,7 @@
}
},
"require-dev": {
"phpunit/phpunit": "^12.5"
"phpunit/phpunit": "^12.5",
"friendsofphp/php-cs-fixer": "^3.94"
}
}

2602
composer.lock generated

File diff suppressed because it is too large Load Diff