-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.php_cs.dist
105 lines (96 loc) · 4.33 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
/**
* See the README for a list of rules and explanations
* @see https://github.com/FriendsOfPHP/PHP-CS-Fixer
*/
$finder = PhpCsFixer\Finder::create()
->files()
->in(__DIR__ . '/src')
->in(__DIR__ . '/tests')
->name('*.php');
return PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setRules([
// Include all PSR-2 rules
'@PSR2' => true,
// Agreed standards
'array_syntax' => ['syntax' => 'short'],
'strict_comparison' => true, // @risky
'is_null' => true, // [@Symfony:risky]
'return_type_declaration' => ['space_before' => 'none'], // [@Symfony]
'ordered_imports' => ['sortAlgorithm' => 'alpha'],
'no_unused_imports' => true, // [@Symfony]
'no_trailing_comma_in_singleline_array' => true, // [@Symfony]
'no_singleline_whitespace_before_semicolons' => true, // [@Symfony]
'no_extra_blank_lines' => true, // [@Symfony]
'multiline_whitespace_before_semicolons' => ['strategy' => 'no_multi_line'],
'blank_line_before_statement' => true, // [@Symfony]
'cast_spaces' => true,
// Additional whitespace rules
'ternary_operator_spaces' => true, // [@Symfony]
'trim_array_spaces' => true, // [@Symfony]
'space_after_semicolon' => true, // [@Symfony]
'single_blank_line_before_namespace' => true, // [@Symfony]
'object_operator_without_whitespace' => true, // [@Symfony]
'no_whitespace_before_comma_in_array' => true, // [@Symfony]
'no_multiline_whitespace_around_double_arrow' => true, // [@Symfony]
'no_leading_namespace_whitespace' => true, // [@Symfony]
'no_blank_lines_after_class_opening' => true, // [@Symfony]
'linebreak_after_opening_tag' => true,
'function_typehint_space' => true, // [@Symfony]
'blank_line_after_opening_tag' => true, // [@Symfony]
'no_whitespace_in_blank_line' => true, // [@Symfony]
// Additional useful formatting rules
'ternary_to_null_coalescing' => true, // [@PHP70Migration]
'single_quote' => true, // [@Symfony]
'normalize_index_brace' => true, // [@Symfony]
'no_useless_else' => true,
'no_unneeded_curly_braces' => true, // [@Symfony]
'no_unneeded_control_parentheses' => true, // [@Symfony]
'no_trailing_comma_in_list_call' => true, // [@Symfony]
'no_superfluous_elseif' => true,
'no_short_echo_tag' => true,
'no_leading_import_slash' => true, // [@Symfony]
'no_empty_statement' => true, // [@Symfony]
'new_with_braces' => true, // [@Symfony]
'native_function_casing' => true, // [@Symfony]
'method_chaining_indentation' => true,
'magic_constant_casing' => true, // [@Symfony]
'lowercase_cast' => true, // [@Symfony]
'combine_consecutive_unsets' => true,
'no_unreachable_default_argument_value' => true, // @risky
'ordered_class_elements' => [
'use_trait',
'constant_private',
'constant_protected',
'constant_public',
'property_private', // ID is usually private and should be at the top
'property_protected',
'property_public',
'construct',
'destruct',
'magic',
'phpunit',
'method_public',
'method_protected',
'method_private',
],
// Docblock formatting
'phpdoc_trim' => true, // [@Symfony]
'phpdoc_types' => true, // [@Symfony]
'phpdoc_scalar' => true, // [@Symfony]
'phpdoc_no_useless_inheritdoc' => true, // [@Symfony]
'phpdoc_no_empty_return' => true, // [@Symfony]
'phpdoc_indent' => true, // [@Symfony]
'no_empty_phpdoc' => true, // [@Symfony]
'no_empty_comment' => true, // [@Symfony]
'no_blank_lines_after_phpdoc' => true, // [@Symfony]
'multiline_comment_opening_closing' => true,
'align_multiline_comment' => true,
// Annotation formatting
'doctrine_annotation_spaces' => true, // [@DoctrineAnnotation]
'doctrine_annotation_indentation' => true, // [@DoctrineAnnotation]
'doctrine_annotation_braces' => true, // [@DoctrineAnnotation]
'doctrine_annotation_array_assignment' => true, // [@DoctrineAnnotation]
])
->setFinder($finder);