|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +use PhpCsFixer\Config; |
| 6 | +use PhpCsFixer\Finder; |
| 7 | + |
| 8 | +$finder = Finder::create() |
| 9 | + ->in([__DIR__]) |
| 10 | + ->exclude(['vendor']); |
| 11 | + |
| 12 | +return (new Config()) |
| 13 | + ->setRiskyAllowed(true) |
| 14 | + ->setRules([ |
| 15 | + '@PhpCsFixer' => true, |
| 16 | + '@PhpCsFixer:risky' => true, |
| 17 | + '@PHP71Migration' => true, |
| 18 | + '@PHP71Migration:risky' => true, |
| 19 | + |
| 20 | + // required by PSR-12 |
| 21 | + 'concat_space' => [ |
| 22 | + 'spacing' => 'one', |
| 23 | + ], |
| 24 | + |
| 25 | + // disable some too strict rules |
| 26 | + 'phpdoc_types_order' => [ |
| 27 | + 'null_adjustment' => 'always_last', |
| 28 | + 'sort_algorithm' => 'none', |
| 29 | + ], |
| 30 | + 'single_line_throw' => false, |
| 31 | + 'yoda_style' => [ |
| 32 | + 'equal' => false, |
| 33 | + 'identical' => false, |
| 34 | + ], |
| 35 | + 'native_constant_invocation' => true, |
| 36 | + 'native_function_invocation' => false, |
| 37 | + 'void_return' => false, |
| 38 | + 'blank_line_before_statement' => [ |
| 39 | + 'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'exit'], |
| 40 | + ], |
| 41 | + 'final_internal_class' => false, |
| 42 | + 'combine_consecutive_issets' => false, |
| 43 | + 'combine_consecutive_unsets' => false, |
| 44 | + 'multiline_whitespace_before_semicolons' => false, |
| 45 | + 'no_superfluous_elseif' => false, |
| 46 | + 'ordered_class_elements' => false, |
| 47 | + 'php_unit_internal_class' => false, |
| 48 | + 'php_unit_test_class_requires_covers' => false, |
| 49 | + 'phpdoc_add_missing_param_annotation' => false, |
| 50 | + 'return_assignment' => false, |
| 51 | + 'comment_to_phpdoc' => false, |
| 52 | + 'general_phpdoc_annotation_remove' => [ |
| 53 | + 'annotations' => ['author', 'copyright', 'throws'], |
| 54 | + ], |
| 55 | + |
| 56 | + // fn => without curly brackets is less readable, |
| 57 | + // also prevent bounding of unwanted variables for GC |
| 58 | + 'use_arrow_functions' => false, |
| 59 | + |
| 60 | + // TODO disable too strict rules for now - remove once the CS is updated |
| 61 | + 'declare_strict_types' => false, |
| 62 | + 'fully_qualified_strict_types' => false, |
| 63 | + 'general_phpdoc_annotation_remove' => false, |
| 64 | + 'global_namespace_import' => false, |
| 65 | + 'increment_style' => false, |
| 66 | + 'native_constant_invocation' => false, |
| 67 | + 'no_useless_else' => false, |
| 68 | + 'php_unit_data_provider_name' => false, |
| 69 | + 'php_unit_data_provider_return_type' => false, |
| 70 | + 'php_unit_data_provider_static' => false, |
| 71 | + 'php_unit_strict' => false, |
| 72 | + 'php_unit_test_case_static_method_calls' => false, |
| 73 | + 'phpdoc_to_comment' => false, |
| 74 | + 'static_lambda' => false, |
| 75 | + 'strict_comparison' => false, |
| 76 | + ]) |
| 77 | + ->setFinder($finder) |
| 78 | + ->setCacheFile(sys_get_temp_dir() . '/php-cs-fixer.' . md5(__DIR__) . '.cache'); |
0 commit comments