Skip to content

Commit f1be448

Browse files
committed
Improved CS rules
1 parent b4571b5 commit f1be448

File tree

115 files changed

+2318
-2346
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+2318
-2346
lines changed

.php_cs

Lines changed: 194 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,173 @@
11
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->files()
5+
->in([
6+
__DIR__ . '/src',
7+
__DIR__ . '/tests',
8+
]);
9+
10+
if (!\file_exists(__DIR__ . '/var')) {
11+
\mkdir(__DIR__ . '/var');
12+
}
13+
214
return PhpCsFixer\Config::create()
15+
->setRiskyAllowed(true)
16+
->setCacheFile(__DIR__.'/var/.php_cs.cache')
317
->setRules([
4-
'@PSR2' => true,
5-
'declare_strict_types' => true,
18+
'align_multiline_comment' => true,
19+
'array_indentation' => true,
620
'array_syntax' => ['syntax' => 'short'],
7-
'blank_line_after_opening_tag' => true,
8-
'single_blank_line_before_namespace' => true,
9-
'no_unused_imports' => true,
10-
'single_quote' => true,
11-
'native_function_casing' => false,
12-
'native_function_invocation' => false,
13-
'single_import_per_statement' => true,
14-
'single_line_after_imports' => true,
1521
'blank_line_after_namespace' => true,
16-
'no_extra_blank_lines' => true,
17-
22+
'blank_line_before_statement' => [
23+
'statements' => [
24+
'break',
25+
'continue',
26+
'declare',
27+
'default',
28+
'die',
29+
'do',
30+
'exit',
31+
'for',
32+
'foreach',
33+
'goto',
34+
'if',
35+
'include',
36+
'include_once',
37+
'require',
38+
'require_once',
39+
'return',
40+
'switch',
41+
'throw',
42+
'try',
43+
'while',
44+
],
45+
],
46+
'braces' => true,
47+
'cast_spaces' => true,
48+
'class_attributes_separation' => ['elements' => ['const', 'method', 'property']],
49+
'combine_consecutive_issets' => true,
50+
'combine_consecutive_unsets' => true,
51+
'compact_nullable_typehint' => true,
52+
'concat_space' => ['spacing' => 'one'],
53+
'constant_case' => true,
54+
'declare_equal_normalize' => ['space' => 'none'],
55+
'declare_strict_types' => true,
56+
'dir_constant' => true,
57+
'elseif' => true,
58+
'encoding' => true,
59+
'explicit_indirect_variable' => true,
60+
'explicit_string_variable' => true,
61+
'full_opening_tag' => true,
62+
'fully_qualified_strict_types' => true,
63+
'function_typehint_space' => true,
64+
'function_declaration' => true,
1865
'global_namespace_import' => [
19-
'import_classes' => true,
20-
'import_constants' => true,
21-
'import_functions' => true,
66+
'import_classes' => false,
67+
'import_constants' => false,
68+
'import_functions' => false,
69+
],
70+
'heredoc_to_nowdoc' => true,
71+
'increment_style' => [
72+
'style' => PhpCsFixer\Fixer\Operator\IncrementStyleFixer::STYLE_POST,
73+
],
74+
'indentation_type' => true,
75+
'is_null' => true,
76+
'line_ending' => true,
77+
'list_syntax' => ['syntax' => 'short'],
78+
'logical_operators' => true,
79+
'lowercase_keywords' => true,
80+
'lowercase_static_reference' => true,
81+
'magic_constant_casing' => true,
82+
'magic_method_casing' => true,
83+
'method_argument_space' => ['ensure_fully_multiline' => true],
84+
'modernize_types_casting' => true,
85+
'multiline_comment_opening_closing' => true,
86+
'multiline_whitespace_before_semicolons' => true,
87+
'native_constant_invocation' => false,
88+
'native_function_casing' => false,
89+
'native_function_invocation' => true,
90+
'native_function_type_declaration_casing' => true,
91+
'new_with_braces' => false,
92+
'no_alias_functions' => true,
93+
'no_alternative_syntax' => true,
94+
'no_blank_lines_after_class_opening' => true,
95+
'no_blank_lines_after_phpdoc' => true,
96+
'no_blank_lines_before_namespace' => false,
97+
'no_closing_tag' => true,
98+
'no_empty_comment' => true,
99+
'no_empty_phpdoc' => true,
100+
'no_empty_statement' => true,
101+
'no_extra_blank_lines' => true,
102+
'no_homoglyph_names' => true,
103+
'no_leading_import_slash' => true,
104+
'no_leading_namespace_whitespace' => true,
105+
'no_mixed_echo_print' => ['use' => 'print'],
106+
'no_multiline_whitespace_around_double_arrow' => true,
107+
'no_null_property_initialization' => true,
108+
'no_php4_constructor' => true,
109+
'no_short_bool_cast' => true,
110+
'no_short_echo_tag' => true,
111+
'no_singleline_whitespace_before_semicolons' => true,
112+
'no_spaces_after_function_name' => true,
113+
'no_spaces_around_offset' => true,
114+
'no_spaces_inside_parenthesis' => true,
115+
'no_superfluous_elseif' => true,
116+
'no_superfluous_phpdoc_tags' => false,
117+
'no_trailing_comma_in_list_call' => true,
118+
'no_trailing_comma_in_singleline_array' => true,
119+
'no_trailing_whitespace' => true,
120+
'no_trailing_whitespace_in_comment' => true,
121+
'no_unneeded_control_parentheses' => true,
122+
'no_unneeded_curly_braces' => true,
123+
'no_unneeded_final_method' => true,
124+
'no_unreachable_default_argument_value' => true,
125+
'no_unset_on_property' => true,
126+
'no_unused_imports' => true,
127+
'no_useless_else' => true,
128+
'no_useless_return' => true,
129+
'no_whitespace_before_comma_in_array' => true,
130+
'no_whitespace_in_blank_line' => true,
131+
'non_printable_character' => true,
132+
'normalize_index_brace' => true,
133+
'object_operator_without_whitespace' => true,
134+
'ordered_class_elements' => [
135+
'order' => [
136+
'use_trait',
137+
'constant_public',
138+
'constant_protected',
139+
'constant_private',
140+
'property_public_static',
141+
'property_protected_static',
142+
'property_private_static',
143+
'property_public',
144+
'property_protected',
145+
'property_private',
146+
'construct',
147+
'method_public_static',
148+
'destruct',
149+
'magic',
150+
'phpunit',
151+
'method_public',
152+
'method_protected',
153+
'method_private',
154+
'method_protected_static',
155+
'method_private_static',
156+
],
157+
],
158+
'ordered_imports' => [
159+
'imports_order' => [
160+
PhpCsFixer\Fixer\Import\OrderedImportsFixer::IMPORT_TYPE_CONST,
161+
PhpCsFixer\Fixer\Import\OrderedImportsFixer::IMPORT_TYPE_FUNCTION,
162+
PhpCsFixer\Fixer\Import\OrderedImportsFixer::IMPORT_TYPE_CLASS,
163+
]
164+
],
165+
'ordered_interfaces' => [
166+
'direction' => 'ascend',
167+
'order' => 'alpha',
22168
],
23-
24169
'phpdoc_add_missing_param_annotation' => false,
25-
'phpdoc_align' => true,
170+
'phpdoc_align' => ['align' => 'left'],
26171
'phpdoc_annotation_without_dot' => true,
27172
'phpdoc_indent' => true,
28173
'phpdoc_no_access' => true,
@@ -34,23 +179,41 @@ return PhpCsFixer\Config::create()
34179
'phpdoc_separation' => true,
35180
'phpdoc_single_line_var_spacing' => true,
36181
'phpdoc_summary' => true,
37-
'phpdoc_to_comment' => true,
182+
'phpdoc_to_comment' => false,
38183
'phpdoc_trim' => true,
39184
'phpdoc_trim_consecutive_blank_line_separation' => true,
40185
'phpdoc_types' => ['groups' => ['simple', 'meta']],
41186
'phpdoc_types_order' => true,
42187
'phpdoc_var_without_name' => true,
43-
'phpdoc_line_span' => true,
44-
45-
'fully_qualified_strict_types' => true,
46-
'no_spaces_after_function_name' => true,
47-
'method_separation' => true,
48-
49-
'class_attributes_separation' => ['elements' => ['const', 'method', 'property']]
188+
'pow_to_exponentiation' => true,
189+
'protected_to_private' => true,
190+
'return_assignment' => true,
191+
'return_type_declaration' => ['space_before' => 'one'],
192+
'self_accessor' => true,
193+
'self_static_accessor' => true,
194+
'semicolon_after_instruction' => true,
195+
'set_type_to_cast' => true,
196+
'short_scalar_cast' => true,
197+
'simple_to_complex_string_variable' => true,
198+
'simplified_null_return' => false,
199+
'single_blank_line_at_eof' => true,
200+
'single_import_per_statement' => true,
201+
'single_line_after_imports' => true,
202+
'single_quote' => true,
203+
'standardize_not_equals' => true,
204+
'strict_param' => true,
205+
'ternary_to_null_coalescing' => true,
206+
'trailing_comma_in_multiline_array' => true,
207+
'trim_array_spaces' => true,
208+
'unary_operator_spaces' => true,
209+
'visibility_required' => [
210+
'elements' => [
211+
'const',
212+
'method',
213+
'property',
214+
],
215+
],
216+
'void_return' => true,
217+
'whitespace_after_comma_in_array' => true,
50218
])
51-
->setFinder(
52-
PhpCsFixer\Finder::create()
53-
->in(__DIR__ . '/src')
54-
->in(__DIR__ . '/tests')
55-
)->setRiskyAllowed(true)
56-
->setUsingCache(false);
219+
->setFinder($finder);

src/AST/Expander.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
namespace Coduo\PHPMatcher\AST;
66

7-
use function count;
8-
97
final class Expander implements Node
108
{
119
/**
@@ -29,14 +27,14 @@ public function getName() : string
2927
return $this->name;
3028
}
3129

32-
public function addArgument($argument): void
30+
public function addArgument($argument) : void
3331
{
3432
$this->arguments[] = $argument;
3533
}
3634

3735
public function hasArguments() : bool
3836
{
39-
return (boolean) count($this->arguments);
37+
return (bool) \count($this->arguments);
4038
}
4139

4240
public function getArguments() : array

src/AST/Pattern.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
namespace Coduo\PHPMatcher\AST;
66

7-
use function count;
8-
97
final class Pattern implements Node
108
{
119
/**
@@ -31,7 +29,7 @@ public function getType() : Type
3129

3230
public function hasExpanders() : bool
3331
{
34-
return (boolean) count($this->expanders);
32+
return (bool) \count($this->expanders);
3533
}
3634

3735
/**
@@ -42,7 +40,7 @@ public function getExpanders() : array
4240
return $this->expanders;
4341
}
4442

45-
public function addExpander(Expander $expander): void
43+
public function addExpander(Expander $expander) : void
4644
{
4745
$this->expanders[] = $expander;
4846
}

src/Backtrace.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
interface Backtrace
88
{
9+
public function __toString() : string;
10+
911
public function matcherCanMatch(string $name, $value, bool $result) : void;
1012

1113
public function matcherEntrance(string $name, $value, $pattern) : void;
@@ -22,7 +24,5 @@ public function expanderFailed(string $name, $value, string $error) : void;
2224

2325
public function isEmpty() : bool;
2426

25-
public function __toString() : string;
26-
2727
public function raw() : array;
2828
}

0 commit comments

Comments
 (0)