Skip to content

Instantly share code, notes, and snippets.

@dinhquochan
Last active November 12, 2023 10:44
Show Gist options
  • Save dinhquochan/f156c7ea15b10fb3e2ee42dc2b26d187 to your computer and use it in GitHub Desktop.
Save dinhquochan/f156c7ea15b10fb3e2ee42dc2b26d187 to your computer and use it in GitHub Desktop.
PHP CS Fixer (PSR-12) - Laravel Compatible
<?php
$finder = PhpCsFixer\Finder::create()
->notPath('storage/*')
->name('*.php')
->notName('*.blade.php')
->ignoreDotFiles(true)
->ignoreVCS(true)
;
$config = new PhpCsFixer\Config();
return $config->setRules([
'@PSR12' => true,
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => [
'default' => 'single_space',
'operators' => [
'=' => null,
],
],
'blank_line_before_statement' => [
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'],
],
'concat_space' => [
'spacing' => 'one',
],
'function_typehint_space' => true,
'native_function_casing' => true,
'no_extra_blank_lines' => true,
'no_leading_namespace_whitespace' => true,
'no_spaces_around_offset' => true,
'no_unused_imports' => true,
'not_operator_with_successor_space' => true,
'object_operator_without_whitespace' => true,
'single_quote' => true,
'trailing_comma_in_multiline' => true,
'unary_operator_spaces' => true,
'whitespace_after_comma_in_array' => true,
])
->setFinder($finder)
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment