Skip to content

Instantly share code, notes, and snippets.

@bubba-h57
Created June 21, 2017 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bubba-h57/3ed8db1969791e8f1adbac9aac538943 to your computer and use it in GitHub Desktop.
Save bubba-h57/3ed8db1969791e8f1adbac9aac538943 to your computer and use it in GitHub Desktop.
My favorite Code Style Rules for php-cs-fixer
<?php
$rules = [
'@PSR2' => true,
// Additional Non-PSR2 rules
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => ['align_double_arrow' => true],
'blank_line_after_opening_tag' => true,
'blank_line_before_return' => true,
'cast_spaces' => true,
'concat_space' => ['spacing' => 'one'],
'function_typehint_space' => true,
'include' => true,
'linebreak_after_opening_tag' => true,
'list_syntax' => ['syntax' => 'short'],
'lowercase_cast' => true,
'method_separation' => true,
'no_blank_lines_after_class_opening' => true,
'no_blank_lines_before_namespace' => true,
'no_empty_statement' => true,
'no_extra_consecutive_blank_lines' => true,
'no_unused_imports' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'no_whitespace_before_comma_in_array' => true,
'no_whitespace_in_blank_line' => true,
'normalize_index_brace' => true,
'not_operator_with_successor_space' => true,
'ordered_class_elements' => true,
'ordered_imports' => ['sortAlgorithm' => 'length'],
'self_accessor' => true,
'short_scalar_cast' => true,
'single_quote' => true,
'ternary_operator_spaces' => true,
];
$finder = PhpCsFixer\Finder::create()->in(__DIR__);
return PhpCsFixer\Config::create()
->setRules($rules)
->setFinder($finder)
->setUsingCache(true)
->setCacheFile(__DIR__.'/.php_cs.cache')
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment