Skip to content

Instantly share code, notes, and snippets.

@alexbcberio
Last active April 12, 2018 12:30
Show Gist options
  • Save alexbcberio/7462194398aacde54c8010f95357713a to your computer and use it in GitHub Desktop.
Save alexbcberio/7462194398aacde54c8010f95357713a to your computer and use it in GitHub Desktop.
php-cs fixer preferred rules
<?php
$finder = Symfony\Component\Finder\Finder::create()
->files()
->in(__DIR__)
->exclude("vendor")
->ignoreDotFiles(true)
->ignoreVCS(true);
return PhpCsFixer\Config::create()
->setFinder($finder)
->setRules([
"@PSR2" => true,
"align_multiline_comment" => ["comment_type" => "all_multiline"],
"array_syntax" => ["syntax" => "short"],
"backtick_to_shell_exec" => true,
"blank_line_after_opening_tag" => true,
"blank_line_before_statement" => true,
"braces" => [
"position_after_anonymous_constructs" => "same",
"position_after_control_structures" => "same",
"position_after_functions_and_oop_constructs" => "same"
],
"class_definition" => true,
"declare_equal_normalize" => [
"space" => "single"
],
"encoding" => true,
"elseif" => true,
"full_opening_tag" => true,
"function_declaration" => true,
"indentation_type" => true,
"line_ending" => true,
"linebreak_after_opening_tag" => true,
"lowercase_constants" => true,
"lowercase_keywords" => true,
"method_argument_space" => [
"ensure_fully_multiline" => true
],
"no_closing_tag" => true,
"no_empty_comment" => true,
"no_short_echo_tag" => true,
"no_spaces_after_function_name" => true,
"no_spaces_inside_parenthesis" => true,
"no_trailing_whitespace" => true,
"no_trailing_whitespace_in_comment" => true,
"no_useless_else" => true,
"no_useless_return" => true,
"no_whitespace_in_blank_line" => true,
"single_blank_line_at_eof" => true,
"single_class_element_per_statement" => true,
"single_import_per_statement" => true,
"single_line_after_imports" => true,
"standardize_not_equals" => true,
"switch_case_semicolon_to_colon" => true,
"switch_case_space" => true,
"visibility_required" => true,
"whitespace_after_comma_in_array" => true
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment