From 714a38d53ee293571a099b152ecf75c5935f03d6 Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Sat, 23 Feb 2019 02:05:20 +0300 Subject: [PATCH] Bump minimal php-cs-fixer version to 2.13.0. Add additional rules. --- composer.json | 2 +- composer.lock | 2 +- src/Rules.php | 60 ++++++++++++++++++- .../BlankLineBeforeReturnFixerTest.php | 2 +- 4 files changed, 62 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index b739878..24e41ca 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ "type": "library", "require": { "php": "^7.0", - "friendsofphp/php-cs-fixer": "^2.12.2" + "friendsofphp/php-cs-fixer": "^2.13.0" }, "require-dev": { "phpunit/phpunit": "^6.5.1" diff --git a/composer.lock b/composer.lock index 36c14b4..ea8a6c8 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "80849b188628ffdf06b4ffc4be3edb84", + "content-hash": "0d399f36e24f93c2b3ce717b19cfa1ac", "packages": [ { "name": "composer/semver", diff --git a/src/Rules.php b/src/Rules.php index ad93090..3b90402 100644 --- a/src/Rules.php +++ b/src/Rules.php @@ -7,6 +7,7 @@ class Rules { private static $rules = [ '@PSR2' => true, + 'array_indentation' => true, 'array_syntax' => [ 'syntax' => 'short', ], @@ -20,41 +21,98 @@ class Rules { 'class_attributes_separation' => [ 'elements' => ['method', 'property'], ], + 'combine_consecutive_issets' => true, + 'combine_nested_dirname' => true, 'compact_nullable_typehint' => true, 'concat_space' => [ 'spacing' => 'one', ], 'declare_equal_normalize' => true, + 'dir_constant' => true, + 'ereg_to_preg' => true, + 'explicit_indirect_variable' => true, + 'explicit_string_variable' => true, // Should be configurable to choose between ${var} and {$var} 'function_declaration' => [ 'closure_function_spacing' => 'none', ], 'function_to_constant' => true, + 'implode_call' => true, 'include' => true, + 'is_null' => true, 'linebreak_after_opening_tag' => true, + 'list_syntax' => [ + 'syntax' => 'short', + ], + 'logical_operators' => true, + 'lowercase_cast' => true, + 'lowercase_static_reference' => true, + 'magic_constant_casing' => true, + 'magic_method_casing' => true, 'method_chaining_indentation' => true, 'modernize_types_casting' => true, + 'multiline_whitespace_before_semicolons' => [ + 'strategy' => 'no_multi_line', + ], + 'native_function_casing' => true, + 'no_alternative_syntax' => 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_php4_constructor' => true, 'no_short_bool_cast' => true, + 'no_spaces_around_offset' => true, + 'no_superfluous_elseif' => true, 'no_trailing_comma_in_singleline_array' => true, + 'no_unneeded_control_parentheses' => true, 'no_unneeded_final_method' => 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, 'object_operator_without_whitespace' => true, 'ordered_class_elements' => true, 'ordered_imports' => true, - 'random_api_migration' => true, + 'php_unit_construct' => true, + 'php_unit_expectation' => true, + 'php_unit_method_casing' => true, + 'php_unit_mock' => true, + 'php_unit_namespaced' => true, + 'php_unit_set_up_tear_down_visibility' => true, + 'php_unit_strict' => true, + 'pow_to_exponentiation' => true, + 'psr4' => true, + 'return_assignment' => true, + 'random_api_migration' => [ + 'replacements' => [ + 'getrandmax' => 'mt_getrandmax', + 'rand' => 'random_int', + 'srand' => 'mt_srand', + ], + ], 'return_type_declaration' => [ 'space_before' => 'none', ], + 'self_accessor' => true, + 'semicolon_after_instruction' => true, + 'set_type_to_cast' => true, + 'short_scalar_cast' => true, 'single_quote' => true, + 'space_after_semicolon' => true, + 'standardize_increment' => true, + 'standardize_not_equals' => true, 'strict_comparison' => 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' => [ 'elements' => ['property', 'method', 'const'], ], diff --git a/tests/Fixer/Whitespace/BlankLineBeforeReturnFixerTest.php b/tests/Fixer/Whitespace/BlankLineBeforeReturnFixerTest.php index 22dcdad..07e8f9d 100644 --- a/tests/Fixer/Whitespace/BlankLineBeforeReturnFixerTest.php +++ b/tests/Fixer/Whitespace/BlankLineBeforeReturnFixerTest.php @@ -36,7 +36,7 @@ public function testFix($expected, $input = null) { public function provideFixCases() { $cases = []; $cases[] = [ - '$a = $a; + '$a = $a; return $a; ', ];