|
| 1 | +<?php |
| 2 | + |
| 3 | +$header = <<<EOF |
| 4 | +This file is part of Composer. |
| 5 | +
|
| 6 | +(c) Nils Adermann <naderman@naderman.de> |
| 7 | + Jordi Boggiano <j.boggiano@seld.be> |
| 8 | +
|
| 9 | +For the full copyright and license information, please view the LICENSE |
| 10 | +file that was distributed with this source code. |
| 11 | +EOF; |
| 12 | + |
| 13 | +$finder = PhpCsFixer\Finder::create() |
| 14 | + ->files() |
| 15 | + ->in(__DIR__.'/src') |
| 16 | + ->in(__DIR__.'/tests') |
| 17 | + ->name('*.php') |
| 18 | + ->notPath('Fixtures') |
| 19 | +; |
| 20 | + |
| 21 | +$config = new PhpCsFixer\Config(); |
| 22 | +return $config |
| 23 | + ->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect()) |
| 24 | + ->setRules([ |
| 25 | + '@PSR2' => true, |
| 26 | + 'binary_operator_spaces' => true, |
| 27 | + 'blank_line_before_statement' => ['statements' => ['declare', 'return']], |
| 28 | + 'cast_spaces' => ['space' => 'single'], |
| 29 | + 'header_comment' => ['header' => $header], |
| 30 | + 'statement_indentation' => ['stick_comment_to_next_continuous_control_statement' => true], |
| 31 | + 'include' => true, |
| 32 | + |
| 33 | + 'class_attributes_separation' => ['elements' => ['method' => 'one', 'trait_import' => 'none']], |
| 34 | + 'no_blank_lines_after_class_opening' => true, |
| 35 | + 'no_blank_lines_after_phpdoc' => true, |
| 36 | + 'no_empty_statement' => true, |
| 37 | + 'no_extra_blank_lines' => true, |
| 38 | + 'no_leading_namespace_whitespace' => true, |
| 39 | + 'no_trailing_comma_in_singleline' => true, |
| 40 | + 'no_whitespace_in_blank_line' => true, |
| 41 | + 'object_operator_without_whitespace' => true, |
| 42 | + //'phpdoc_align' => true, |
| 43 | + 'phpdoc_indent' => true, |
| 44 | + 'no_empty_comment' => true, |
| 45 | + 'no_empty_phpdoc' => true, |
| 46 | + 'phpdoc_no_access' => true, |
| 47 | + 'phpdoc_no_package' => true, |
| 48 | + //'phpdoc_order' => true, |
| 49 | + 'phpdoc_scalar' => true, |
| 50 | + 'phpdoc_trim' => true, |
| 51 | + 'phpdoc_types' => true, |
| 52 | + 'psr_autoloading' => true, |
| 53 | + 'blank_lines_before_namespace' => true, |
| 54 | + 'standardize_not_equals' => true, |
| 55 | + 'ternary_operator_spaces' => true, |
| 56 | + 'trailing_comma_in_multiline' => ['elements' => ['arrays']], |
| 57 | + 'unary_operator_spaces' => true, |
| 58 | + |
| 59 | + 'native_function_invocation' => [ |
| 60 | + 'include' => ['@compiler_optimized'], // Targets functions with special Zend opcodes (e.g., strlen, count) |
| 61 | + 'scope' => 'namespaced', // Only fixes functions inside a namespace |
| 62 | + 'strict' => true, // Removes leading \ if not native |
| 63 | + ], |
| 64 | + |
| 65 | + // imports |
| 66 | + 'no_unused_imports' => true, |
| 67 | + 'fully_qualified_strict_types' => true, |
| 68 | + 'single_line_after_imports' => true, |
| 69 | + //'global_namespace_import' => ['import_classes' => true], |
| 70 | + 'no_leading_import_slash' => true, |
| 71 | + 'single_import_per_statement' => true, |
| 72 | + |
| 73 | + // PHP 7.2 migration |
| 74 | + 'array_syntax' => true, |
| 75 | + 'list_syntax' => true, |
| 76 | + 'regular_callable_call' => true, |
| 77 | + 'static_lambda' => true, |
| 78 | + 'nullable_type_declaration_for_default_null_value' => true, |
| 79 | + 'explicit_indirect_variable' => true, |
| 80 | + 'visibility_required' => ['elements' => ['property', 'method', 'const']], |
| 81 | + 'non_printable_character' => true, |
| 82 | + 'combine_nested_dirname' => true, |
| 83 | + 'random_api_migration' => true, |
| 84 | + 'ternary_to_null_coalescing' => true, |
| 85 | + 'phpdoc_to_param_type' => false, |
| 86 | + 'declare_strict_types' => true, |
| 87 | + 'no_superfluous_phpdoc_tags' => [ |
| 88 | + 'allow_mixed' => true, |
| 89 | + ], |
| 90 | + |
| 91 | + // TODO php 7.4 migration (one day..) |
| 92 | + // 'phpdoc_to_property_type' => true, |
| 93 | + ]) |
| 94 | + ->setUsingCache(true) |
| 95 | + ->setRiskyAllowed(true) |
| 96 | + ->setFinder($finder) |
| 97 | +; |
0 commit comments