Code Formatting¶
Canonical PHP CS Fixer config:
.php-cs-fixer.dist.php
<?php
$finder = PhpCsFixer\Finder::create()
->in(['src', 'src/tests'])
->exclude(['vendor'])
->notPath('Template.php');
return (new PhpCsFixer\Config())
->setRules([
'@PhpCsFixer' => true,
'@PSR12' => true,
'yoda_style' => false,
'increment_style' => false,
'array_syntax' => ['syntax' => 'short'],
'ordered_imports' => ['sort_algorithm' => 'alpha'],
'no_unused_imports' => true,
'fully_qualified_strict_types' => false,
'global_namespace_import' => [
'import_classes' => true,
],
'single_quote' => true,
'concat_space' => ['spacing' => 'one'],
'blank_line_after_namespace' => true,
'blank_line_before_statement' => [
'statements' => ['return', 'if', 'for', 'foreach', 'while', 'switch'],
],
'method_chaining_indentation' => true,
'multiline_whitespace_before_semicolons' => ['strategy' => 'no_multi_line'],
])
->setRiskyAllowed(false)
->setUnsupportedPhpVersionAllowed(true)
->setFinder($finder);