|
| 1 | +<?php |
| 2 | +declare(strict_types=1); |
| 3 | + |
| 4 | +use PhpCsFixer\Runner\Parallel\ParallelConfigFactory; |
| 5 | + |
| 6 | +$finder = PhpCsFixer\Finder::create() |
| 7 | + ->in( |
| 8 | + [ |
| 9 | + __DIR__ . '/src', |
| 10 | + __DIR__ . '/tests', |
| 11 | + __DIR__ . '/generated', |
| 12 | + __DIR__ . '/examples', |
| 13 | + ] |
| 14 | + ) |
| 15 | + ->append( |
| 16 | + [ |
| 17 | + __FILE__, |
| 18 | + ] |
| 19 | + ) |
| 20 | + ->notContains([ |
| 21 | + '_generated', |
| 22 | + ]) |
| 23 | +; |
| 24 | +$rules = [ |
| 25 | + /** symfony set @see \PhpCsFixer\RuleSet\Sets\PSR12Set */ |
| 26 | + '@PSR12' => true, |
| 27 | + /** symfony set @see \PhpCsFixer\RuleSet\Sets\SymfonySet */ |
| 28 | + '@Symfony' => true, |
| 29 | + /** symfony set @see \PhpCsFixer\RuleSet\Sets\SymfonyRiskySet */ |
| 30 | + '@Symfony:risky' => true, |
| 31 | + '@PhpCsFixer:risky' => true, |
| 32 | + '@PHP83Migration' => true, |
| 33 | + '@DoctrineAnnotation' => true, |
| 34 | + // OEG Set: |
| 35 | + 'binary_operator_spaces' => [ |
| 36 | + 'default' => 'align', |
| 37 | + 'operators' => [ |
| 38 | + '??' => 'single_space', |
| 39 | + ], |
| 40 | + ], |
| 41 | + 'concat_space' => ['spacing' => 'one'], |
| 42 | + |
| 43 | + 'encoding' => true, |
| 44 | + 'blank_lines_before_namespace' => true, |
| 45 | + 'blank_line_after_opening_tag' => false, // psr 12 = true |
| 46 | + 'strict_param' => true, |
| 47 | + 'no_useless_else' => true, |
| 48 | + 'no_useless_return' => true, |
| 49 | + 'modernize_types_casting' => true, |
| 50 | + 'declare_strict_types' => true, |
| 51 | + 'dir_constant' => true, |
| 52 | + |
| 53 | + 'php_unit_dedicate_assert' => ['target' => 'newest'], |
| 54 | + 'php_unit_test_case_static_method_calls' => ['call_type' => 'this'], |
| 55 | + 'fopen_flags' => false, |
| 56 | + 'combine_nested_dirname' => true, |
| 57 | + |
| 58 | + 'ordered_imports' => [ |
| 59 | + 'imports_order' => [ |
| 60 | + // symfony order: Class Function Const |
| 61 | + // OEG: |
| 62 | + 'const', |
| 63 | + 'class', |
| 64 | + 'function', |
| 65 | + ], |
| 66 | + 'sort_algorithm' => 'alpha', |
| 67 | + ], |
| 68 | + |
| 69 | + 'global_namespace_import' => [ |
| 70 | + 'import_classes' => true, |
| 71 | + 'import_functions' => true, |
| 72 | + 'import_constants' => true, |
| 73 | + ], |
| 74 | + |
| 75 | + // if this is true, phpstan checks will fail |
| 76 | + 'phpdoc_to_comment' => false, |
| 77 | + 'nullable_type_declaration_for_default_null_value' => true, |
| 78 | + 'no_superfluous_phpdoc_tags' => false, // symfony -> true löscht aber mixed return was phpstan aggro macht |
| 79 | + // prevent mega diff |
| 80 | + 'blank_line_between_import_groups' => false, // PSR 12 = true |
| 81 | + |
| 82 | + // new stuff that fails to much: |
| 83 | + 'ordered_types' => [ |
| 84 | + // default symfony "always_last" |
| 85 | + 'null_adjustment' => 'always_first', |
| 86 | + ], |
| 87 | +]; |
| 88 | + |
| 89 | +$config = new PhpCsFixer\Config('webproject-style'); |
| 90 | +$config->setRules($rules); |
| 91 | +$config->setUsingCache(true); |
| 92 | +$config->setLineEnding("\n"); |
| 93 | +$config->setRiskyAllowed(true); |
| 94 | +$config->setParallelConfig(ParallelConfigFactory::detect()); |
| 95 | +$config->setFinder($finder); |
| 96 | + |
| 97 | +return $config; |
0 commit comments