|
2 | 2 |
|
3 | 3 | declare(strict_types=1); |
4 | 4 |
|
5 | | -$finder = PhpCsFixer\Finder::create() |
6 | | - ->in(__DIR__ . '/src') |
7 | | - ->in(__DIR__ . '/tests') |
8 | | - ->name('*.php'); |
| 5 | +/** |
| 6 | + * PHP-CS-Fixer configuration (PSR-12 + Symfony canonical). |
| 7 | + * Standard for Nowo bundles. Run: make cs-check | make cs-fix |
| 8 | + */ |
| 9 | +use PhpCsFixer\Config; |
| 10 | +use PhpCsFixer\Finder; |
| 11 | +use PhpCsFixer\Runner\Parallel\ParallelConfigFactory; |
9 | 12 |
|
10 | | -return (new PhpCsFixer\Config()) |
| 13 | +return (new Config()) |
| 14 | + ->setParallelConfig(ParallelConfigFactory::detect()) |
11 | 15 | ->setRiskyAllowed(true) |
12 | 16 | ->setRules([ |
13 | 17 | '@PSR12' => true, |
14 | | - '@PHP74Migration' => true, |
15 | | - 'array_syntax' => ['syntax' => 'short'], |
16 | | - 'binary_operator_spaces' => true, |
17 | | - 'blank_line_after_opening_tag' => true, |
18 | | - 'blank_line_before_statement' => [ |
19 | | - 'statements' => ['return', 'throw', 'try'], |
| 18 | + '@Symfony' => true, |
| 19 | + '@Symfony:risky' => true, |
| 20 | + 'declare_strict_types' => true, |
| 21 | + 'ordered_imports' => [ |
| 22 | + 'imports_order' => ['class', 'function', 'const'], |
| 23 | + 'sort_algorithm' => 'alpha', |
20 | 24 | ], |
21 | | - 'cast_spaces' => true, |
22 | | - 'class_attributes_separation' => [ |
23 | | - 'elements' => ['method' => 'one'], |
| 25 | + 'single_import_per_statement' => true, |
| 26 | + 'no_unused_imports' => true, |
| 27 | + 'no_leading_import_slash' => true, |
| 28 | + 'single_line_after_imports' => true, |
| 29 | + 'array_syntax' => ['syntax' => 'short'], |
| 30 | + 'trailing_comma_in_multiline' => [ |
| 31 | + 'elements' => ['arguments', 'arrays', 'match'], |
24 | 32 | ], |
25 | 33 | 'concat_space' => ['spacing' => 'one'], |
26 | | - 'declare_strict_types' => true, |
27 | | - 'fully_qualified_strict_types' => true, |
28 | | - 'function_typehint_space' => true, |
29 | | - 'include' => true, |
30 | | - 'lowercase_cast' => true, |
31 | | - 'modernize_types_casting' => true, |
32 | | - 'native_function_casing' => true, |
33 | | - 'new_with_braces' => true, |
34 | | - 'no_blank_lines_after_class_opening' => true, |
35 | | - 'no_blank_lines_after_phpdoc' => true, |
36 | | - 'no_empty_comment' => true, |
37 | | - 'no_empty_phpdoc' => true, |
38 | | - 'no_empty_statement' => true, |
39 | | - 'no_extra_blank_lines' => true, |
40 | | - 'no_leading_import_slash' => true, |
41 | | - 'no_leading_namespace_whitespace' => true, |
42 | | - 'no_mixed_echo_print' => true, |
43 | | - 'no_multiline_whitespace_around_double_arrow' => true, |
44 | | - 'no_null_property_initialization' => true, |
45 | | - 'no_short_bool_cast' => true, |
46 | | - 'no_spaces_around_offset' => true, |
47 | | - 'no_trailing_comma_in_singleline' => true, |
48 | | - 'no_unneeded_control_parentheses' => true, |
49 | | - 'no_unused_imports' => true, |
| 34 | + 'binary_operator_spaces' => [ |
| 35 | + 'default' => 'single_space', |
| 36 | + 'operators' => [ |
| 37 | + '=>' => 'align_single_space_minimal', |
| 38 | + '=' => 'align_single_space_minimal', |
| 39 | + ], |
| 40 | + ], |
| 41 | + 'method_argument_space' => [ |
| 42 | + 'on_multiline' => 'ensure_fully_multiline', |
| 43 | + ], |
| 44 | + 'no_extra_blank_lines' => [ |
| 45 | + 'tokens' => ['extra', 'throw', 'use'], |
| 46 | + ], |
| 47 | + 'no_trailing_whitespace' => true, |
| 48 | + 'no_whitespace_in_blank_line' => true, |
| 49 | + 'single_blank_line_at_eof' => true, |
| 50 | + 'blank_line_after_opening_tag' => true, |
50 | 51 | 'no_useless_else' => true, |
51 | 52 | 'no_useless_return' => true, |
52 | | - 'no_whitespace_before_comma_in_array' => true, |
53 | | - 'no_whitespace_in_blank_line' => true, |
54 | | - 'object_operator_without_whitespace' => true, |
55 | | - 'ordered_imports' => ['sort_algorithm' => 'alpha'], |
56 | | - 'phpdoc_align' => true, |
57 | | - 'phpdoc_indent' => true, |
58 | | - 'phpdoc_no_access' => true, |
59 | | - 'phpdoc_no_package' => true, |
| 53 | + 'simplified_if_return' => true, |
| 54 | + 'single_line_throw' => true, |
| 55 | + 'no_superfluous_elseif' => true, |
| 56 | + 'switch_continue_to_break' => true, |
60 | 57 | 'phpdoc_order' => true, |
61 | | - 'phpdoc_scalar' => true, |
62 | 58 | 'phpdoc_separation' => true, |
63 | 59 | 'phpdoc_single_line_var_spacing' => true, |
64 | 60 | 'phpdoc_trim' => true, |
65 | | - 'phpdoc_types' => true, |
66 | | - 'phpdoc_var_without_name' => true, |
67 | | - 'return_type_declaration' => true, |
68 | | - 'self_accessor' => true, |
69 | | - 'short_scalar_cast' => true, |
70 | | - 'single_quote' => true, |
71 | | - 'space_after_semicolon' => true, |
72 | | - 'standardize_not_equals' => true, |
73 | | - 'ternary_operator_spaces' => true, |
74 | | - 'trailing_comma_in_multiline' => ['elements' => ['arrays']], |
75 | | - 'trim_array_spaces' => true, |
76 | | - 'unary_operator_spaces' => true, |
77 | | - 'whitespace_after_comma_in_array' => true, |
| 61 | + 'phpdoc_trim_consecutive_blank_line_separation' => true, |
| 62 | + 'phpdoc_types_order' => [ |
| 63 | + 'null_adjustment' => 'always_last', |
| 64 | + 'sort_algorithm' => 'alpha', |
| 65 | + ], |
| 66 | + 'no_superfluous_phpdoc_tags' => [ |
| 67 | + 'allow_mixed' => true, |
| 68 | + 'remove_inheritdoc' => false, |
| 69 | + ], |
| 70 | + 'phpdoc_align' => [ |
| 71 | + 'align' => 'left', |
| 72 | + 'tags' => ['param', 'property', 'return', 'throws', 'type', 'var'], |
| 73 | + ], |
| 74 | + 'phpdoc_no_empty_return' => false, |
| 75 | + 'phpdoc_add_missing_param_annotation' => false, |
| 76 | + 'no_null_property_initialization' => true, |
| 77 | + 'single_line_comment_style' => ['comment_types' => ['hash']], |
| 78 | + 'yoda_style' => [ |
| 79 | + 'equal' => false, |
| 80 | + 'identical' => false, |
| 81 | + 'less_and_greater' => false, |
| 82 | + ], |
| 83 | + 'modernize_types_casting' => true, |
| 84 | + 'no_short_bool_cast' => true, |
| 85 | + 'explicit_string_variable' => true, |
| 86 | + 'fully_qualified_strict_types' => true, |
| 87 | + 'global_namespace_import' => [ |
| 88 | + 'import_classes' => true, |
| 89 | + 'import_constants' => true, |
| 90 | + 'import_functions' => true, |
| 91 | + ], |
78 | 92 | ]) |
79 | | - ->setFinder($finder); |
80 | | - |
| 93 | + ->setFinder( |
| 94 | + (new Finder()) |
| 95 | + ->in(__DIR__ . '/src') |
| 96 | + ->in(__DIR__ . '/tests') |
| 97 | + ->exclude(['vendor', 'var', 'coverage', '.phpunit.cache']) |
| 98 | + ->notPath('namespace-stubs.php') |
| 99 | + ->name('*.php') |
| 100 | + ); |
0 commit comments