Skip to content

Instantly share code, notes, and snippets.

@mknparreira
Last active August 12, 2021 22:24
Show Gist options
  • Save mknparreira/9fc6f8538b26c96b2c2bd968260e8462 to your computer and use it in GitHub Desktop.
Save mknparreira/9fc6f8538b26c96b2c2bd968260e8462 to your computer and use it in GitHub Desktop.
PHP | PHP CS Fixer .php_cs file
$excluded_folders = [
    'bootstrap',
    'config',
    'database',
    'node_modules',
    'public',
    'resources',
    'storage',
    'vendor'
];

$rules = [
    '@PSR1' => true,
    '@PSR2' => true,
    '@PhpCsFixer' => true,
    '@Symfony' => true,
    'array_indentation' => true,
    'array_syntax' => ['syntax' => 'short'],
    'binary_operator_spaces' => ['align_equals' => true],
    'linebreak_after_opening_tag' => true,
    'not_operator_with_successor_space' => true,
    'no_superfluous_phpdoc_tags' => false,
    'no_short_echo_tag' => true,
    'no_multiline_whitespace_before_semicolons' => true,
    'no_unused_imports' => true,
    'ordered_imports' => true,
    'phpdoc_order' => true,
];

$finder = PhpCsFixer\Finder::create()
    ->exclude($excluded_folders)
    ->notName('AcceptanceTester.php')
    ->notName('FunctionalTester.php')
    ->notName('UnitTester.php')
    ->notName('README.md')
    ->notName('*.xml')
    ->notName('*.yml')
    ->in(__DIR__)
;

return PhpCsFixer\Config::create()
    ->setUsingCache(false)
    ->setRules($rules)
    ->setFinder($finder)
;
@mknparreira
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment