|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +use PhpCsFixer\Config; |
| 6 | +use PhpCsFixer\Runner\Parallel\ParallelConfigFactory; |
| 7 | +use PhpCsFixer\Finder; |
| 8 | + |
| 9 | +if (PHP_SAPI !== 'cli') { |
| 10 | + die('This script supports command line usage only. Please check your command.'); |
| 11 | +} |
| 12 | + |
| 13 | +return new Config() |
| 14 | + ->setParallelConfig(ParallelConfigFactory::detect()) |
| 15 | + ->setCacheFile(__DIR__ . '/.php-cs-fixer.cache.php') |
| 16 | + ->setFinder( |
| 17 | + new Finder() |
| 18 | + ->ignoreVCSIgnored(true) |
| 19 | + ->in(realpath(__DIR__ . '/src')) |
| 20 | + ) |
| 21 | + ->setRiskyAllowed(true) |
| 22 | + ->setRules([ |
| 23 | + '@DoctrineAnnotation' => true, |
| 24 | + // @todo: Switch to @PER-CS2x0 once php-cs-fixer's todo list is done: https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7247 |
| 25 | + '@PER-CS1x0' => true, |
| 26 | + 'array_indentation' => true, |
| 27 | + 'array_syntax' => ['syntax' => 'short'], |
| 28 | + 'cast_spaces' => ['space' => 'none'], |
| 29 | + // @todo: Can be dropped once we enable @PER-CS2x0 |
| 30 | + 'concat_space' => ['spacing' => 'one'], |
| 31 | + 'declare_equal_normalize' => ['space' => 'none'], |
| 32 | + 'declare_parentheses' => true, |
| 33 | + 'dir_constant' => true, |
| 34 | + // @todo: Can be dropped once we enable @PER-CS2x0 |
| 35 | + 'function_declaration' => [ |
| 36 | + 'closure_fn_spacing' => 'none', |
| 37 | + ], |
| 38 | + 'function_to_constant' => ['functions' => ['get_called_class', 'get_class', 'get_class_this', 'php_sapi_name', 'phpversion', 'pi']], |
| 39 | + 'type_declaration_spaces' => true, |
| 40 | + 'global_namespace_import' => ['import_classes' => false, 'import_constants' => false, 'import_functions' => false], |
| 41 | + 'list_syntax' => ['syntax' => 'short'], |
| 42 | + // @todo: Can be dropped once we enable @PER-CS2x0 |
| 43 | + 'method_argument_space' => true, |
| 44 | + 'modernize_strpos' => true, |
| 45 | + 'modernize_types_casting' => true, |
| 46 | + 'native_function_casing' => true, |
| 47 | + 'no_alias_functions' => true, |
| 48 | + 'no_blank_lines_after_phpdoc' => true, |
| 49 | + 'no_empty_phpdoc' => true, |
| 50 | + 'no_empty_statement' => true, |
| 51 | + 'no_extra_blank_lines' => true, |
| 52 | + 'no_leading_namespace_whitespace' => true, |
| 53 | + 'no_null_property_initialization' => true, |
| 54 | + 'no_short_bool_cast' => true, |
| 55 | + 'no_singleline_whitespace_before_semicolons' => true, |
| 56 | + 'no_superfluous_elseif' => true, |
| 57 | + 'no_trailing_comma_in_singleline' => true, |
| 58 | + 'no_unneeded_control_parentheses' => true, |
| 59 | + 'no_unused_imports' => true, |
| 60 | + 'no_useless_else' => true, |
| 61 | + 'no_useless_nullsafe_operator' => true, |
| 62 | + 'nullable_type_declaration' => [ |
| 63 | + 'syntax' => 'question_mark', |
| 64 | + ], |
| 65 | + 'nullable_type_declaration_for_default_null_value' => true, |
| 66 | + 'ordered_class_elements' => ['order' => ['use_trait', 'case', 'constant', 'property']], |
| 67 | + 'ordered_imports' => ['imports_order' => ['class', 'function', 'const'], 'sort_algorithm' => 'alpha'], |
| 68 | + 'php_unit_construct' => ['assertions' => ['assertEquals', 'assertSame', 'assertNotEquals', 'assertNotSame']], |
| 69 | + 'php_unit_mock_short_will_return' => true, |
| 70 | + 'php_unit_test_case_static_method_calls' => ['call_type' => 'self', |
| 71 | + 'methods' => [ |
| 72 | + 'any' => 'this', |
| 73 | + 'atLeast' => 'this', |
| 74 | + 'atLeastOnce' => 'this', |
| 75 | + 'atMost' => 'this', |
| 76 | + 'exactly' => 'this', |
| 77 | + 'never' => 'this', |
| 78 | + 'onConsecutiveCalls' => 'this', |
| 79 | + 'once' => 'this', |
| 80 | + 'returnArgument' => 'this', |
| 81 | + 'returnCallback' => 'this', |
| 82 | + 'returnSelf' => 'this', |
| 83 | + 'returnValue' => 'this', |
| 84 | + 'returnValueMap' => 'this', |
| 85 | + 'throwException' => 'this', |
| 86 | + ], |
| 87 | + ], |
| 88 | + 'phpdoc_no_access' => true, |
| 89 | + 'phpdoc_no_empty_return' => true, |
| 90 | + 'phpdoc_no_package' => true, |
| 91 | + 'phpdoc_scalar' => true, |
| 92 | + 'phpdoc_trim' => true, |
| 93 | + 'phpdoc_types' => true, |
| 94 | + 'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'], |
| 95 | + 'return_type_declaration' => ['space_before' => 'none'], |
| 96 | + 'single_quote' => true, |
| 97 | + 'single_space_around_construct' => true, |
| 98 | + 'single_line_comment_style' => ['comment_types' => ['hash']], |
| 99 | + // @todo: Can be dropped once we enable @PER-CS2x0 |
| 100 | + 'single_line_empty_body' => true, |
| 101 | + 'trailing_comma_in_multiline' => ['elements' => ['arrays']], |
| 102 | + 'whitespace_after_comma_in_array' => ['ensure_single_space' => true], |
| 103 | + 'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false], |
| 104 | + ]); |
0 commit comments