Skip to content

PHP-CS-Fixer🔗

Installlation🔗

1
composer require --dev friendsofphp/php-cs-fixer

Configuration🔗

Edit or add a .php-cs-fixer.dist.php in your project root directory

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php

$finder = (new PhpCsFixer\Finder())
    ->in(__DIR__)
    ->exclude([
        'var',
        'config/secrets',
    ])
    ->notPath([
        'config/bundles.php',
    ])
;

return (new PhpCsFixer\Config())
    ->setRiskyAllowed(true)
    ->setFinder($finder)
    ->setRules([
        '@Symfony' => true,
        'array_syntax' => ['syntax' => 'short'],
        'concat_space' => ['spacing' => 'one'],
        'phpdoc_to_comment' => ['ignored_tags' => [
            // https://github.com/phpstan/phpstan/issues/5465
            'use',
        ]],
        'declare_strict_types' => true,
        'native_function_invocation' => ['include' => ['@compiler_optimized']],
        'no_superfluous_phpdoc_tags' => true,
        'ordered_imports' => true,
        'phpdoc_summary' => false,
        'phpdoc_annotation_without_dot' => false,
        'phpdoc_order' => true,
        'single_line_throw' => false,
        'simplified_null_return' => false,
        'yoda_style' => [],
    ])
;

Integration🔗

To enable this with our CI follow this documentation

See Wotol Lint Workflow for a complete reference about PHP linting with Github Actions, including a php-cs-fixer step.


Last update: December 20, 2024