|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * @source https://gist.github.com/codfish/c77d348820c1c6b4ebe4a66dc2291c74 |
| 5 | + * |
| 6 | + * Rules we follow are from PSR-2 as well as the rectified PSR-2 guide. |
| 7 | + * |
| 8 | + * - https://github.com/FriendsOfPHP/PHP-CS-Fixer |
| 9 | + * - https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md |
| 10 | + * - https://github.com/php-fig-rectified/fig-rectified-standards/blob/master/PSR-2-R-coding-style-guide-additions.md |
| 11 | + * |
| 12 | + * If something isn't addressed in either of those, some other common community rules are |
| 13 | + * used that might not be addressed explicitly in PSR-2 in order to improve code quality |
| 14 | + * (so that devs don't need to comment on them in Code Reviews). |
| 15 | + * |
| 16 | + * For instance: removing trailing white space, removing extra line breaks where |
| 17 | + * they're not needed (back to back, beginning or end of function/class, etc.), |
| 18 | + * adding trailing commas in the last line of an array, etc. |
| 19 | + */ |
| 20 | + |
| 21 | +$finder = PhpCsFixer\Finder::create() |
| 22 | + ->exclude('node_modules') |
| 23 | + ->exclude('vendor') |
| 24 | + ->in(__DIR__); |
| 25 | + |
| 26 | +return PhpCsFixer\Config::create() |
| 27 | + ->setRules([ |
| 28 | + '@PSR2' => true, |
| 29 | + 'array_syntax' => [ 'syntax' => 'short' ], |
| 30 | + 'binary_operator_spaces' => [ 'align_equals' => false, 'align_double_arrow' => false ], |
| 31 | + 'cast_spaces' => true, |
| 32 | + 'combine_consecutive_unsets' => true, |
| 33 | + 'concat_space' => [ 'spacing' => 'one' ], |
| 34 | + 'linebreak_after_opening_tag' => true, |
| 35 | + 'no_blank_lines_after_class_opening' => true, |
| 36 | + 'no_blank_lines_after_phpdoc' => true, |
| 37 | + 'no_extra_consecutive_blank_lines' => true, |
| 38 | + 'no_trailing_comma_in_singleline_array' => true, |
| 39 | + 'no_whitespace_in_blank_line' => true, |
| 40 | + 'no_spaces_around_offset' => true, |
| 41 | + 'no_unused_imports' => true, |
| 42 | + 'no_useless_else' => true, |
| 43 | + 'no_useless_return' => true, |
| 44 | + 'no_whitespace_before_comma_in_array' => true, |
| 45 | + 'normalize_index_brace' => true, |
| 46 | + 'phpdoc_indent' => true, |
| 47 | + 'phpdoc_to_comment' => true, |
| 48 | + 'phpdoc_trim' => true, |
| 49 | + 'single_quote' => true, |
| 50 | + 'ternary_to_null_coalescing' => true, |
| 51 | + 'trailing_comma_in_multiline_array' => true, |
| 52 | + 'trim_array_spaces' => true, |
| 53 | + 'method_argument_space' => ['ensure_fully_multiline' => false], |
| 54 | + 'no_break_comment' => false, |
| 55 | + 'blank_line_before_statement' => true, |
| 56 | + ]) |
| 57 | + ->setFinder($finder); |
0 commit comments