Skip to content

Latest commit

 

History

History
966 lines (627 loc) · 44 KB

index.rst

File metadata and controls

966 lines (627 loc) · 44 KB

List of Available Rules

Alias

Array Notation

Attribute Notation

Basic

  • braces (deprecated)

    The body of each structure MUST be enclosed by braces. Braces should be properly placed. Body of braces should be properly indented.

  • braces_position

    Braces must be placed as configured.

  • curly_braces_position (deprecated)

    Curly braces must be placed as configured.

  • encoding

    PHP code MUST use only UTF-8 without BOM (remove BOM).

  • no_multiple_statements_per_line

    There must not be more than one statement per line.

  • no_trailing_comma_in_singleline

    If a list of values separated by a comma is contained on a single line, then the last item MUST NOT have a trailing comma.

  • non_printable_character (risky)

    Remove Zero-width space (ZWSP), Non-breaking space (NBSP) and other invisible unicode symbols.

  • numeric_literal_separator

    Adds separators to numeric literals of any kind.

  • octal_notation

    Literal octal must be in 0o notation.

  • psr_autoloading (risky)

    Classes must be in a path that matches their namespace, be at least one namespace deep and the class name should match the file name.

  • single_line_empty_body

    Empty body of class, interface, trait, enum or function must be abbreviated as {} and placed on the same line as the previous symbol, separated by a single space.

Casing

Cast Notation

  • cast_spaces

    A single space or none should be between cast and variable.

  • lowercase_cast

    Cast should be written in lower case.

  • modernize_types_casting (risky)

    Replaces intval, floatval, doubleval, strval and boolval function calls with according type casting operator.

  • no_short_bool_cast

    Short cast bool using double exclamation mark should not be used.

  • no_unset_cast

    Variables must be set null instead of using (unset) casting.

  • short_scalar_cast

    Cast (boolean) and (integer) should be written as (bool) and (int), (double) and (real) as (float), (binary) as (string).

Class Notation

Class Usage

Comment

Constant Notation

  • native_constant_invocation (risky)

    Add leading \ before constant invocation of internal constant to speed up resolving. Constant name match is case-sensitive, except for null, false and true.

Control Structure

Doctrine Annotation

Function Notation

  • combine_nested_dirname (risky)

    Replace multiple nested calls of dirname by only one call with second $level parameter.

  • date_time_create_from_format_call (risky)

    The first argument of DateTime::createFromFormat method must start with !.

  • fopen_flag_order (risky)

    Order the flags in fopen calls, b and t must be last.

  • fopen_flags (risky)

    The flags in fopen calls must omit t, and b must be omitted or included consistently.

  • function_declaration

    Spaces should be properly placed in a function declaration.

  • function_typehint_space (deprecated)

    Ensure single space between function's argument and its typehint.

  • implode_call (risky)

    Function implode must be called with 2 arguments in the documented order.

  • lambda_not_used_import

    Lambda must not import variables it doesn't use.

  • method_argument_space

    In method arguments and method call, there MUST NOT be a space before each comma and there MUST be one space after each comma. Argument lists MAY be split across multiple lines, where each subsequent line is indented once. When doing so, the first item in the list MUST be on the next line, and there MUST be only one argument per line.

  • native_function_invocation (risky)

    Add leading \ before function invocation to speed up resolving.

  • no_spaces_after_function_name

    When making a method or function call, there MUST NOT be a space between the method or function name and the opening parenthesis.

  • no_trailing_comma_in_singleline_function_call (deprecated)

    When making a method or function call on a single line there MUST NOT be a trailing comma after the last argument.

  • no_unreachable_default_argument_value (risky)

    In function arguments there must not be arguments with default values before non-default ones.

  • no_useless_sprintf (risky)

    There must be no sprintf calls with only the first argument.

  • nullable_type_declaration_for_default_null_value

    Adds or removes ? before single type declarations or |null at the end of union types when parameters have a default null value.

  • phpdoc_to_param_type (experimental, risky)

    Takes @param annotations of non-mixed types and adjusts accordingly the function signature.

  • phpdoc_to_property_type (experimental, risky)

    Takes @var annotation of non-mixed types and adjusts accordingly the property signature..

  • phpdoc_to_return_type (experimental, risky)

    Takes @return annotation of non-mixed types and adjusts accordingly the function signature.

  • regular_callable_call (risky)

    Callables must be called without using call_user_func* when possible.

  • return_type_declaration

    Adjust spacing around colon in return type declarations and backed enum types.

  • single_line_throw

    Throwing exception must be done in single line.

  • static_lambda (risky)

    Lambdas not (indirectly) referencing $this must be declared static.

  • use_arrow_functions (risky)

    Anonymous functions with return as the only statement must use arrow functions.

  • void_return (risky)

    Add void return type to functions with missing or empty return statements, but priority is given to @return annotations.

Import

Language Construct

List Notation

  • list_syntax

    List (array destructuring) assignment should be declared using the configured syntax.

Namespace Notation

Naming

  • no_homoglyph_names (risky)

    Replace accidental usage of homoglyphs (non ascii characters) in names.

Operator

PHP Tag

  • blank_line_after_opening_tag

    Ensure there is no code on the same line as the PHP open tag and it is followed by a blank line.

  • echo_tag_syntax

    Replaces short-echo <?= with long format <?php echo/<?php print syntax, or vice-versa.

  • full_opening_tag

    PHP code must use the long <?php tags or short-echo <?= tags and not other tag variations.

  • linebreak_after_opening_tag

    Ensure there is no code on the same line as the PHP open tag.

  • no_closing_tag

    The closing ?> tag MUST be omitted from files containing only PHP.

PHPUnit

PHPDoc

Return Notation

  • no_useless_return

    There should not be an empty return statement at the end of a function.

  • return_assignment

    Local, dynamic and directly referenced variables should not be assigned and directly returned by a function or method.

  • simplified_null_return

    A return statement wishing to return void should not return null.

Semicolon

Strict

String Notation

  • escape_implicit_backslashes (deprecated)

    Escape implicit backslashes in strings and heredocs to ease the understanding of which are special chars interpreted by PHP and which not.

  • explicit_string_variable

    Converts implicit variables into explicit ones in double-quoted strings or heredoc syntax.

  • heredoc_closing_marker

    Unify heredoc or nowdoc closing marker.

  • heredoc_to_nowdoc

    Convert heredoc to nowdoc where possible.

  • multiline_string_to_heredoc

    Convert multiline string to heredoc or nowdoc.

  • no_binary_string

    There should not be a binary flag before strings.

  • no_trailing_whitespace_in_string (risky)

    There must be no trailing whitespace in strings.

  • simple_to_complex_string_variable

    Converts explicit variables in double-quoted strings and heredoc syntax from simple to complex format (${ to {$).

  • single_quote

    Convert double quotes to single quotes for simple strings.

  • string_implicit_backslashes

    Handles implicit backslashes in strings and heredocs. Depending on the chosen strategy, it can escape implicit backslashes to ease the understanding of which are special chars interpreted by PHP and which not (escape), or it can remove these additional backslashes if you find them superfluous (unescape). You can also leave them as-is using ignore strategy.

  • string_length_to_empty (risky)

    String tests for empty must be done against '', not with strlen.

  • string_line_ending (risky)

    All multi-line strings must use correct line ending.

Whitespace