|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * Licensed to the Apache Software Foundation (ASF) under one |
| 5 | + * or more contributor license agreements. See the NOTICE file |
| 6 | + * distributed with this work for additional information |
| 7 | + * regarding copyright ownership. The ASF licenses this file |
| 8 | + * to you under the Apache License, Version 2.0 (the |
| 9 | + * "License"); you may not use this file except in compliance |
| 10 | + * with the License. You may obtain a copy of the License at |
| 11 | + * |
| 12 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 13 | + * |
| 14 | + * Unless required by applicable law or agreed to in writing, software |
| 15 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 16 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 | + * See the License for the specific language governing permissions and |
| 18 | + * limitations under the License. |
| 19 | + */ |
| 20 | + |
| 21 | +declare(strict_types=1); |
| 22 | + |
| 23 | +use PhpCsFixer\Runner\Parallel\ParallelConfigFactory; |
| 24 | + |
| 25 | +/** |
| 26 | + * PHP CS Fixer documentation: |
| 27 | + * - Homepage: https://cs.symfony.com/ |
| 28 | + * - List of all available rules: https://cs.symfony.com/doc/rules/index.html |
| 29 | + * - List of all available rule sets: https://cs.symfony.com/doc/ruleSets/index.html |
| 30 | + * |
| 31 | + * To inspect a specific rule (e.g. `blank_line_before_statement`), run: |
| 32 | + * |
| 33 | + * ```console |
| 34 | + * > php-cs-fixer describe blank_line_before_statement |
| 35 | + * ``` |
| 36 | + */ |
| 37 | +$finder = PhpCsFixer\Finder::create() |
| 38 | + ->in(['lib', 'test']) |
| 39 | + ->append(['.php-cs-fixer.dist.php']); |
| 40 | + |
| 41 | +return (new PhpCsFixer\Config()) |
| 42 | + ->setRiskyAllowed(true) |
| 43 | + ->setParallelConfig(ParallelConfigFactory::detect()) |
| 44 | + ->setRules([ |
| 45 | + // —— CS Rule Sets ————————————————————————————————————————————————————— |
| 46 | + '@Symfony' => true, |
| 47 | + '@PHP8x0Migration' => true, |
| 48 | + |
| 49 | + // —— Overriden rules —————————————————————————————————————————————————— |
| 50 | + |
| 51 | + // @Symfony: `['statements' => ['return']]` |
| 52 | + // Here using: default, `['statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try']]` |
| 53 | + 'blank_line_before_statement' => true, |
| 54 | + |
| 55 | + // @Symfony: `['tokens' => [['attribute', 'case', 'continue', 'curly_brace_block', 'default', 'extra', 'parenthesis_brace_block', 'square_brace_block', 'switch', 'throw', 'use']]]` |
| 56 | + // Here using: default, `['tokens' => ['extra']]` |
| 57 | + 'no_extra_blank_lines' => true, |
| 58 | + |
| 59 | + // @Symfony: `['allow_hidden_params' => true, 'remove_inheritdoc' => true]` |
| 60 | + 'no_superfluous_phpdoc_tags' => ['allow_mixed' => true, 'allow_unused_params' => true, 'remove_inheritdoc' => false], |
| 61 | + |
| 62 | + // @Symfony: `['after_heredoc' => true]` |
| 63 | + // Here using: default, `['after_heredoc' => false]` |
| 64 | + 'no_whitespace_before_comma_in_array' => true, |
| 65 | + |
| 66 | + // @Symfony: `['order' => ['use_trait']]` |
| 67 | + // Here using: default, `['order' => ['use_trait', 'case', 'constant_public', 'constant_protected', 'constant_private', 'property_public', 'property_protected', 'property_private', 'construct', 'destruct', 'magic', 'phpunit', 'method_public', 'method_protected', 'method_private']]`) |
| 68 | + 'ordered_class_elements' => true, |
| 69 | + |
| 70 | + // @Symfony: `['imports_order' => ['class', 'function', 'const'], 'sort_algorithm' => 'alpha']` |
| 71 | + // Here using: default, all import types (classes, functions, and constants) are sorted together alphabetically without grouping them by type |
| 72 | + 'ordered_imports' => true, |
| 73 | + |
| 74 | + // @Symfony: `['order' => ['param', 'return', 'throws']]` |
| 75 | + // Here using: default, `['param', 'throws', 'return']` |
| 76 | + 'phpdoc_order' => true, |
| 77 | + |
| 78 | + // @Symfony: `['null_adjustment' => 'always_last', 'sort_algorithm' => 'none']` |
| 79 | + 'phpdoc_types_order' => ['null_adjustment' => 'always_first'], |
| 80 | + |
| 81 | + // @Symfony: `['case' => 'camel_case']` |
| 82 | + 'php_unit_method_casing' => ['case' => 'snake_case'], |
| 83 | + |
| 84 | + // —— Overriden rules (disabled) ———————————————————————————————————————— |
| 85 | + // @Symfony |
| 86 | + 'increment_style' => false, |
| 87 | + 'phpdoc_align' => false, |
| 88 | + 'phpdoc_separation' => false, |
| 89 | + 'phpdoc_summary' => false, |
| 90 | + 'phpdoc_to_comment' => false, |
| 91 | + 'single_line_comment_style' => false, |
| 92 | + 'single_line_throw' => false, |
| 93 | + 'single_quote' => false, |
| 94 | + |
| 95 | + // —— Additional rules —————————————————————————————————————————————————— |
| 96 | + 'no_useless_else' => true, |
| 97 | + 'phpdoc_add_missing_param_annotation' => true, |
| 98 | + 'phpdoc_annotation_without_dot' => false, |
| 99 | + 'protected_to_private' => true, |
| 100 | + 'psr_autoloading' => true, |
| 101 | + ]) |
| 102 | + ->setFinder($finder) |
| 103 | +; |
0 commit comments