Our PHP fixing works by applying single-purposed transformations to files that fix specific issues.
Depending upon the preset, a default set of fixers will be included. If you want more granular control, you can enable or disable specific fixers by adding them to your configuration:
preset: recommended
enabled:
- no_superfluous_phpdoc_tags
- declare_strict_types
disabled:
- align_double_arrow
- include
{danger} If you want to use our PHP header checking facility, you must configure that part on the settings page; it's the only part of the configuration not available through the
.styleci.yml
file.
Align all multiline phpdoc and comments to match their first line.
{warn} This fixer cannot be enabled at the same time as the
align_phpdoc
fixer.
Align double arrow symbols in consecutive lines.
{warn} This fixer cannot be enabled at the same time as the
align_double_arrow_minimal
orunalign_double_arrow
fixers.
Minimally align double arrow symbols in consecutive lines.
{warn} This fixer cannot be enabled at the same time as the
align_double_arrow
orunalign_double_arrow
fixers.
Align equals symbols in consecutive lines.
{warn} This fixer cannot be enabled at the same time as the
align_equals_minimal
orunalign_equals
fixers.
Minimally align equals symbols in consecutive lines.
{warn} This fixer cannot be enabled at the same time as the
align_equals
orunalign_equals
fixers.
Align all multiline comments to match their first line.
{warn} This fixer cannot be enabled at the same time as the
align_comments
fixer.
Structural bodies MUST be enclosed by braces and properly indented. Braces MUST be properly placed, always on the next line.
{warn} This fixer cannot be enabled at the same time as the
laravel_braces
,psr12_braces
,psr2_braces
, orsymfony_braces
fixers.
Import use
statements MUST be sorted alphabetically.
{info} This fixer can also be enabled using its old names of
ordered_imports
orordered_use
.
{warn} This fixer cannot be enabled at the same time as the
length_ordered_imports
fixer.
Trait use
statements MUST be sorted alphabetically.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
Each element of an array must be indented exactly once.
Converts simple usages of array_push($x, $y)
to $x[] = $y
.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
Use the null coalescing assignment operator ??=
where possible.
Converts backtick operators to shell_exec
calls.
Binary operators MUST be surrounded by at least one space.
{warn} This fixer cannot be enabled at the same time as the
binary_operator_exactly_one_space
fixer.
Binary operators MUST be surrounded by at exactly one space.
{info} This fixer can also be enabled using its old names of
binary_operator_spaces
oroperators_spaces
.
{warn} This fixer cannot be enabled at the same time as the
binary_operator_at_least_one_space
fixer.
There MUST be one blank line after the namespace declaration.
{info} This fixer can also be enabled using its old name of
line_after_namespace
.
Ensure there is no code on the same line as the PHP open tag and it is followed by a blank line.
{info} This fixer can also be enabled using its old name of
blankline_after_open_tag
.
An empty line feed MUST precede a break
statement.
An empty line feed MUST precede a case
or default
statement.
An empty line feed MUST precede a continue
statement.
An empty line feed MUST precede a declare
statement.
An empty line feed MUST precede a do
statement.
An empty line feed MUST precede a die
or exit
statement.
An empty line feed MUST precede a for
or foreach
statement.
An empty line feed MUST precede a goto
statement.
An empty line feed MUST precede an if
statement.
An empty line feed MUST precede an include
or require
statement.
An empty line feed MUST precede a return
statement.
{info} This fixer can also be enabled using its old name of
return
.
An empty line feed MUST precede a switch
statement.
An empty line feed MUST precede a throw
statement.
An empty line feed MUST precede a try
statement.
An empty line feed MUST precede a while
statement.
An empty line feed MUST precede a yield
statement.
Putting blank lines between use
statement groups.
Multiline expressions MUST have their boolean operators at the beginning of each line.
{warn} This fixer cannot be enabled at the same time as the
boolean_operator_linebreak_end
,operator_linebreak_beginning
, oroperator_linebreak_end
fixers.
Multiline expressions MUST have their boolean operators at the end of each line.
{warn} This fixer cannot be enabled at the same time as the
boolean_operator_linebreak_beginning
,operator_linebreak_beginning
, oroperator_linebreak_end
fixers.
A single space MUST be between cast and variable.
{info} This fixer can also be enabled using its old name of
spaces_cast
.
Whitespace around the keywords of a class, trait, enum or interfaces definition should be one space.
{warn} This fixer cannot be enabled at the same time as the
psr12_class_definition
orsymfony_class_definition
fixers.
Converts ::class
keywords to FQCN strings.
When referencing an internal class it must be written using the correct casing.
Namespace must not contain spacing, comments or PHPDoc.
Using isset($var) &&
multiple times should be done in one call.
Calling unset
on multiple items should be done in one call.
Replace multiple nested calls of dirname
by only one call with second $level
parameter.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
Comments with annotation should be docblock when used on structural elements.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
Remove extra spaces in a nullable type declaration.
{info} This fixer can also be enabled using its old name of
compact_nullable_typehint
.
Concatenation should be used with at least one whitespace around.
{warn} This fixer cannot be enabled at the same time as the
concat_without_spaces
fixer.
Concatenation should be used without spaces.
{warn} This fixer cannot be enabled at the same time as the
concat_with_spaces
fixer.
Constants MUST be separated with one blank line.
Visibility MUST be declared on all constants.
The first argument of DateTime::createFromFormat
method must start with !
.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
Class DateTimeImmutable
should be used instead of DateTime
.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
Equal sign in declare statement MUST NOT be surrounded by spaces.
Force strict types declaration in all files.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
The error control operator MUST be present on deprecation notices.
{info} This fixer can also be enabled using its old names of
error_suppression
orsilenced_deprecation_error
.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
Converts die
language construct to exit
if possible.
Replaces dirname(__FILE__)
expression with equivalent __DIR__
constant.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
Normalizes Doctrine operator assignment in arrays.
Normalizes Doctrine annotations without arguments.
Doctrine annotations must be indented with four spaces.
Fixes spaces in Doctrine annotations.
Converts echo
language construct to print
if possible.
{warn} This fixer cannot be enabled at the same time as the
print_to_echo
fixer.
The keyword elseif
should be used instead of else if
so that all control keywords look like single words.
Empty loop bodies MUST use braces.
{warn} This fixer cannot be enabled at the same time as the
empty_loop_body_semicolon
fixer.
Empty loop bodies MUST use a semicolon.
{warn} This fixer cannot be enabled at the same time as the
empty_loop_body_braces
fixer.
Empty loop-conditions MUST be expressed as a while loop.
PHP files MUST use only UTF-8 without BOM.
Replace deprecated ereg
regular expression functions with preg
.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
Escape implicit backslashes in strings and heredocs.
Add curly braces to indirect variables to make them clear to understand.
Converts implicit variables into explicit ones in double-quoted strings or heredoc syntax.
Internal classes should be final
.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
All public
methods of abstract
classes should be final
.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
Order the flags in fopen
calls, b
and t
must be last.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
The flags in fopen
calls MUST omit t
.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
Code MUST use either the long <?php ?>
tags or the short-echo <?= ?>
tags.
{info} This fixer can also be enabled using its old name of
short_tag
.
Removes the leading part of fully qualified symbol references if a given symbol is imported or belongs to the current namespace.
Spaces should be properly placed in a function declaration.
Replace core functions calls returning constants with the constants.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
Ensure single space between function's argument and its typehint.
Replace get_class
calls on object variables with class keyword syntax.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
There MUST be group use for the same namespaces.
{warn} This fixer cannot be enabled at the same time as the
psr12_single_import_per_statement
orsingle_import_per_statement
fixers.
Single line comments MUST use double slashes and not a hash.
Heredoc and nowdoc content MUST be properly indented.
Convert heredoc
to nowdoc
where possible.
Function implode
must be called with 2 arguments in the documented order.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
The include
and require
keywords should be followed by exactly one space and then a file path.
Code MUST use the specified indentation style.
{info} This fixer can also be enabled using its old name of
no_tab_indentation
.
Integer literals MUST use the correct case.
Replaces is_null($var)
expression with null === $var
.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
Structural bodies MUST be enclosed by braces and properly indented. Braces MUST be properly placed, allowing empty anonymous classes.
{warn} This fixer cannot be enabled at the same time as the
allman_braces
,psr12_braces
,psr2_braces
, orsymfony_braces
fixers.
All items of the given phpdoc tags MUST be aligned according to Laravel code style rules.
{warn} This fixer cannot be enabled at the same time as the
phpdoc_align
orphpdoc_unalign
fixers.
Annotations of the same type should immediately follow each other, and annotations of different types MUST be separated, @param
and @return
grouped.
{warn} This fixer cannot be enabled at the same time as the
phpdoc_separation
fixer.
Import use
statements MUST be sorted by length.
{warn} This fixer cannot be enabled at the same time as the
alpha_ordered_imports
fixer.
Ensure there is no code on the same line as the PHP open tag.
{info} This fixer can also be enabled using its old name of
newline_after_open_tag
.
Use &&
and ||
logical operators instead of and
and or
.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
Arrays MUST use the long syntax.
{warn} This fixer cannot be enabled at the same time as the
short_array_syntax
fixer.
Destructuring assignment should use the long syntax.
{warn} This fixer cannot be enabled at the same time as the
short_list_syntax
fixer.
Shorthand notation for operators should be used if possible.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
Cast should be written in lower case.
The PHP constants true
, false
, and null
MUST be in lower case.
{warn} This fixer cannot be enabled at the same time as the
uppercase_constants
fixer.
PHP keywords MUST be in lower case.
Class static references self
, static
and parent
MUST be in lower case.
Magic constants should be referred to using the correct casing.
Magic method definitions and calls must be using the correct casing.
Replace non multibyte-safe functions with corresponding mb function.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
In arguments and calls, there MUST be 0 spaces before and 1 space after each comma.
{warn} This fixer cannot be enabled at the same time as the
method_argument_space_strict
ormethod_argument_space_symfony
fixers.
In arguments and calls, there MUST be 0 spaces before and 1 space after each comma, and multiline statements MUST be strictly so.
{warn} This fixer cannot be enabled at the same time as the
method_argument_space
ormethod_argument_space_symfony
fixers.
In arguments and calls, there MUST be 0 spaces before and 1 space after each comma and attributes must be standalone.
{warn} This fixer cannot be enabled at the same time as the
method_argument_space
ormethod_argument_space_strict
fixers.
Method chaining MUST be properly indented. Method chaining with different levels of indentation is not supported.
Methods MUST be separated with one blank line.
Visibility MUST be declared on all methods, with abstract
and final
declared before the visibility, and static
declared after.
{info} This fixer can also be enabled using its old names of
visibility
orvisibility_required
.
Replace strpos()
calls with str_starts_with()
or str_contains()
if possible.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
Replaces intval
, floatval
, doubleval
, strval
and boolval
function calls with according type casting operator.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
The start and end of multiline comments and phpdoc MUST be correctly formatted.
Add leading slash before constant invocation of internal constants.
{warn} This fixer cannot be enabled at the same time as the
native_constant_invocation_strict
fixer.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
Add leading slash before constant invocation of internal constants and remove from non-internal.
{info} This fixer can also be enabled using its old name of
native_constant_invocation_symfony
.
{warn} This fixer cannot be enabled at the same time as the
native_constant_invocation
fixer.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
Function defined by PHP should be called using the correct casing.
Add leading slash before function invocation of internal functions.
{warn} This fixer cannot be enabled at the same time as the
native_function_invocation_strict
ornative_function_invocation_symfony
fixers.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
Add leading slash before function invocation of internal functions and remove from non-internal.
{warn} This fixer cannot be enabled at the same time as the
native_function_invocation
ornative_function_invocation_symfony
fixers.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
Add leading slash before function invocation of optimized functions within namespaces and remove from non-optimized.
{warn} This fixer cannot be enabled at the same time as the
native_function_invocation
ornative_function_invocation_strict
fixers.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
Native type declarations for functions should use the correct case.
{warn} This fixer cannot be enabled at the same time as the
native_type_declaration_casing
fixer.
Native type declarations should be used in the correct case.
{warn} This fixer cannot be enabled at the same time as the
native_function_type_declaration_casing
fixer.
All instances created with new
keyword must (not) be followed by parentheses.
{info} This fixer can also be enabled using its old name of
new_with_braces
.
Ensure that there is a newline and then a semicolin in chained function calls.
{warn} This fixer cannot be enabled at the same time as the
no_multiline_whitespace_before_semicolons
fixer.
Master functions shall be used instead of aliases.
{info} This fixer can also be enabled using its old names of
alias_functions
orjoin_function
.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
Replace control structure alternative syntax to use braces.
There should not be a binary flag before strings.
Removes empty lines following an attribute statement.
There should be no empty lines after class opening brace.
There should not be blank lines between docblock and the documented element.
{info} This fixer can also be enabled using its old name of
no_empty_lines_after_phpdocs
.
Removes empty lines following a return statement.
Removes empty lines following a throw statement.
Removes empty lines around a break statement.
Removes empty lines around a case and default statements.
Removes empty lines around a continue statement.
Removes empty lines around a switch statement.
There should be no blank lines before a namespace declaration.
{warn} This fixer cannot be enabled at the same time as the
single_blank_line_before_namespace
fixer.
Removes empty lines in between import use statements.
{info} This fixer can also be enabled using its old names of
no_blank_lines_between_uses
orremove_lines_between_uses
.
Removes empty lines in between trait use statements.
There must be a comment when fall-through is intentional in a non-empty case body.
The closing ?>
tag MUST be omitted from files containing only PHP.
{info} This fixer can also be enabled using its old name of
php_closing_tag
.
There should not be any empty comments.
There should not be empty PHPDoc blocks.
Removes empty statements such as additional semicolons.
{info} This fixer can also be enabled using its old names of
duplicate_semicolon
orno_duplicate_semicolons
.
Removes extra empty lines inside statements directly wrapped in blocks.
Removes extra consecutive empty lines.
{info} This fixer can also be enabled using its old name of
extra_empty_lines
.
Replace accidental usage of homoglyphs (non ascii characters) in names.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
Remove leading slashes in use
clauses.
{info} This fixer can also be enabled using its old name of
remove_leading_slash_use
.
The namespace declaration line shouldn't contain leading whitespace.
{info} This fixer can also be enabled using its old name of
namespace_no_leading_whitespace
.
Operator =>
should not be surrounded by multi-line whitespaces.
{info} This fixer can also be enabled using its old names of
double_arrow_multiline_whitespaces
ordouble_arrow_no_multiline_whitespace
.
There MUST NOT be a newline before a semicolon.
{info} This fixer can also be enabled using its old name of
multiline_spaces_before_semicolon
.
{warn} This fixer cannot be enabled at the same time as the
newline_before_semicolons_chained
fixer.
There must not be more than one statement per line.
Properties MUST not be explicitly initialized with null
except when they have a type declaration (PHP 7.4).
There MUST NOT be a ?
in the type declaration of a parameter with a null
default.
{warn} This fixer cannot be enabled at the same time as the
nullable_type_declarations
fixer.
Convert PHP4-style constructors to __construct
.
{info} This fixer can also be enabled using its old name of
php4_constructor
.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
Short cast bool
using double exclamation mark should not be used.
{info} This fixer can also be enabled using its old name of
short_bool_cast
.
Replaces short-echo <?=
with long format <?php echo
syntax.
{info} This fixer can also be enabled using its old name of
short_echo_tag
.
Single line comments MUST use double slashes and not asterisk style.
Single-line whitespace before closing semicolon are prohibited.
{info} This fixer can also be enabled using its old name of
spaces_before_semicolon
.
There must be no space around double colons (also called Scope Resolution Operator or Paamayim Nekudotayim).
When making a method or function call, there MUST NOT be a space between the method or function name and the opening parenthesis.
{info} This fixer can also be enabled using its old name of
function_call_space
.
There MUST NOT be spaces between the offset square braces and its contained values.
{info} This fixer can also be enabled using its old name of
no_spaces_inside_ofsset
.
There MUST NOT be a space after the opening parenthesis or before the closing parenthesis.
{info} This fixer can also be enabled using its old name of
parenthesis
.
There MUST NOT be spaces directly outside offset square braces.
{info} This fixer can also be enabled using its old name of
no_spaces_outside_ofsset
.
Replaces superfluous elseif
with if
.
Removes @param
, @return
and @var
tags that do not provide any useful information.
{warn} This fixer cannot be enabled at the same time as the
no_superfluous_phpdoc_tags_strict
orno_superfluous_phpdoc_tags_symfony
fixers.
Removes inheritdoc and @param
, @return
and @var
tags that do not provide any useful information.
{warn} This fixer cannot be enabled at the same time as the
no_superfluous_phpdoc_tags
orno_superfluous_phpdoc_tags_symfony
fixers.
Removes @param
, @return
and @var
tags that do not provide any useful information.
{warn} This fixer cannot be enabled at the same time as the
no_superfluous_phpdoc_tags
orno_superfluous_phpdoc_tags_strict
fixers.
Single-line argument lists MUST NOT have a trailing comma.
{info} This fixer can also be enabled using its old name of
no_trailing_comma_in_singleline_function_call
.
Single-line arrays MUST NOT have a trailing comma.
{info} This fixer can also be enabled using its old name of
single_array_no_trailing_comma
.
Single-line array destructuring parameter lists MUST NOT have a trailing comma.
{info} This fixer can also be enabled using its old names of
list_commas
orno_trailing_comma_in_list_call
.
Single-line group import statements MUST NOT have a trailing comma.
Remove trailing whitespace at the end of non-blank lines.
{info} This fixer can also be enabled using its old name of
trailing_spaces
.
There MUST be no trailing spaces inside comment or PHPDoc.
There must be no trailing whitespace in strings.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
Removes unneeded braces that are superfluous and are not part of a control structure body.
{info} This fixer can also be enabled using its old name of
no_unneeded_curly_braces
.
Removes unneeded parentheses around control statements.
{info} This fixer can also be enabled using its old name of
unneeded_control_parentheses
.
Removes final
from methods where possible.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
Imports should not be aliased as the same name.
In function arguments there must not be arguments with default values before non-default ones.
{info} This fixer can also be enabled using its old name of
method_argument_default_value
.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
Variables must be set null
instead of using (unset)
casting.
Properties should be set to null
instead of using unset
.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
Unused use
statements must be removed.
{info} This fixer can also be enabled using its old name of
unused_use
.
There MUST NOT be unused variables imported by Closures.
There should not be useless concat operations.
There should not be useless else
cases.
There MUST NOT be useless null-safe operators (?->
) used.
There should not be an empty return
statement at the end of a function.
There must be no sprintf
calls with only the first argument.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
In array declaration, there MUST NOT be a whitespace before each comma.
{info} This fixer can also be enabled using its old name of
array_element_no_space_before_comma
.
Remove trailing whitespace at the end of blank lines.
{info} This fixer can also be enabled using its old names of
no_whitespace_in_blank_lines
orwhitespacy_lines
.
Remove Zero-width space (ZWSP), Non-breaking space (NBSP) and other invisible unicode symbols.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
Array index should always be written by using square braces.
Logical NOT operators (!
) should have leading and trailing whitespaces.
{info} This fixer can also be enabled using its old names of
logical_not_operators_with_spaces
ornot_operators_with_space
.
Logical NOT operators (!
) should have one trailing whitespace.
{info} This fixer can also be enabled using its old name of
logical_not_operators_with_successor_space
.
There MUST be a ?
in the type declaration of a parameter with a null
default.
{warn} This fixer cannot be enabled at the same time as the
no_nullable_type_declarations
fixer.
There should not be space before or after object operators ->
and ?->
.
{info} This fixer can also be enabled using its old name of
object_operator
.
Multiline expressions MUST have all their operators at the beginning of each line.
{warn} This fixer cannot be enabled at the same time as the
boolean_operator_linebreak_beginning
,boolean_operator_linebreak_end
, oroperator_linebreak_end
fixers.
Multiline expressions MUST have all their operators at the end of each line.
{warn} This fixer cannot be enabled at the same time as the
boolean_operator_linebreak_beginning
,boolean_operator_linebreak_end
, oroperator_linebreak_beginning
fixers.
Orders the elements of classes/interfaces/traits/enums.
PHPUnit assertion method calls like ->assertSame(true, $foo)
should be written with dedicated method like ->assertTrue($foo)
.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
PHPUnit data providers MUST be static
functions.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
PHPUnit assertions like assertInternalType
, assertFileExists
, should be used over assertTrue
.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
PHPUnit assertions like assertIsArray
should be used over assertInternalType
.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
Usages of ->setExpectedException*
methods MUST be replaced by ->expectException*
methods.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
PHPUnit annotations should be a FQCNs including a root namespace.
All PHPUnit test classes should be marked as internal.
The PHPUnit methods createMock
or createPartialMock
MUST be used instead of legacy variants.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
Usage of PHPUnit's mock e.g. ->will($this->returnValue(..))
MUST be replaced by its shorter equivalent.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
PHPUnit classes MUST be used in namespaced version, e.g. \PHPUnit\Framework\TestCase
instead of \PHPUnit_Framework_TestCase
.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
Usages of @expectedException*
annotations MUST be replaced by ->setExpectedException*
methods.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
@covers
annotations in PHPUnit tests MUST be ordered.
Changes the visibility of the setUp()
and tearDown()
functions of PHPUnit to protected
, to match the PHPUnit TestCase.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
PHPUnit methods like assertSame
should be used instead of assertEquals
.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
Calls to PHPUnit\Framework\TestCase
static methods MUST be of the form $this->
.
{warn} This fixer cannot be enabled at the same time as the
php_unit_test_case_self_method_calls
orphp_unit_test_case_static_method_calls
fixers.
Calls to PHPUnit\Framework\TestCase
static methods MUST be of the form self::
.
{warn} This fixer cannot be enabled at the same time as the
php_unit_test_case_instance_method_calls
orphp_unit_test_case_static_method_calls
fixers.
Calls to PHPUnit\Framework\TestCase
static methods MUST be of the form static::
.
{warn} This fixer cannot be enabled at the same time as the
php_unit_test_case_instance_method_calls
orphp_unit_test_case_self_method_calls
fixers.
Adds a default @coversNothing
annotation to PHPUnit test classes that have no @covers*
annotation.
PHPDoc should contain @param
for all params.
All items of the given phpdoc tags MUST be aligned vertically.
{info} This fixer can also be enabled using its old name of
phpdoc_params
.
{warn} This fixer cannot be enabled at the same time as the
laravel_phpdoc_alignment
orphpdoc_unalign
fixers.
PHPDoc annotation descriptions should not be a sentence.
Docblocks should have the same indentation as the documented subject.
@inheritDoc
and related tags MUST always be written in inline form.
{info} This fixer can also be enabled using its old name of
phpdoc_inline_tag
.
PHPDoc tags written in inline form MUST be normalized.
@link
MUST always be written as @see
.
@access
annotations MUST be omitted from phpdocs.
@return void
and @return null
annotations should be omitted from PHPDoc.
{info} This fixer can also be enabled using its old name of
phpdoc_no_simplified_null_return
.
@package
and @subpackage
annotations MUST be omitted from phpdocs
Classy that does not inherit must not have @inheritdoc
tags.
Annotations in phpdocs MUST be ordered so that @param
annotations come first, then @throws
, then @return
.
{warn} This fixer cannot be enabled at the same time as the
symfony_phpdoc_order
fixer.
Orders all @param
annotations in DocBlocks according to method signature.
@property
tags MUST be used rather than other variants.
@return
annotations for reference to self MUST be normalized.
Scalar types should always be written in the same form. int
not integer
, bool
not boolean
, float
not real
or double
.
Annotations of the same type should immediately follow each other, and annotations of different types MUST be separated.
{warn} This fixer cannot be enabled at the same time as the
laravel_phpdoc_separation
fixer.
Single line @var
PHPDoc should have proper spacing.
The singular @inheritDoc
form should be preferred.
PHPDoc summary should end in either a full stop, exclamation mark, or question mark.
{info} This fixer can also be enabled using its old name of
phpdoc_short_description
.
Docblocks should only be used on structural elements.
PHPDoc should start and end with content, excluding the very first and last line of the docblocks.
Removes extra blank lines after summary and after description in PHPDoc.
@type
MUST always be written as @var
.
{warn} This fixer cannot be enabled at the same time as the
phpdoc_var_to_type
fixer.
The correct case must be used for standard PHP types in PHPDoc.
Moves null
to the end of a phpdoc union type.
{warn} This fixer cannot be enabled at the same time as the
phpdoc_types_order
fixer.
Sorts phpdoc union types alphabetically and moves null
to the end.
{warn} This fixer cannot be enabled at the same time as the
phpdoc_types_null_last
fixer.
All items of the given phpdoc tags MUST be not be aligned.
{warn} This fixer cannot be enabled at the same time as the
laravel_phpdoc_alignment
orphpdoc_align
fixers.
@var
and @type
tags MUST be correctly ordered.
@var
MUST always be written as @type
.
{warn} This fixer cannot be enabled at the same time as the
phpdoc_type_to_var
fixer.
@var
and @type
annotations of classy properties should not contain the name.
Post incrementation/decrementation should be used if possible.
{warn} This fixer cannot be enabled at the same time as the
pre_increment
fixer.
Converts pow
to the **
operator.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
Pre incrementation/decrementation should be used if possible.
{warn} This fixer cannot be enabled at the same time as the
post_increment
fixer.
Converts print language construct to echo if possible.
{warn} This fixer cannot be enabled at the same time as the
echo_to_print
fixer.
Properties MUST be separated with one blank line.
Visibility MUST be declared on all properties, with static
declared after the visibility.
Converts protected
variables and methods to private
where possible.
Structural bodies MUST be enclosed by braces and properly indented. Braces MUST be properly placed, allowing empty anonymous classes.
{info} This fixer can also be enabled using its old name of
braces
.
{warn} This fixer cannot be enabled at the same time as the
allman_braces
,laravel_braces
,psr2_braces
, orsymfony_braces
fixers.
Whitespace around the keywords of a class, trait or interfaces definition should be one space, with a space before parenthesis.
{warn} This fixer cannot be enabled at the same time as the
class_definition
orsymfony_class_definition
fixers.
There MUST be one use keyword per declaration, except when using import groups.
{warn} This fixer cannot be enabled at the same time as the
group_import
orsingle_import_per_statement
fixers.
Structural bodies MUST be enclosed by braces and properly indented. Braces MUST be properly placed.
{warn} This fixer cannot be enabled at the same time as the
allman_braces
,laravel_braces
,psr12_braces
, orsymfony_braces
fixers.
Class names MUST match the file name.
{info} This fixer can also be enabled using its old name of
psr0
.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
Replaces rand
, srand
, getrandmax
functions calls with their mt_*
analogs or random_int
.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
Callables must be called without using call_user_func*
when possible.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
Local, dynamic and directly referenced variables should not be assigned and directly returned by a function or method.
There should be no space before colon and one space after it in return type declaration.
Inside class or interface element self
should be preferred to the class name itself.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
Inside an enum or final
/anonymous class, self
should be preferred over static
.
{info} This fixer can also be enabled using its old name of
final_static_access
.
Instructions must be terminated with a semicolon.
Cast shall be used, not settype
.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
Arrays MUST use the short syntax.
{warn} This fixer cannot be enabled at the same time as the
long_array_syntax
fixer.
Destructuring assignment MUST use the short syntax.
{warn} This fixer cannot be enabled at the same time as the
long_list_syntax
fixer.
Casts (boolean)
, (integer)
, (double)
, (real)
, (float)
, and (binary)
should be replaced with their canonical forms.
Converts explicit variables in double-quoted strings and heredoc syntax from simple to complex format (${
to {$
).
Simplify if
control structures that return the boolean result of their condition.
A return statement wishing to return void
should not return null
.
{info} This fixer can also be enabled using its old name of
empty_return
.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
A PHP file without end tag must always end with a single empty line feed.
{info} This fixer can also be enabled using its old name of
eof_ending
.
There should be exactly one blank line before a namespace declaration.
{warn} This fixer cannot be enabled at the same time as the
no_blank_lines_before_namespace
fixer.
There MUST NOT be more than one property or constant declared per statement.
There MUST be one use keyword per declaration.
{info} This fixer can also be enabled using its old name of
multiple_use
.
{warn} This fixer cannot be enabled at the same time as the
group_import
orpsr12_single_import_per_statement
fixers.
Each namespace use MUST go on its own line and there MUST be one blank line after the use statements block.
Single-line comments must have proper spacing.
Throwing exception must be done in single line.
Convert double quotes to single quotes for simple strings.
There MUST be exactly one space after language constructs.
Each trait use
must be done as single statement.
Remove trailing whitespace after a semicolon.
{info} This fixer can also be enabled using its old name of
spaces_after_semicolon
.
Increment and decrement operators should be used if possible.
Replace all <>
with !=
.
{info} This fixer can also be enabled using its old name of
standardize_not_equal
.
Lambdas not (indirectly) referencing $this
must be declared static
.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
Comparisons should be strict.
{info} This fixer can also be enabled using its old name of
strict
.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
Functions should be used with $strict
param set to true
.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
String tests for empty must be done against ''
, not with strlen
.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
All multi-line strings must use correct line ending.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
A case should be followed by a colon and not a semicolon.
Removes extra spaces between colon and case value.
Switch case must not be ended with continue
but with break
.
Structural bodies MUST be enclosed by braces and properly indented. Braces MUST be properly placed, allowing empty anonymous classes and single-line closures.
{warn} This fixer cannot be enabled at the same time as the
allman_braces
,laravel_braces
,psr12_braces
, orpsr2_braces
fixers.
Whitespace around the keywords of a class, trait or interfaces definition should be one space, with the definition on a single line.
{info} This fixer can also be enabled using its old name of
single_line_class_definition
.
{warn} This fixer cannot be enabled at the same time as the
class_definition
orpsr12_class_definition
fixers.
Annotations in phpdocs MUST be ordered so that @param
annotations come first, then @return
, then @throws
.
{info} This fixer can also be enabled using its old name of
laravel_phpdoc_order
.
{warn} This fixer cannot be enabled at the same time as the
phpdoc_order
fixer.
Standardize spaces around ternary operator.
{info} This fixer can also be enabled using its old name of
ternary_spaces
.
Use the Elvis operator ?:
where possible.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
The null
coalescing operator ??
MUST be used where possible in place of ternary style.
Multiline arrays MUST have a trailing comma.
{info} This fixer can also be enabled using its old name of
multiline_array_trailing_comma
.
Multiline calls MUST have a trailing comma.
Multiline definitions MUST have a trailing comma.
Arrays should be formatted like function/method arguments, without leading or trailing single line space.
Unalign double arrow symbols.
{warn} This fixer cannot be enabled at the same time as the
align_double_arrow
oralign_double_arrow_minimal
fixers.
Unalign equals symbols.
{warn} This fixer cannot be enabled at the same time as the
align_equals
oralign_equals_minimal
fixers.
Unary operators should be placed adjacent to their operands.
{info} This fixer can also be enabled using its old name of
unary_operators_spaces
.
Union type operators must be surrounded be exactly one space.
{warn} This fixer cannot be enabled at the same time as the
union_type_without_spaces
fixer.
Union type operators must be surrounded be no spaces.
{warn} This fixer cannot be enabled at the same time as the
union_type_with_spaces
fixer.
All PHP files MUST use the Unix LF line ending.
{info} This fixer can also be enabled using its old name of
linefeed
.
The PHP constants true
, false
, and null
MUST be in upper case.
{warn} This fixer cannot be enabled at the same time as the
lowercase_constants
fixer.
Anonymous functions with one-liner return statement must use arrow functions.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
Add the void return type to functions with missing or empty return statements.
{danger} This is a "risky" heuristic fixer, and could change code behavior!
In array declaration, there MUST be a whitespace after each comma.
{info} This fixer can also be enabled using its old name of
array_element_white_space_after_comma
.
Boolean comparison expressions MUST be written in the Yoda style.
Please note that much of the content on this page is Copyright (c) 2012-2021 Fabien Potencier and Dariusz Rumiński, licensed under The MIT License.