StyleCI

PHP Fixers

We have many available fixers. Note that while header comment fixing is available in StyleCI, we do not consider it a "fixer" as isn't configured as a fixer. Header comment fixing has it's own dedicated config on the settings page for your repo.

align_comments

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

Align double arrow symbols in consecutive lines.

{warn} This fixer cannot be enabled at the same time as the align_double_arrow_minimal or unalign_double_arrow fixers.

align_double_arrow_minimal

Minimally align double arrow symbols in consecutive lines.

{warn} This fixer cannot be enabled at the same time as the align_double_arrow or unalign_double_arrow fixers.

align_equals

Align equals symbols in consecutive lines.

{warn} This fixer cannot be enabled at the same time as the align_equals_minimal or unalign_equals fixers.

align_equals_minimal

Minimally align equals symbols in consecutive lines.

{warn} This fixer cannot be enabled at the same time as the align_equals or unalign_equals fixers.

align_phpdoc

Align all multiline comments to match their first line.

{warn} This fixer cannot be enabled at the same time as the align_comments fixer.

alpha_ordered_imports

Order import statements alphabetically.

{info} This fixer can also be enabled using its old names of ordered_imports or ordered_use.

{warn} This fixer cannot be enabled at the same time as the length_ordered_imports fixer.

array_indentation

Each element of an array must be indented exactly once.

backtick_to_shell_exec

Converts backtick operators to shell_exec calls.

binary_operator_spaces

Binary operators MUST be surrounded by at exactly one space.

{info} This fixer can also be enabled using its old name of operators_spaces.

blank_line_after_namespace

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.

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.

{info} This fixer can also be enabled using its old name of blankline_after_open_tag.

blank_line_before_break

An empty line feed MUST precede a break.

blank_line_before_continue

An empty line feed MUST precede a continue.

blank_line_before_declare

An empty line feed MUST precede a declare.

blank_line_before_return

An empty line feed MUST precede a return.

{info} This fixer can also be enabled using its old name of return.

blank_line_before_throw

An empty line feed MUST precede a throw.

blank_line_before_try

An empty line feed MUST precede a try.

braces

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

cast_spaces

A single space MUST be between cast and variable.

{info} This fixer can also be enabled using its old name of spaces_cast.

class_definition

Whitespace around the keywords of a class, trait or interfaces definition should be one space.

class_keyword_remove

Converts ::class keywords to FQCN strings.

combine_consecutive_issets

Using isset($var) && multiple times should be done in one call.

combine_consecutive_unsets

Calling unset on multiple items should be done in one call.

comment_to_phpdoc

Comments with annotation should be docblock.

{danger} This is an heuristic fixer, and could change code behavior!

compact_nullable_typehint

Remove extra spaces in a nullable typehint.

concat_with_spaces

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.

concat_without_spaces

Concatenation should be used without spaces.

{warn} This fixer cannot be enabled at the same time as the concat_with_spaces fixer.

const_separation

Constants MUST be separated with one blank line.

const_visibility_required

Visibility MUST be declared on all constants.

date_time_immutable

Class DateTimeImmutable should be used instead of DateTime.

{danger} This is an heuristic fixer, and could change code behavior!

declare_equal_normalize

Equal sign in declare statement MUST NOT be surrounded by spaces.

declare_strict_types

Force strict types declaration in all files.

{danger} This is an heuristic fixer, and could change code behavior!

dir_constant

Replaces dirname(__FILE__) expression with equivalent __DIR__ constant.

{danger} This is an heuristic fixer, and could change code behavior!

doctrine_annotation_array_assignment

Normalizes Doctrine operator assignment in arrays.

doctrine_annotation_braces

Normalizes Doctrine annotations without arguments.

doctrine_annotation_indentation

Doctrine annotations must be indented with four spaces.

doctrine_annotation_spaces

Fixes spaces in Doctrine annotations.

echo_to_print

Converts echo language construct to print if possible.

{warn} This fixer cannot be enabled at the same time as the print_to_echo fixer.

elseif

The keyword elseif should be used instead of else if so that all control keywords look like single words.

encoding

PHP files MUST use only UTF-8 without BOM.

ereg_to_preg

Replace deprecated ereg regular expression functions with preg.

{danger} This is an heuristic fixer, and could change code behavior!

escape_implicit_backslashes

Escape implicit backslashes in strings and heredocs.

explicit_indirect_variable

Add curly braces to indirect variables to make them clear to understand.

explicit_string_variable

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

final_internal_class

Internal classes should be final.

{danger} This is an heuristic fixer, and could change code behavior!

full_opening_tag

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.

fully_qualified_strict_types

Transforms imported FQCN parameters and return types in function arguments to short version.

function_declaration

Spaces should be properly placed in a function declaration.

function_to_constant

Replace core functions calls returning constants with the constants.

{danger} This is an heuristic fixer, and could change code behavior!

function_typehint_space

Add missing space between function's argument and its typehint.

hash_to_slash_comment

Single line comments MUST use double slashes and not a hash.

heredoc_to_nowdoc

Convert heredoc to nowdoc where possible.

include

The include and require keywords should be followed by exactly one space and then a file path.

indentation

Code MUST use the specified indentation style.

{info} This fixer can also be enabled using its old name of no_tab_indentation.

is_null

Replaces is_null($var) expression with null === $var.

{danger} This is an heuristic fixer, and could change code behavior!

length_ordered_imports

Order import statements by length.

{warn} This fixer cannot be enabled at the same time as the alpha_ordered_imports fixer.

linebreak_after_opening_tag

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.

long_array_syntax

Arrays MUST use the long syntax.

{warn} This fixer cannot be enabled at the same time as the short_array_syntax fixer.

long_list_syntax

Destructuring assignment should use the long syntax.

{warn} This fixer cannot be enabled at the same time as the short_list_syntax fixer.

lowercase_cast

Cast should be written in lower case.

lowercase_constants

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.

lowercase_keywords

PHP keywords MUST be in lower case.

magic_constant_casing

Magic constants should be referred to using the correct casing.

mb_str_functions

Replace non multibyte-safe functions with corresponding mb function.

{danger} This is an heuristic fixer, and could change code behavior!

method_argument_space

In method arguments and method calls, there MUST NOT be a space before each comma and there MUST be one space after.

method_chaining_indentation

Method chaining MUST be properly indented. Method chaining with different levels of indentation is not supported.

method_separation

Methods MUST be separated with one blank line.

method_visibility_required

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 or visibility_required.

modernize_types_casting

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

{danger} This is an heuristic fixer, and could change code behavior!

multiline_comment_opening_closing

The start and end of multiline comments and phpdoc MUST be correctly formatted.

native_function_casing

Function defined by PHP should be called using the correct casing.

native_function_invocation

Add leading \ before function invocation of internal function to speed up resolving.

{danger} This is an heuristic fixer, and could change code behavior!

new_with_braces

All instances created with new keyword must be followed by braces.

newline_before_semicolons_chained

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.

no_alias_functions

Master functions shall be used instead of aliases.

{info} This fixer can also be enabled using its old names of alias_functions or join_function.

{danger} This is an heuristic fixer, and could change code behavior!

no_alternative_syntax

Replace control structure alternative syntax to use braces.

no_blank_lines_after_class_opening

There should be no empty lines after class opening brace.

no_blank_lines_after_phpdoc

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.

no_blank_lines_after_return

Removes empty lines following a return statement.

no_blank_lines_after_throw

Removes empty lines following a throw statement.

no_blank_lines_before_namespace

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.

no_blank_lines_between_imports

Removes empty lines inbetween import use statements.

{info} This fixer can also be enabled using its old names of no_blank_lines_between_uses or remove_lines_between_uses.

no_blank_lines_between_traits

Removes empty lines inbetween trait use statements.

no_closing_tag

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.

no_empty_comment

There should not be any empty comments.

no_empty_phpdoc

There should not be empty PHPDoc blocks.

no_empty_statement

Remove useless semicolon statements.

{info} This fixer can also be enabled using its old names of duplicate_semicolon or no_duplicate_semicolons.

no_extra_block_blank_lines

Removes extra empty lines inside statements directly wrapped in blocks.

no_extra_consecutive_blank_lines

Removes extra consecutive empty lines.

{info} This fixer can also be enabled using its old name of extra_empty_lines.

no_homoglyph_names

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

{danger} This is an heuristic fixer, and could change code behavior!

no_leading_import_slash

Remove leading slashes in use clauses.

{info} This fixer can also be enabled using its old name of remove_leading_slash_use.

no_leading_namespace_whitespace

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.

no_multiline_whitespace_around_double_arrow

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 or double_arrow_no_multiline_whitespace.

no_multiline_whitespace_before_semicolons

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.

no_null_property_initialization

Properties MUST not be explicitly initialized with null.

no_php4_constructor

Convert PHP4-style constructors to __construct.

{info} This fixer can also be enabled using its old name of php4_constructor.

{danger} This is an heuristic fixer, and could change code behavior!

no_short_bool_cast

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.

no_short_echo_tag

Replace short-echo <?= with long format <?php echo syntax.

{info} This fixer can also be enabled using its old name of short_echo_tag.

no_singleline_whitespace_before_semicolons

Single-line whitespace before closing semicolon are prohibited.

{info} This fixer can also be enabled using its old name of spaces_before_semicolon.

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.

{info} This fixer can also be enabled using its old name of function_call_space.

no_spaces_inside_offset

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.

no_spaces_inside_parenthesis

There MUST NOT be a space after the opening parenthesis. There MUST NOT be a space before the closing parenthesis.

{info} This fixer can also be enabled using its old name of parenthesis.

no_spaces_outside_offset

There MUST NOT be spaces directly ouside offset square braces.

{info} This fixer can also be enabled using its old name of no_spaces_outside_ofsset.

no_superfluous_elseif

Replaces superfluous elseif with if.

no_trailing_comma_in_list_call

Remove trailing commas in list function calls.

{info} This fixer can also be enabled using its old name of list_commas.

no_trailing_comma_in_singleline_array

PHP single-line arrays should not have trailing comma.

{info} This fixer can also be enabled using its old name of single_array_no_trailing_comma.

no_trailing_whitespace

Remove trailing whitespace at the end of non-blank lines.

{info} This fixer can also be enabled using its old name of trailing_spaces.

no_trailing_whitespace_in_comment

There MUST be no trailing spaces inside comments and phpdocs.

no_unneeded_control_parentheses

Removes unneeded parentheses around control statements.

{info} This fixer can also be enabled using its old name of unneeded_control_parentheses.

no_unneeded_curly_braces

Removes unneeded curly braces that are superfluous and aren't part of a control structure's body.

no_unneeded_final_method

A final class must not have final methods.

no_unreachable_default_argument_value

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 an heuristic fixer, and could change code behavior!

no_unused_imports

Unused use statements must be removed.

{info} This fixer can also be enabled using its old name of unused_use.

no_useless_else

There should not be useless else cases.

no_useless_return

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

no_whitespace_before_comma_in_array

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.

no_whitespace_in_blank_line

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 or whitespacy_lines.

non_printable_character

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

{danger} This is an heuristic fixer, and could change code behavior!

normalize_index_brace

Array index should always be written by using square braces.

not_operator_with_space

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 or not_operators_with_space.

not_operator_with_successor_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.

object_operator_without_whitespace

There should not be space before or after object T_OBJECT_OPERATOR ->.

{info} This fixer can also be enabled using its old name of object_operator.

ordered_class_elements

Orders the elements of classes/interfaces/traits.

php_unit_construct

PHPUnit assertion method calls like "->assertSame(true, $foo)" should be written with dedicated method like "->assertTrue($foo)".

{danger} This is an heuristic fixer, and could change code behavior!

php_unit_dedicate_assert

PHPUnit assertions like "assertInternalType", "assertFileExists", should be used over "assertTrue".

{danger} This is an heuristic fixer, and could change code behavior!

php_unit_expectation

Usages of ->setExpectedException* methods MUST be replaced by ->expectException* methods.

{danger} This is an heuristic fixer, and could change code behavior!

php_unit_fqcn_annotation

PHPUnit annotations should be a FQCNs including a root namespace.

php_unit_mock

The PHPUnit methods createMock or createPartialMock MUST be used instead of legacy variants.

{danger} This is an heuristic fixer, and could change code behavior!

php_unit_namespaced

PHPUnit classes MUST be used in namespaced version, eg \PHPUnit\Framework\TestCase instead of \PHPUnit_Framework_TestCase.

{danger} This is an heuristic fixer, and could change code behavior!

php_unit_no_expectation_annotation

Usages of @expectedException* annotations MUST be replaced by ->setExpectedException* methods.

{danger} This is an heuristic fixer, and could change code behavior!

php_unit_ordered_covers

Order @covers annotation of PHPUnit tests.

php_unit_set_up_tear_down_visibility

Changes the visibility of the setUp and tearDown functions of phpunit to protected, to match the PHPUnit TestCase.

{danger} This is an heuristic fixer, and could change code behavior!

php_unit_strict

PHPUnit methods like assertSame should be used instead of assertEquals.

{danger} This is an heuristic fixer, and could change code behavior!

php_unit_test_class_requires_covers

Adds a default @coversNothing annotation to PHPUnit test classes that have no @covers* annotation.

phpdoc_add_missing_param_annotation

Phpdoc should contain @param for all params.

phpdoc_align

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.

phpdoc_annotation_without_dot

Phpdocs annotation descriptions should not be a sentence.

phpdoc_indent

Docblocks should have the same indentation as the documented subject.

phpdoc_inline_tag

Fix phpdoc inline tags, make inheritdoc always inline.

phpdoc_link_to_see

@link should always be written as @see.

phpdoc_no_access

@access annotations should be omitted from phpdocs.

phpdoc_no_empty_return

@return void and @return null annotations should be omitted from phpdocs.

{info} This fixer can also be enabled using its old name of phpdoc_no_simplified_null_return.

phpdoc_no_package

@package and @subpackage annotations should be omitted from phpdocs

phpdoc_no_useless_inheritdoc

Classy that does not inherit must not have inheritdoc tags.

phpdoc_order

Annotations in phpdocs should be ordered so that param annotations come first, then throws annotations, then return annotations.

phpdoc_property

@property tags should be used rather than other variants.

phpdoc_return_self_reference

@return annotations for reference to self MUST be normalized.

phpdoc_scalar

Scalar types should always be written in the same form. int not integer, bool not boolean, float not real or double.

phpdoc_separation

Annotations of the same type should immediately follow each other, and annotations of different types should be separated.

phpdoc_single_line_var_spacing

Single line @var PHPDoc should have proper spacing.

phpdoc_summary

Phpdocs 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.

phpdoc_to_comment

Docblocks should only be used on structural elements.

phpdoc_trim

Phpdocs should start and end with content, excluding the very first and last line of the docblocks.

phpdoc_type_to_var

@type should always be written as @var.

{warn} This fixer cannot be enabled at the same time as the phpdoc_var_to_type fixer.

phpdoc_types

The correct case must be used for standard PHP types in phpdoc.

phpdoc_types_order

Sorts phpdoc types alphabetically and moves null to the end.

phpdoc_var_to_type

@var should always be written as @type.

{warn} This fixer cannot be enabled at the same time as the phpdoc_type_to_var fixer.

phpdoc_var_without_name

@var and @type annotations should not contain the variable name.

post_increment

Post incrementation/decrementation should be used if possible.

{warn} This fixer cannot be enabled at the same time as the pre_increment fixer.

pow_to_exponentiation

Converts pow to the ** operator.

{danger} This is an heuristic fixer, and could change code behavior!

pre_increment

Pre incrementation/decrementation should be used if possible.

{warn} This fixer cannot be enabled at the same time as the post_increment fixer.

print_to_echo

Converts print language construct to echo if possible.

{warn} This fixer cannot be enabled at the same time as the echo_to_print fixer.

property_separation

Properties MUST be separated with one blank line.

property_visibility_required

Visibility MUST be declared on all properties, with static declared after the visibility.

protected_to_private

Converts protected variables and methods to private where possible.

psr4

Class names should match the file name.

{info} This fixer can also be enabled using its old name of psr0.

{danger} This is an heuristic fixer, and could change code behavior!

random_api_migration

Replaces rand, srand, getrandmax functions calls with their mt_* analogs.

{danger} This is an heuristic fixer, and could change code behavior!

return_type_declaration

There should be no space before colon and one space after it in return type declaration.

self_accessor

Inside class or interface element "self" should be preferred to the class name itself.

{danger} This is an heuristic fixer, and could change code behavior!

semicolon_after_instruction

Instructions must be terminated with a semicolon.

short_array_syntax

Arrays MUST use the short syntax.

{warn} This fixer cannot be enabled at the same time as the long_array_syntax fixer.

short_list_syntax

Destructuring assignment should use the short syntax.

{warn} This fixer cannot be enabled at the same time as the long_list_syntax fixer.

short_scalar_cast

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

silenced_deprecation_error

Ensures deprecation notices are silenced.

{danger} This is an heuristic fixer, and could change code behavior!

simplified_null_return

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 an heuristic fixer, and could change code behavior!

single_blank_line_at_eof

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.

single_blank_line_before_namespace

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.

single_class_element_per_statement

There MUST NOT be more than one property or constant declared per statement.

single_import_per_statement

There MUST be one use keyword per declaration.

{info} This fixer can also be enabled using its old name of multiple_use.

single_line_after_imports

Each namespace use MUST go on its own line and there MUST be one blank line after the use statements block.

single_line_class_definition

Put class declarations on one line.

single_quote

Convert double quotes to single quotes for simple strings.

space_after_semicolon

Fix whitespace after a semicolon.

{info} This fixer can also be enabled using its old name of spaces_after_semicolon.

standardize_increment

Increment and decrement operators should be used if possible.

standardize_not_equals

Replace all <> with !=.

{info} This fixer can also be enabled using its old name of standardize_not_equal.

static_lambda

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

{danger} This is an heuristic fixer, and could change code behavior!

strict_comparison

Comparisons should be strict.

{info} This fixer can also be enabled using its old name of strict.

{danger} This is an heuristic fixer, and could change code behavior!

strict_param

Functions should be used with $strict param set to true.

{danger} This is an heuristic fixer, and could change code behavior!

string_line_ending

All multi-line strings must use correct line ending.

{danger} This is an heuristic fixer, and could change code behavior!

switch_case_semicolon_to_colon

A case should be followed by a colon and not a semicolon.

switch_case_space

Removes extra spaces between colon and case value.

ternary_operator_spaces

Standardize spaces around ternary operator.

{info} This fixer can also be enabled using its old name of ternary_spaces.

ternary_to_null_coalescing

Use null coalescing operator ?? where possible.

trailing_comma_in_multiline_array

PHP multi-line arrays should have a trailing comma.

{info} This fixer can also be enabled using its old name of multiline_array_trailing_comma.

trim_array_spaces

Arrays should be formatted like function/method arguments, without leading or trailing single line space.

unalign_double_arrow

Unalign double arrow symbols.

{warn} This fixer cannot be enabled at the same time as the align_double_arrow or align_double_arrow_minimal fixers.

unalign_equals

Unalign equals symbols.

{warn} This fixer cannot be enabled at the same time as the align_equals or align_equals_minimal fixers.

unary_operator_spaces

Unary operators should be placed adjacent to their operands.

{info} This fixer can also be enabled using its old name of unary_operators_spaces.

unix_line_endings

All PHP files MUST use the Unix LF line ending.

{info} This fixer can also be enabled using its old name of linefeed.

uppercase_constants

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.

void_return

Add the void return type to functions with missing or empty return statements.

{danger} This is an heuristic fixer, and could change code behavior!

whitespace_after_comma_in_array

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.

yoda_style

Boolean comparison expressions MUST be written in the Yoda style.


Please note that much of the content on this page is Copyright (c) 2012-2018 Fabien Potencier and Dariusz Rumiński, licensed under The MIT License.