|
| 1 | +<?php |
| 2 | + |
| 3 | +$finder = PhpCsFixer\Finder::create() |
| 4 | + ->exclude('tests/Fixtures') |
| 5 | + ->in(__DIR__) |
| 6 | +; |
| 7 | +$config = PhpCsFixer\Config::create() |
| 8 | + ->setRiskyAllowed(true) |
| 9 | + ->setRules([ |
| 10 | + '@PHP56Migration' => true, |
| 11 | + '@PHPUnit60Migration:risky' => true, |
| 12 | + '@PSR1' => true, |
| 13 | + '@PSR2' => true, |
| 14 | + '@Symfony' => true, |
| 15 | + '@Symfony:risky' => true, |
| 16 | + 'align_multiline_comment' => true, |
| 17 | + 'array_indentation' => true, |
| 18 | + 'array_syntax' => ['syntax' => 'short'], |
| 19 | + 'blank_line_before_statement' => true, |
| 20 | + 'binary_operator_spaces' => [ |
| 21 | + 'align_double_arrow' => true, |
| 22 | + 'align_equals' => false, |
| 23 | + ], |
| 24 | + 'combine_consecutive_issets' => true, |
| 25 | + 'combine_consecutive_unsets' => true, |
| 26 | + 'comment_to_phpdoc' => true, |
| 27 | + 'compact_nullable_typehint' => true, |
| 28 | + 'concat_space' => ['spacing' => 'one'], |
| 29 | + 'escape_implicit_backslashes' => true, |
| 30 | + 'explicit_indirect_variable' => true, |
| 31 | + 'explicit_string_variable' => true, |
| 32 | + 'final_internal_class' => true, |
| 33 | + 'fully_qualified_strict_types' => true, |
| 34 | + 'function_to_constant' => ['functions' => ['get_class', 'get_called_class', 'php_sapi_name', 'phpversion', 'pi']], |
| 35 | + 'heredoc_to_nowdoc' => true, |
| 36 | + 'increment_style' => false, |
| 37 | + 'list_syntax' => ['syntax' => 'long'], |
| 38 | + 'logical_operators' => true, |
| 39 | + 'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'], |
| 40 | + 'method_chaining_indentation' => true, |
| 41 | + 'multiline_comment_opening_closing' => true, |
| 42 | + 'no_alternative_syntax' => true, |
| 43 | + 'no_binary_string' => true, |
| 44 | + 'no_extra_blank_lines' => ['tokens' => ['break', 'continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block']], |
| 45 | + 'no_null_property_initialization' => true, |
| 46 | + 'no_short_echo_tag' => true, |
| 47 | + 'no_superfluous_elseif' => true, |
| 48 | + 'no_unneeded_curly_braces' => true, |
| 49 | + 'no_unneeded_final_method' => true, |
| 50 | + 'no_unreachable_default_argument_value' => true, |
| 51 | + 'no_unset_on_property' => true, |
| 52 | + 'no_useless_else' => true, |
| 53 | + 'no_useless_return' => true, |
| 54 | + 'ordered_class_elements' => true, |
| 55 | + 'ordered_imports' => true, |
| 56 | + 'php_unit_internal_class' => true, |
| 57 | + 'php_unit_ordered_covers' => true, |
| 58 | + 'php_unit_set_up_tear_down_visibility' => true, |
| 59 | + 'php_unit_strict' => true, |
| 60 | + 'php_unit_test_annotation' => true, |
| 61 | + 'php_unit_test_case_static_method_calls' => ['call_type' => 'this'], |
| 62 | + 'php_unit_test_class_requires_covers' => true, |
| 63 | + 'phpdoc_add_missing_param_annotation' => true, |
| 64 | + 'phpdoc_order' => true, |
| 65 | + 'phpdoc_trim_consecutive_blank_line_separation' => true, |
| 66 | + 'phpdoc_types_order' => true, |
| 67 | + 'return_assignment' => true, |
| 68 | + 'semicolon_after_instruction' => true, |
| 69 | + 'single_line_comment_style' => true, |
| 70 | + 'strict_comparison' => true, |
| 71 | + 'strict_param' => true, |
| 72 | + 'string_line_ending' => true, |
| 73 | + 'ternary_operator_spaces' => true, |
| 74 | + 'trim_array_spaces' => true, |
| 75 | + 'unary_operator_spaces' => true, |
| 76 | + 'yoda_style' => true, |
| 77 | + 'whitespace_after_comma_in_array' => true, |
| 78 | + ]) |
| 79 | + ->setFinder($finder) |
| 80 | +; |
| 81 | +// special handling of fabbot.io service if it's using too old PHP CS Fixer version |
| 82 | +if (false !== getenv('FABBOT_IO')) { |
| 83 | + try { |
| 84 | + PhpCsFixer\FixerFactory::create() |
| 85 | + ->registerBuiltInFixers() |
| 86 | + ->registerCustomFixers($config->getCustomFixers()) |
| 87 | + ->useRuleSet(new PhpCsFixer\RuleSet($config->getRules())); |
| 88 | + } catch (PhpCsFixer\ConfigurationException\InvalidConfigurationException $e) { |
| 89 | + $config->setRules([]); |
| 90 | + } catch (UnexpectedValueException $e) { |
| 91 | + $config->setRules([]); |
| 92 | + } catch (InvalidArgumentException $e) { |
| 93 | + $config->setRules([]); |
| 94 | + } |
| 95 | +} |
| 96 | +return $config; |
0 commit comments