Created
January 11, 2018 10:51
-
-
Save erdemkeren/b9ac2e1def0a13342812c79f4053ec4b to your computer and use it in GitHub Desktop.
Laravel + Fab Cs Fixer Rules sync with StyleCI.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$header = <<<'EOF' | |
This file is part of GSS GoHub Software. | |
(c) Gözen Systems, 2018. | |
EOF; | |
$config = PhpCsFixer\Config::create() | |
->setRiskyAllowed(true) | |
->setRules([ | |
'header_comment' => ['header' => $header], | |
'@PHP56Migration' => true, | |
'@PHPUnit60Migration:risky' => true, | |
'@Symfony' => true, | |
'@Symfony:risky' => true, | |
'align_multiline_comment' => [ | |
'comment_type' => 'phpdocs_like' | |
], | |
'binary_operator_spaces' => [ | |
'align_double_arrow' => true, | |
'align_equals' => false, | |
], | |
'blank_line_after_opening_tag' => true, | |
'blank_line_after_namespace' => true, | |
'blank_line_before_return' => true, | |
'braces' => true, | |
'cast_spaces' => [ | |
'space' => 'single', | |
], | |
'class_definition' => true, | |
'concat_space' => true, | |
'declare_equal_normalize' => true, | |
'elseif' => true, | |
'encoding' => true, | |
'full_opening_tag' => true, | |
'function_declaration' => true, | |
'function_typehint_space' => true, | |
'single_line_comment_style' => true, | |
'heredoc_to_nowdoc' => true, | |
'include' => true, | |
'indentation_type' => true, | |
'ordered_imports' => [ | |
'sortAlgorithm' => 'length', | |
], | |
'lowercase_cast' => true, | |
'lowercase_constants' => true, | |
'lowercase_keywords' => true, | |
'magic_constant_casing' => true, | |
'method_argument_space' => true, | |
'visibility_required' => true, | |
'no_closing_tag' => true, | |
'no_spaces_after_function_name' => true, | |
'no_spaces_inside_parenthesis' => true, | |
'no_trailing_whitespace' => true, | |
'no_trailing_whitespace_in_comment' => true, | |
'psr4' => true, // risky! | |
'single_blank_line_at_eof' => true, | |
'single_class_element_per_statement' => true, | |
'single_import_per_statement' => true, | |
'single_line_after_imports' => true, | |
'switch_case_semicolon_to_colon' => true, | |
'switch_case_space' => true, | |
'line_ending' => true, | |
'array_syntax' => ['syntax' => 'short'], | |
'combine_consecutive_issets' => true, | |
'combine_consecutive_unsets' => true, | |
'compact_nullable_typehint' => true, | |
'escape_implicit_backslashes' => true, | |
'explicit_indirect_variable' => true, | |
'explicit_string_variable' => true, | |
'final_internal_class' => true, | |
'list_syntax' => ['syntax' => 'long'], | |
'method_chaining_indentation' => true, | |
'no_extra_blank_lines' => [ | |
'tokens' => [ | |
'break', 'continue', 'extra', 'return', 'throw', 'use', | |
'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block' | |
] | |
], | |
'no_null_property_initialization' => true, | |
'no_short_echo_tag' => true, | |
'no_superfluous_elseif' => true, | |
'no_unneeded_curly_braces' => true, | |
'no_unneeded_final_method' => true, | |
'no_unreachable_default_argument_value' => true, | |
'no_useless_else' => true, | |
'no_useless_return' => true, | |
'ordered_class_elements' => true, | |
'php_unit_strict' => true, | |
'php_unit_test_annotation' => true, | |
'php_unit_test_class_requires_covers' => true, | |
'phpdoc_add_missing_param_annotation' => true, | |
'phpdoc_order' => true, | |
'phpdoc_types_order' => true, | |
'semicolon_after_instruction' => true, | |
'single_line_comment_style' => true, | |
'strict_comparison' => true, | |
'strict_param' => true, | |
'yoda_style' => true, | |
]) | |
->setFinder( | |
PhpCsFixer\Finder::create() | |
->exclude('tests/Fixtures') | |
->in(__DIR__) | |
) | |
; | |
try { | |
PhpCsFixer\FixerFactory::create() | |
->registerBuiltInFixers() | |
->registerCustomFixers($config->getCustomFixers()) | |
->useRuleSet(new PhpCsFixer\RuleSet($config->getRules())); | |
} catch (PhpCsFixer\ConfigurationException\InvalidConfigurationException $e) { | |
$config->setRules([]); | |
} catch (UnexpectedValueException $e) { | |
$config->setRules([]); | |
} catch (InvalidArgumentException $e) { | |
$config->setRules([]); | |
} | |
return $config; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment