|
| 1 | +<?php |
| 2 | + |
| 3 | +$header = <<<'EOF' |
| 4 | +@package PHP Prefixer REST API CLI |
| 5 | +
|
| 6 | +@author Desarrollos Inteligentes Virtuales, SL. <team@div.com.es> |
| 7 | +@copyright Copyright (c)2019-2021 Desarrollos Inteligentes Virtuales, SL. All rights reserved. |
| 8 | +@license MIT |
| 9 | +
|
| 10 | +@see https://php-prefixer.com |
| 11 | +EOF; |
| 12 | + |
| 13 | +$finder = PhpCsFixer\Finder::create() |
| 14 | + ->exclude('tests/Fixtures') |
| 15 | + ->in(__DIR__) |
| 16 | +; |
| 17 | + |
| 18 | +$config = PhpCsFixer\Config::create() |
| 19 | + ->setRiskyAllowed(true) |
| 20 | + ->setRules([ |
| 21 | + '@PHP56Migration' => true, |
| 22 | + '@PHPUnit60Migration:risky' => true, |
| 23 | + '@Symfony' => true, |
| 24 | + '@Symfony:risky' => true, |
| 25 | + 'align_multiline_comment' => true, |
| 26 | + 'array_indentation' => true, |
| 27 | + 'array_syntax' => ['syntax' => 'short'], |
| 28 | + 'blank_line_before_statement' => true, |
| 29 | + 'combine_consecutive_issets' => true, |
| 30 | + 'combine_consecutive_unsets' => true, |
| 31 | + 'comment_to_phpdoc' => true, |
| 32 | + 'compact_nullable_typehint' => true, |
| 33 | + 'escape_implicit_backslashes' => true, |
| 34 | + 'explicit_indirect_variable' => true, |
| 35 | + 'explicit_string_variable' => true, |
| 36 | + 'final_internal_class' => true, |
| 37 | + 'fully_qualified_strict_types' => true, |
| 38 | + 'function_to_constant' => ['functions' => ['get_class', 'get_called_class', 'php_sapi_name', 'phpversion', 'pi']], |
| 39 | + 'header_comment' => ['header' => $header], |
| 40 | + 'heredoc_to_nowdoc' => true, |
| 41 | + 'list_syntax' => ['syntax' => 'long'], |
| 42 | + 'method_argument_space' => ['ensure_fully_multiline' => true], |
| 43 | + 'method_chaining_indentation' => true, |
| 44 | + 'multiline_comment_opening_closing' => true, |
| 45 | + 'no_alternative_syntax' => true, |
| 46 | + 'no_extra_blank_lines' => ['tokens' => ['break', 'continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block']], |
| 47 | + 'no_null_property_initialization' => true, |
| 48 | + 'no_short_echo_tag' => true, |
| 49 | + 'no_superfluous_elseif' => true, |
| 50 | + 'no_unneeded_curly_braces' => true, |
| 51 | + 'no_unneeded_final_method' => true, |
| 52 | + 'no_unreachable_default_argument_value' => true, |
| 53 | + 'no_useless_else' => true, |
| 54 | + 'no_useless_return' => true, |
| 55 | + 'ordered_class_elements' => true, |
| 56 | + 'ordered_imports' => 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_class_requires_covers' => true, |
| 62 | + 'phpdoc_add_missing_param_annotation' => true, |
| 63 | + 'phpdoc_order' => true, |
| 64 | + 'phpdoc_types_order' => true, |
| 65 | + 'semicolon_after_instruction' => true, |
| 66 | + 'single_line_comment_style' => true, |
| 67 | + 'strict_comparison' => true, |
| 68 | + 'strict_param' => true, |
| 69 | + 'string_line_ending' => true, |
| 70 | + 'yoda_style' => true, |
| 71 | + ]) |
| 72 | + ->setFinder($finder) |
| 73 | +; |
| 74 | + |
| 75 | +// special handling of fabbot.io service if it's using too old PHP CS Fixer version |
| 76 | +if (false !== getenv('FABBOT_IO')) { |
| 77 | + try { |
| 78 | + PhpCsFixer\FixerFactory::create() |
| 79 | + ->registerBuiltInFixers() |
| 80 | + ->registerCustomFixers($config->getCustomFixers()) |
| 81 | + ->useRuleSet(new PhpCsFixer\RuleSet($config->getRules())); |
| 82 | + } catch (PhpCsFixer\ConfigurationException\InvalidConfigurationException $e) { |
| 83 | + $config->setRules([]); |
| 84 | + } catch (UnexpectedValueException $e) { |
| 85 | + $config->setRules([]); |
| 86 | + } catch (InvalidArgumentException $e) { |
| 87 | + $config->setRules([]); |
| 88 | + } |
| 89 | +} |
| 90 | + |
| 91 | +return $config; |
0 commit comments