From 9bd84e473d5ef1cd8caac31721e1b1c194d83a4c Mon Sep 17 00:00:00 2001 From: Jannik Zschiesche Date: Thu, 17 Sep 2020 13:53:40 +0200 Subject: [PATCH] Use tabs for indentation --- .editorconfig | 92 ++++++++ .github/workflows/ci.yml | 2 +- .php_cs.dist | 477 ++++++++++++++++++++------------------- CHANGELOG.md | 6 + composer.json | 50 ++-- 5 files changed, 363 insertions(+), 264 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..d9841a4 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,92 @@ +# EditorConfig is awesome: http://EditorConfig.org + +# top-most EditorConfig file +root = true +charset = utf-8 + +# Get rid of whitespace to avoid diffs with a bunch of EOL changes +trim_trailing_whitespace = true + +# Unix-style newlines with a newline ending every file +[*] +end_of_line = lf +insert_final_newline = true + +# CSS-Files +[*.css] +indent_style = tab + +# HTML-Files +[*.html] +indent_style = tab + +# TXT-Files +[*.txt] +indent_style = tab + +# TMPL-Files +[*.tmpl] +indent_style = tab + +# LESS-Files +[*.less] +indent_style = tab + +# SCSS-Files +[*.scss] +indent_style = tab + +# SASS-Files +[*.sass] +indent_style = tab + +# JS-Files +[*.js] +indent_style = tab + +# JSON-Files +[*.json] +indent_style = tab + +# YML-Files +[*.yml] +indent_style = tab + +# Makefile +[Makefile] +indent_style = tab + +# PHP-Files +[*.php] +indent_style = tab + +# ReST-Files +[*.rst] +indent_style = space +indent_size = 3 + +# MD-Files +[*.md] +indent_style = space +indent_size = 4 + +# .travis.yml +[.travis.yml] +indent_style = tab + +# TypeScript +[*.ts] +indent_style = tab + +# TypoScript +[*.ts2] +indent_style = space +indent_size = 2 + +# XLF-Files +[*.xlf] +indent_style = tab + +# SQL-Files +[*.sql] +indent_style = tab diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fe802d8..3889478 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,4 +16,4 @@ jobs: - name: Composer Normalize uses: "docker://ergebnis/composer-normalize-action:latest" with: - args: "--indent-size 4 --indent-style space --dry-run" \ No newline at end of file + args: "--indent-style tab --indent-size 1 --dry-run" diff --git a/.php_cs.dist b/.php_cs.dist index 1d995ca..c6e9aa0 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -4,259 +4,260 @@ $cwd = \getcwd(); if (\is_dir("{$cwd}/src") && (\is_dir("{$cwd}/public") || \is_dir("{$cwd}/web"))) { - $dirs = []; + $dirs = []; - // this is a symfony project, so add possible symfony directories - foreach (["app", "config", "public", "src", "web"] as $possibleDir) - { - if (\is_dir("{$cwd}/{$possibleDir}")) - { - $dirs[] = $possibleDir; - } - } + // this is a symfony project, so add possible symfony directories + foreach (["app", "config", "public", "src", "web"] as $possibleDir) + { + if (\is_dir("{$cwd}/{$possibleDir}")) + { + $dirs[] = $possibleDir; + } + } } else { - // regular library, so just lint everything - $dirs = ["src"]; + // regular library, so just lint everything + $dirs = ["src"]; } - $finder = PhpCsFixer\Finder::create() - ->in($dirs) - ->exclude(["Migrations", "node_modules", "tests", "var", "vendor", "vendor-bin"]) - ->ignoreUnreadableDirs() -; + ->in($dirs) + ->exclude(["Migrations", "node_modules", "tests", "var", "vendor", "vendor-bin"]) + ->ignoreUnreadableDirs(); return PhpCsFixer\Config::create() - ->setFinder($finder) - ->setRiskyAllowed(true) - ->setRules([ - "@PSR1" => true, - "align_multiline_comment" => [ - "comment_type" => "phpdocs_only", - ], - "array_indentation" => true, - "array_syntax" => [ - "syntax" => "short", - ], - "backtick_to_shell_exec" => true, - "binary_operator_spaces" => true, - "blank_line_after_namespace" => true, - "blank_line_after_opening_tag" => false, // we want to allow ` [ - "statements" => [ - "case", - "default", - "do", - "exit", - "for", - "foreach", - "if", - "switch", - "try", - "while", - "yield", - ], - ], - // disabled, as this forces the brace on the same line, if the method arguments are over multiple lines (to be compatible with PSR-2) - // see https://github.com/FriendsOfPHP/PHP-CS-Fixer/issues/3637#issuecomment-409987422 + ->setIndent("\t") + ->setFinder($finder) + ->setRiskyAllowed(true) + ->setRules( + [ + "@PSR1" => true, + "align_multiline_comment" => [ + "comment_type" => "phpdocs_only", + ], + "array_indentation" => true, + "array_syntax" => [ + "syntax" => "short", + ], + "backtick_to_shell_exec" => true, + "binary_operator_spaces" => true, + "blank_line_after_namespace" => true, + "blank_line_after_opening_tag" => false, + // we want to allow ` [ + "statements" => [ + "case", + "default", + "do", + "exit", + "for", + "foreach", + "if", + "switch", + "try", + "while", + "yield", + ], + ], + // disabled, as this forces the brace on the same line, if the method arguments are over multiple lines (to be compatible with PSR-2) + // see https://github.com/FriendsOfPHP/PHP-CS-Fixer/issues/3637#issuecomment-409987422 // "braces" => [ // "allow_single_line_closure" => true, // "position_after_anonymous_constructs" => "next", // "position_after_control_structures" => "next", // "position_after_functions_and_oop_constructs" => "next", // ], - "cast_spaces" => [ - "space" => "single", - ], - // Disabled, as we can't configure *2* blank lines to separate - // see https://github.com/FriendsOfPHP/PHP-CS-Fixer/issues/4001 + "cast_spaces" => [ + "space" => "single", + ], + // Disabled, as we can't configure *2* blank lines to separate + // see https://github.com/FriendsOfPHP/PHP-CS-Fixer/issues/4001 // "class_attributes_separation" => [ // "elements" => ["method", "property"], // ], - "class_definition" => true, - "combine_consecutive_issets" => true, - "combine_consecutive_unsets" => true, - "combine_nested_dirname" => true, - "compact_nullable_typehint" => true, - "concat_space" => [ - "spacing" => "one", - ], - "constant_case" => true, - "declare_equal_normalize" => [ - "space" => "none", - ], - "declare_strict_types" => true, - "dir_constant" => true, - "doctrine_annotation_array_assignment" => true, - "elseif" => true, - "encoding" => true, - "ereg_to_preg" => true, - "error_suppression" => true, - "escape_implicit_backslashes" => [ - "double_quoted" => true, - "heredoc_syntax" => true, - "single_quoted" => true, - ], - "explicit_indirect_variable" => true, - "explicit_string_variable" => true, - "final_internal_class" => true, - "final_static_access" => true, - "full_opening_tag" => true, - "fully_qualified_strict_types" => true, - "function_to_constant" => true, - "function_typehint_space" => true, - "global_namespace_import" => [ - "import_classes" => false, - "import_constants" => false, - "import_functions" => false, - ], - "heredoc_to_nowdoc" => true, - "implode_call" => true, - "include" => true, - "increment_style" => true, - "indentation_type" => true, - "is_null" => true, - "line_ending" => true, - "list_syntax" => [ - "syntax" => "short", - ], - "logical_operators" => true, - "lowercase_cast" => true, - "lowercase_constants" => true, - "lowercase_keywords" => true, - "lowercase_static_reference" => true, - "magic_constant_casing" => true, - "magic_method_casing" => true, - "method_argument_space" => [ - "keep_multiple_spaces_after_comma" => false, - "on_multiline" => "ensure_fully_multiline", - ], - "modernize_types_casting" => true, - "multiline_comment_opening_closing" => true, - "multiline_whitespace_before_semicolons" => true, - "native_constant_invocation" => true, - "native_function_casing" => true, - "native_function_invocation" => true, - "native_function_type_declaration_casing" => true, - "new_with_braces" => true, - "no_alias_functions" => [ - "sets" => ["@all"], - ], - "no_binary_string" => true, - "no_blank_lines_after_class_opening" => true, - "no_blank_lines_after_phpdoc" => true, - "no_break_comment" => true, - "no_closing_tag" => true, - "no_empty_comment" => true, - "no_empty_statement" => true, - "no_homoglyph_names" => true, - "no_leading_import_slash" => true, - "no_leading_namespace_whitespace" => true, - "no_mixed_echo_print" => true, - "no_multiline_whitespace_around_double_arrow" => true, - "no_null_property_initialization" => true, - "no_short_bool_cast" => true, - "no_singleline_whitespace_before_semicolons" => true, - "no_spaces_after_function_name" => false, - "no_spaces_around_offset" => true, - "no_spaces_inside_parenthesis" => true, - "no_superfluous_elseif" => true, - "no_superfluous_phpdoc_tags" => [ - "allow_mixed" => true, - ], - "no_trailing_comma_in_singleline_array" => true, - "no_trailing_whitespace" => true, - "no_trailing_whitespace_in_comment" => true, - "no_unneeded_control_parentheses" => true, - "no_unneeded_curly_braces" => true, - "no_unneeded_final_method" => true, - "no_unset_cast" => true, - "no_unset_on_property" => true, - "no_unused_imports" => true, - "no_useless_else" => true, - "no_useless_return" => true, - "no_whitespace_before_comma_in_array" => true, - "no_whitespace_in_blank_line" => true, - "non_printable_character" => [ - "use_escape_sequences_in_strings" => true, - ], - "normalize_index_brace" => true, - "nullable_type_declaration_for_default_null_value" => true, - "object_operator_without_whitespace" => true, - "ordered_imports" => true, - "php_unit_construct" => true, - "php_unit_dedicate_assert" => true, - "php_unit_expectation" => true, - "php_unit_fqcn_annotation" => true, - "php_unit_internal_class" => true, - "php_unit_method_casing" => true, - "php_unit_mock" => true, - "php_unit_namespaced" => true, - "php_unit_no_expectation_annotation" => true, - "php_unit_ordered_covers" => true, - "php_unit_set_up_tear_down_visibility" => true, - "php_unit_strict" => true, - "php_unit_test_case_static_method_calls" => [ - "call_type" => "self", - ], - "phpdoc_align" => true, - "phpdoc_indent" => true, - "phpdoc_no_access" => true, - "phpdoc_no_alias_tag" => true, - "phpdoc_no_empty_return" => true, - "phpdoc_no_package" => true, - "phpdoc_no_useless_inheritdoc" => true, - "phpdoc_order" => true, - "phpdoc_return_self_reference" => true, - "phpdoc_scalar" => true, - "phpdoc_separation" => true, - "phpdoc_single_line_var_spacing" => true, - "phpdoc_trim" => true, - "phpdoc_trim_consecutive_blank_line_separation" => true, - "phpdoc_types" => true, - "phpdoc_types_order" => [ - "null_adjustment" => "always_last", - "sort_algorithm" => "none", - ], - "phpdoc_var_without_name" => true, - "pow_to_exponentiation" => true, - "protected_to_private" => true, - "psr4" => true, - "random_api_migration" => true, - "return_type_declaration" => [ - "space_before" => "one", - ], - "self_accessor" => true, - "self_static_accessor" => true, - "semicolon_after_instruction" => true, - "set_type_to_cast" => true, - "short_scalar_cast" => true, - "simple_to_complex_string_variable" => true, - "single_blank_line_at_eof" => true, - "single_blank_line_before_namespace" => true, - "single_class_element_per_statement" => true, - "single_import_per_statement" => true, - "single_line_after_imports" => true, - "single_line_comment_style" => true, - "single_trait_insert_per_statement" => true, - "space_after_semicolon" => true, - "standardize_increment" => true, - "standardize_not_equals" => true, - "strict_comparison" => true, - "strict_param" => true, - "string_line_ending" => true, - "switch_case_semicolon_to_colon" => true, - "switch_case_space" => true, - "ternary_operator_spaces" => true, - "ternary_to_null_coalescing" => true, - "trailing_comma_in_multiline_array" => true, - "trim_array_spaces" => true, - "unary_operator_spaces" => true, - "visibility_required" => true, - "void_return" => true, - "whitespace_after_comma_in_array" => true, - "yoda_style" => true, - ]) -; \ No newline at end of file + "class_definition" => true, + "combine_consecutive_issets" => true, + "combine_consecutive_unsets" => true, + "combine_nested_dirname" => true, + "compact_nullable_typehint" => true, + "concat_space" => [ + "spacing" => "one", + ], + "constant_case" => true, + "declare_equal_normalize" => [ + "space" => "none", + ], + "declare_strict_types" => true, + "dir_constant" => true, + "doctrine_annotation_array_assignment" => true, + "elseif" => true, + "encoding" => true, + "ereg_to_preg" => true, + "error_suppression" => true, + "escape_implicit_backslashes" => [ + "double_quoted" => true, + "heredoc_syntax" => true, + "single_quoted" => true, + ], + "explicit_indirect_variable" => true, + "explicit_string_variable" => true, + "final_internal_class" => true, + "final_static_access" => true, + "full_opening_tag" => true, + "fully_qualified_strict_types" => true, + "function_to_constant" => true, + "function_typehint_space" => true, + "global_namespace_import" => [ + "import_classes" => false, + "import_constants" => false, + "import_functions" => false, + ], + "heredoc_to_nowdoc" => true, + "implode_call" => true, + "include" => true, + "increment_style" => true, + "indentation_type" => true, + "is_null" => true, + "line_ending" => true, + "list_syntax" => [ + "syntax" => "short", + ], + "logical_operators" => true, + "lowercase_cast" => true, + "lowercase_constants" => true, + "lowercase_keywords" => true, + "lowercase_static_reference" => true, + "magic_constant_casing" => true, + "magic_method_casing" => true, + "method_argument_space" => [ + "keep_multiple_spaces_after_comma" => false, + "on_multiline" => "ensure_fully_multiline", + ], + "modernize_types_casting" => true, + "multiline_comment_opening_closing" => true, + "multiline_whitespace_before_semicolons" => true, + "native_constant_invocation" => true, + "native_function_casing" => true, + "native_function_invocation" => true, + "native_function_type_declaration_casing" => true, + "new_with_braces" => true, + "no_alias_functions" => [ + "sets" => ["@all"], + ], + "no_binary_string" => true, + "no_blank_lines_after_class_opening" => true, + "no_blank_lines_after_phpdoc" => true, + "no_break_comment" => true, + "no_closing_tag" => true, + "no_empty_comment" => true, + "no_empty_statement" => true, + "no_homoglyph_names" => true, + "no_leading_import_slash" => true, + "no_leading_namespace_whitespace" => true, + "no_mixed_echo_print" => true, + "no_multiline_whitespace_around_double_arrow" => true, + "no_null_property_initialization" => true, + "no_short_bool_cast" => true, + "no_singleline_whitespace_before_semicolons" => true, + "no_spaces_after_function_name" => false, + "no_spaces_around_offset" => true, + "no_spaces_inside_parenthesis" => true, + "no_superfluous_elseif" => true, + "no_superfluous_phpdoc_tags" => [ + "allow_mixed" => true, + ], + "no_trailing_comma_in_singleline_array" => true, + "no_trailing_whitespace" => true, + "no_trailing_whitespace_in_comment" => true, + "no_unneeded_control_parentheses" => true, + "no_unneeded_curly_braces" => true, + "no_unneeded_final_method" => true, + "no_unset_cast" => true, + "no_unset_on_property" => true, + "no_unused_imports" => true, + "no_useless_else" => true, + "no_useless_return" => true, + "no_whitespace_before_comma_in_array" => true, + "no_whitespace_in_blank_line" => true, + "non_printable_character" => [ + "use_escape_sequences_in_strings" => true, + ], + "normalize_index_brace" => true, + "nullable_type_declaration_for_default_null_value" => true, + "object_operator_without_whitespace" => true, + "ordered_imports" => true, + "php_unit_construct" => true, + "php_unit_dedicate_assert" => true, + "php_unit_expectation" => true, + "php_unit_fqcn_annotation" => true, + "php_unit_internal_class" => true, + "php_unit_method_casing" => true, + "php_unit_mock" => true, + "php_unit_namespaced" => true, + "php_unit_no_expectation_annotation" => true, + "php_unit_ordered_covers" => true, + "php_unit_set_up_tear_down_visibility" => true, + "php_unit_strict" => true, + "php_unit_test_case_static_method_calls" => [ + "call_type" => "self", + ], + "phpdoc_align" => true, + "phpdoc_indent" => true, + "phpdoc_no_access" => true, + "phpdoc_no_alias_tag" => true, + "phpdoc_no_empty_return" => true, + "phpdoc_no_package" => true, + "phpdoc_no_useless_inheritdoc" => true, + "phpdoc_order" => true, + "phpdoc_return_self_reference" => true, + "phpdoc_scalar" => true, + "phpdoc_separation" => true, + "phpdoc_single_line_var_spacing" => true, + "phpdoc_trim" => true, + "phpdoc_trim_consecutive_blank_line_separation" => true, + "phpdoc_types" => true, + "phpdoc_types_order" => [ + "null_adjustment" => "always_last", + "sort_algorithm" => "none", + ], + "phpdoc_var_without_name" => true, + "pow_to_exponentiation" => true, + "protected_to_private" => true, + "psr4" => true, + "random_api_migration" => true, + "return_type_declaration" => [ + "space_before" => "one", + ], + "self_accessor" => true, + "self_static_accessor" => true, + "semicolon_after_instruction" => true, + "set_type_to_cast" => true, + "short_scalar_cast" => true, + "simple_to_complex_string_variable" => true, + "single_blank_line_at_eof" => true, + "single_blank_line_before_namespace" => true, + "single_class_element_per_statement" => true, + "single_import_per_statement" => true, + "single_line_after_imports" => true, + "single_line_comment_style" => true, + "single_trait_insert_per_statement" => true, + "space_after_semicolon" => true, + "standardize_increment" => true, + "standardize_not_equals" => true, + "strict_comparison" => true, + "strict_param" => true, + "string_line_ending" => true, + "switch_case_semicolon_to_colon" => true, + "switch_case_space" => true, + "ternary_operator_spaces" => true, + "ternary_to_null_coalescing" => true, + "trailing_comma_in_multiline_array" => true, + "trim_array_spaces" => true, + "unary_operator_spaces" => true, + "visibility_required" => true, + "void_return" => true, + "whitespace_after_comma_in_array" => true, + "yoda_style" => true, + ] + ); diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d4c3b3..35e5973 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +2.0.1 +===== + +* (improvement) Use tabs for indentation. + + 2.0.0 ===== diff --git a/composer.json b/composer.json index c5fd096..1f65506 100644 --- a/composer.json +++ b/composer.json @@ -1,27 +1,27 @@ { - "name": "21torr/php-cs", - "type": "lib", - "description": "Code style, encoded as rules for common tools.", - "homepage": "https://github.com/21TORR/php-cs", - "license": "BSD-3-Clause", - "authors": [ - { - "name": "21TORR", - "homepage": "https://www.21torr.com/" - } - ], - "require": { - "php": "^7.4", - "ext-json": "*", - "friendsofphp/php-cs-fixer": "^v2.16.4", - "phpstan/phpstan": "^0.12.42", - "phpstan/phpstan-doctrine": "^0.12.19", - "phpstan/phpstan-symfony": "^0.12.7" - }, - "require-dev": { - "roave/security-advisories": "dev-master" - }, - "config": { - "sort-packages": true - } + "name": "21torr/php-cs", + "type": "lib", + "description": "Code style, encoded as rules for common tools.", + "homepage": "https://github.com/21TORR/php-cs", + "license": "BSD-3-Clause", + "authors": [ + { + "name": "21TORR", + "homepage": "https://www.21torr.com/" + } + ], + "require": { + "php": "^7.4", + "ext-json": "*", + "friendsofphp/php-cs-fixer": "^v2.16.4", + "phpstan/phpstan": "^0.12.42", + "phpstan/phpstan-doctrine": "^0.12.19", + "phpstan/phpstan-symfony": "^0.12.7" + }, + "require-dev": { + "roave/security-advisories": "dev-master" + }, + "config": { + "sort-packages": true + } }