-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathphp_cs.dist
72 lines (68 loc) · 2.66 KB
/
php_cs.dist
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
/**
* Rules we follow are from PSR-12.
*
* - https://github.com/FriendsOfPHP/PHP-CS-Fixer
* - https://www.php-fig.org/psr/psr-12/
* - https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-12-extended-coding-style-guide.md
*
* If something isn't addressed in either of those, some other common community rules are
* used that might not be addressed explicitly in PSR-12 in order to improve code quality
* (so that devs don't need to comment on them in Code Reviews).
*
* For instance: removing trailing white space, removing extra line breaks where
* they're not needed (back to back, beginning or end of function/class, etc.),
* adding trailing commas in the last line of an array, etc.
*/
use PhpCsFixer\Fixer\Basic\BracesFixer;
use PhpCsFixer\Fixer\Import\OrderedImportsFixer;
$finder = PhpCsFixer\Finder::create()
->exclude('vendor')
->in(__DIR__);
return (new PhpCsFixer\Config())
->setRules([
'@PSR2' => true,
'binary_operator_spaces' => true,
'blank_line_after_opening_tag' => true,
'braces' => [
'allow_single_line_closure' => false,
'position_after_anonymous_constructs' => BracesFixer::LINE_SAME,
'position_after_control_structures' => BracesFixer::LINE_SAME,
'position_after_functions_and_oop_constructs' => BracesFixer::LINE_NEXT,
],
'concat_space' => ['spacing' => 'one'],
'declare_equal_normalize' => [
'space' => 'none'
],
'lowercase_cast' => true,
'new_with_braces' => true,
'no_blank_lines_after_class_opening' => true,
'no_extra_blank_lines' => false,
'no_leading_import_slash' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_trailing_whitespace' => true,
'no_whitespace_before_comma_in_array' => true,
'ordered_class_elements' => [
'order' => ['use_trait']
],
'ordered_imports' => [
'imports_order' => [
OrderedImportsFixer::IMPORT_TYPE_CLASS,
OrderedImportsFixer::IMPORT_TYPE_CONST,
OrderedImportsFixer::IMPORT_TYPE_FUNCTION,
]
],
'return_type_declaration' => true,
'short_scalar_cast' => true,
'single_import_per_statement' => false,
'space_after_semicolon' => [
'remove_in_empty_for_expressions' => true,
],
'ternary_operator_spaces' => true,
'unary_operator_spaces' => true,
'visibility_required' => [
'elements' => ['const', 'method', 'property']
],
'whitespace_after_comma_in_array' => true,
])
->setFinder($finder);