Browse Source

Add PSR12 ruleset

Julien Falque 4 years ago
parent
commit
5504668825

+ 36 - 0
doc/ruleSets/PSR12.rst

@@ -0,0 +1,36 @@
+===================
+Rule set ``@PSR12``
+===================
+
+Rules that follow `PSR-2 <https://www.php-fig.org/psr/psr-2/>`_ standard.
+
+Rules
+-----
+
+- `@PSR2 <./PSR2.rst>`_
+- `blank_line_after_opening_tag <./../rules/php_tag/blank_line_after_opening_tag.rst>`_
+- `braces <./../rules/basic/braces.rst>`_
+  config:
+  ``['allow_single_line_anonymous_class_with_empty_body' => true]``
+- `compact_nullable_typehint <./../rules/whitespace/compact_nullable_typehint.rst>`_
+- `declare_equal_normalize <./../rules/language_construct/declare_equal_normalize.rst>`_
+- `lowercase_cast <./../rules/cast_notation/lowercase_cast.rst>`_
+- `lowercase_static_reference <./../rules/casing/lowercase_static_reference.rst>`_
+- `new_with_braces <./../rules/operator/new_with_braces.rst>`_
+- `no_blank_lines_after_class_opening <./../rules/class_notation/no_blank_lines_after_class_opening.rst>`_
+- `no_leading_import_slash <./../rules/import/no_leading_import_slash.rst>`_
+- `no_whitespace_in_blank_line <./../rules/whitespace/no_whitespace_in_blank_line.rst>`_
+- `ordered_class_elements <./../rules/class_notation/ordered_class_elements.rst>`_
+  config:
+  ``['order' => ['use_trait']]``
+- `ordered_imports <./../rules/import/ordered_imports.rst>`_
+  config:
+  ``['imports_order' => ['class', 'function', 'const'], 'sort_algorithm' => 'none']``
+- `return_type_declaration <./../rules/function_notation/return_type_declaration.rst>`_
+- `short_scalar_cast <./../rules/cast_notation/short_scalar_cast.rst>`_
+- `single_blank_line_before_namespace <./../rules/namespace_notation/single_blank_line_before_namespace.rst>`_
+- `single_trait_insert_per_statement <./../rules/class_notation/single_trait_insert_per_statement.rst>`_
+- `ternary_operator_spaces <./../rules/operator/ternary_operator_spaces.rst>`_
+- `visibility_required <./../rules/class_notation/visibility_required.rst>`_
+  config:
+  ``['elements' => ['const', 'method', 'property']]``

+ 11 - 0
doc/ruleSets/PSR12Risky.rst

@@ -0,0 +1,11 @@
+=========================
+Rule set ``@PSR12:risky``
+=========================
+
+Rules that follow `PSR-2 <https://www.php-fig.org/psr/psr-2/>`_ standard. This set contains rules that are risky.
+
+Rules
+-----
+
+- `no_trailing_whitespace_in_string <./../rules/string_notation/no_trailing_whitespace_in_string.rst>`_
+- `no_unreachable_default_argument_value <./../rules/function_notation/no_unreachable_default_argument_value.rst>`_

+ 0 - 1
doc/ruleSets/PhpCsFixer.rst

@@ -15,7 +15,6 @@ Rules
   ``['statements' => ['break', 'case', 'continue', 'declare', 'default', 'exit', 'goto', 'include', 'include_once', 'require', 'require_once', 'return', 'switch', 'throw', 'try']]``
 - `combine_consecutive_issets <./../rules/language_construct/combine_consecutive_issets.rst>`_
 - `combine_consecutive_unsets <./../rules/language_construct/combine_consecutive_unsets.rst>`_
-- `compact_nullable_typehint <./../rules/whitespace/compact_nullable_typehint.rst>`_
 - `escape_implicit_backslashes <./../rules/string_notation/escape_implicit_backslashes.rst>`_
 - `explicit_indirect_variable <./../rules/language_construct/explicit_indirect_variable.rst>`_
 - `explicit_string_variable <./../rules/string_notation/explicit_string_variable.rst>`_

+ 2 - 14
doc/ruleSets/Symfony.rst

@@ -7,13 +7,12 @@ Rules that follow the official `Symfony Coding Standards <https://symfony.com/do
 Rules
 -----
 
-- `@PSR2 <./PSR2.rst>`_
+- `@PSR12 <./PSR12.rst>`_
 - `array_syntax <./../rules/array_notation/array_syntax.rst>`_
   config:
   ``['syntax' => 'short']``
 - `backtick_to_shell_exec <./../rules/alias/backtick_to_shell_exec.rst>`_
 - `binary_operator_spaces <./../rules/operator/binary_operator_spaces.rst>`_
-- `blank_line_after_opening_tag <./../rules/php_tag/blank_line_after_opening_tag.rst>`_
 - `blank_line_before_statement <./../rules/whitespace/blank_line_before_statement.rst>`_
   config:
   ``['statements' => ['return']]``
@@ -29,7 +28,6 @@ Rules
   ``['single_line' => true]``
 - `clean_namespace <./../rules/namespace_notation/clean_namespace.rst>`_
 - `concat_space <./../rules/operator/concat_space.rst>`_
-- `declare_equal_normalize <./../rules/language_construct/declare_equal_normalize.rst>`_
 - `echo_tag_syntax <./../rules/php_tag/echo_tag_syntax.rst>`_
 - `fully_qualified_strict_types <./../rules/import/fully_qualified_strict_types.rst>`_
 - `function_typehint_space <./../rules/function_notation/function_typehint_space.rst>`_
@@ -40,18 +38,14 @@ Rules
 - `increment_style <./../rules/operator/increment_style.rst>`_
 - `lambda_not_used_import <./../rules/function_notation/lambda_not_used_import.rst>`_
 - `linebreak_after_opening_tag <./../rules/php_tag/linebreak_after_opening_tag.rst>`_
-- `lowercase_cast <./../rules/cast_notation/lowercase_cast.rst>`_
-- `lowercase_static_reference <./../rules/casing/lowercase_static_reference.rst>`_
 - `magic_constant_casing <./../rules/casing/magic_constant_casing.rst>`_
 - `magic_method_casing <./../rules/casing/magic_method_casing.rst>`_
 - `method_argument_space <./../rules/function_notation/method_argument_space.rst>`_
 - `native_function_casing <./../rules/casing/native_function_casing.rst>`_
 - `native_function_type_declaration_casing <./../rules/casing/native_function_type_declaration_casing.rst>`_
-- `new_with_braces <./../rules/operator/new_with_braces.rst>`_
 - `no_alias_language_construct_call <./../rules/alias/no_alias_language_construct_call.rst>`_
 - `no_alternative_syntax <./../rules/control_structure/no_alternative_syntax.rst>`_
 - `no_binary_string <./../rules/string_notation/no_binary_string.rst>`_
-- `no_blank_lines_after_class_opening <./../rules/class_notation/no_blank_lines_after_class_opening.rst>`_
 - `no_blank_lines_after_phpdoc <./../rules/phpdoc/no_blank_lines_after_phpdoc.rst>`_
 - `no_empty_comment <./../rules/comment/no_empty_comment.rst>`_
 - `no_empty_phpdoc <./../rules/phpdoc/no_empty_phpdoc.rst>`_
@@ -59,7 +53,6 @@ Rules
 - `no_extra_blank_lines <./../rules/whitespace/no_extra_blank_lines.rst>`_
   config:
   ``['tokens' => ['case', 'continue', 'curly_brace_block', 'default', 'extra', 'parenthesis_brace_block', 'square_brace_block', 'switch', 'throw', 'use', 'use_trait']]``
-- `no_leading_import_slash <./../rules/import/no_leading_import_slash.rst>`_
 - `no_leading_namespace_whitespace <./../rules/namespace_notation/no_leading_namespace_whitespace.rst>`_
 - `no_mixed_echo_print <./../rules/alias/no_mixed_echo_print.rst>`_
 - `no_multiline_whitespace_around_double_arrow <./../rules/array_notation/no_multiline_whitespace_around_double_arrow.rst>`_
@@ -80,7 +73,6 @@ Rules
 - `no_unset_cast <./../rules/cast_notation/no_unset_cast.rst>`_
 - `no_unused_imports <./../rules/import/no_unused_imports.rst>`_
 - `no_whitespace_before_comma_in_array <./../rules/array_notation/no_whitespace_before_comma_in_array.rst>`_
-- `no_whitespace_in_blank_line <./../rules/whitespace/no_whitespace_in_blank_line.rst>`_
 - `normalize_index_brace <./../rules/array_notation/normalize_index_brace.rst>`_
 - `object_operator_without_whitespace <./../rules/operator/object_operator_without_whitespace.rst>`_
 - `ordered_imports <./../rules/import/ordered_imports.rst>`_
@@ -113,10 +105,7 @@ Rules
   ``['null_adjustment' => 'always_last', 'sort_algorithm' => 'none']``
 - `phpdoc_var_without_name <./../rules/phpdoc/phpdoc_var_without_name.rst>`_
 - `protected_to_private <./../rules/class_notation/protected_to_private.rst>`_
-- `return_type_declaration <./../rules/function_notation/return_type_declaration.rst>`_
 - `semicolon_after_instruction <./../rules/semicolon/semicolon_after_instruction.rst>`_
-- `short_scalar_cast <./../rules/cast_notation/short_scalar_cast.rst>`_
-- `single_blank_line_before_namespace <./../rules/namespace_notation/single_blank_line_before_namespace.rst>`_
 - `single_class_element_per_statement <./../rules/class_notation/single_class_element_per_statement.rst>`_
 - `single_line_comment_style <./../rules/comment/single_line_comment_style.rst>`_
   config:
@@ -124,16 +113,15 @@ Rules
 - `single_line_throw <./../rules/function_notation/single_line_throw.rst>`_
 - `single_quote <./../rules/string_notation/single_quote.rst>`_
 - `single_space_after_construct <./../rules/language_construct/single_space_after_construct.rst>`_
-- `single_trait_insert_per_statement <./../rules/class_notation/single_trait_insert_per_statement.rst>`_
 - `space_after_semicolon <./../rules/semicolon/space_after_semicolon.rst>`_
   config:
   ``['remove_in_empty_for_expressions' => true]``
 - `standardize_increment <./../rules/operator/standardize_increment.rst>`_
 - `standardize_not_equals <./../rules/operator/standardize_not_equals.rst>`_
 - `switch_continue_to_break <./../rules/control_structure/switch_continue_to_break.rst>`_
-- `ternary_operator_spaces <./../rules/operator/ternary_operator_spaces.rst>`_
 - `trailing_comma_in_multiline_array <./../rules/array_notation/trailing_comma_in_multiline_array.rst>`_
 - `trim_array_spaces <./../rules/array_notation/trim_array_spaces.rst>`_
 - `unary_operator_spaces <./../rules/operator/unary_operator_spaces.rst>`_
+- `visibility_required <./../rules/class_notation/visibility_required.rst>`_
 - `whitespace_after_comma_in_array <./../rules/array_notation/whitespace_after_comma_in_array.rst>`_
 - `yoda_style <./../rules/control_structure/yoda_style.rst>`_

+ 2 - 1
doc/ruleSets/SymfonyRisky.rst

@@ -8,6 +8,7 @@ Rules
 -----
 
 - `@PHP56Migration:risky <./PHP56MigrationRisky.rst>`_
+- `@PSR12:risky <./PSR12Risky.rst>`_
 - `array_push <./../rules/alias/array_push.rst>`_
 - `combine_nested_dirname <./../rules/function_notation/combine_nested_dirname.rst>`_
 - `dir_constant <./../rules/language_construct/dir_constant.rst>`_
@@ -33,8 +34,8 @@ Rules
 - `no_alias_functions <./../rules/alias/no_alias_functions.rst>`_
 - `no_homoglyph_names <./../rules/naming/no_homoglyph_names.rst>`_
 - `no_php4_constructor <./../rules/class_notation/no_php4_constructor.rst>`_
-- `no_trailing_whitespace_in_string <./../rules/string_notation/no_trailing_whitespace_in_string.rst>`_
 - `no_unneeded_final_method <./../rules/class_notation/no_unneeded_final_method.rst>`_
+- `no_unreachable_default_argument_value <./../rules/function_notation/no_unreachable_default_argument_value.rst>`_
 - `no_useless_sprintf <./../rules/function_notation/no_useless_sprintf.rst>`_
 - `non_printable_character <./../rules/basic/non_printable_character.rst>`_
   config:

+ 2 - 0
doc/ruleSets/index.rst

@@ -28,6 +28,8 @@ List of Available Rule sets
 - `@PHPUnit75Migration:risky <./PHPUnit75MigrationRisky.rst>`_
 - `@PHPUnit84Migration:risky <./PHPUnit84MigrationRisky.rst>`_
 - `@PSR1 <./PSR1.rst>`_
+- `@PSR12 <./PSR12.rst>`_
+- `@PSR12:risky <./PSR12Risky.rst>`_
 - `@PSR2 <./PSR2.rst>`_
 - `@PhpCsFixer <./PhpCsFixer.rst>`_
 - `@PhpCsFixer:risky <./PhpCsFixerRisky.rst>`_

+ 5 - 0
doc/rules/basic/braces.rst

@@ -182,6 +182,11 @@ Rule sets
 
 The rule is part of the following rule sets:
 
+@PSR12
+  Using the `@PSR12 <./../../ruleSets/PSR12.rst>`_ rule set will enable the ``braces`` rule with the config below:
+
+  ``['allow_single_line_anonymous_class_with_empty_body' => true]``
+
 @PSR2
   Using the `@PSR2 <./../../ruleSets/PSR2.rst>`_ rule set will enable the ``braces`` rule with the default config.
 

+ 3 - 0
doc/rules/basic/encoding.rst

@@ -28,6 +28,9 @@ The rule is part of the following rule sets:
 @PSR1
   Using the `@PSR1 <./../../ruleSets/PSR1.rst>`_ rule set will enable the ``encoding`` rule.
 
+@PSR12
+  Using the `@PSR12 <./../../ruleSets/PSR12.rst>`_ rule set will enable the ``encoding`` rule.
+
 @PSR2
   Using the `@PSR2 <./../../ruleSets/PSR2.rst>`_ rule set will enable the ``encoding`` rule.
 

+ 3 - 0
doc/rules/casing/constant_case.rst

@@ -60,6 +60,9 @@ Rule sets
 
 The rule is part of the following rule sets:
 
+@PSR12
+  Using the `@PSR12 <./../../ruleSets/PSR12.rst>`_ rule set will enable the ``constant_case`` rule with the default config.
+
 @PSR2
   Using the `@PSR2 <./../../ruleSets/PSR2.rst>`_ rule set will enable the ``constant_case`` rule with the default config.
 

+ 3 - 0
doc/rules/casing/lowercase_keywords.rst

@@ -39,6 +39,9 @@ Rule sets
 
 The rule is part of the following rule sets:
 
+@PSR12
+  Using the `@PSR12 <./../../ruleSets/PSR12.rst>`_ rule set will enable the ``lowercase_keywords`` rule.
+
 @PSR2
   Using the `@PSR2 <./../../ruleSets/PSR2.rst>`_ rule set will enable the ``lowercase_keywords`` rule.
 

Some files were not shown because too many files changed in this diff