PHP Code Rules

This doc explains what each PHP Code Rule does. The Code Rules are sorted alphabetically. All Code Rules can have two default values that can be used: - no_apply - To not apply the Code Rule at all - '' - (empty) to use the global Code Rule if used.


Align array elements

Make sure all the array key/value elements are aligned with each other.

Default value: _none_
Possible values: space, tab


Align DocBlock tags

Make sure all the DocBlock @param (and @return) tags are aligned.

Default value: _none_
Possible values: space, double_space, triple_space, quadruple_space, tab


Align variables

Align array index => value pairs.

Default value: _none_
Possible values: space, tab


Closing Newline

Make sure the closing line of a PHP file is consistent.

Default value: _none_
Possible values: add, remove


File closing PHP tag

Make sure all PHP files have a closing PHP tag or force the removal of the file closing PHP tag (default).

Default value: remove
Possible values: remove, add


Control structure parentheses inner whitespace

Make sure all the control structures have consistent whitespace on the inside of the parentheses.

Default value: _none_
Possible values: no_space, whitespace


Whitespace between DocBlock and Function

Make sure all the whitespace between a DocBlock and a function is consistent.

Default value: _none_
Possible values: no_space, newline


Else if whitespace

Make sure that the whitespace between any 'else'~'if' is consistent.

Default value: _none_
Possible values: no_space, whitespace


Exclamation mark whitespace

Make sure all whitespace after a single exclamation mark is consistent

Default value: _none_
Possible values: whitespace, no_space


Force control structure braces

Make sure all control structures ('if', 'while', 'foreach' etc) have braces.

Default value: _none_
Possible values: force


Function arguments separator whitespace

Make sure all the whitespace after a function argument separator is consistent.

Default value: _none_
Possible values: whitespace, no_space


Function parentheses inner whitespace

Make sure all whitespace in the function parentheses is consistent.

Default value: _none_
Possible values: whitespace, no_space


Indentation Whitespace

Make sure all the code indentation whitespace is consistent.

Default value: _none_
Possible values: tab, space


Opening doc asterisk

Make sure the opening DocBlock line has a double asterisk.

Default value: _none_
Possible values: double


PHP tag casing

Make sure all the PHP tags have the same casing.

Default value: _none_
Possible values: lower, upper


PHP Tags

Make sure all the PHP tags are consistent. Either full tags () or short tags ().

Default value: _none_
Possible values: full_php_tags, short_php_tags


Remove double semicolon

Make sure any double semicolons are removed when added unintentionally.

Default value: _none_
Possible values: remove


Remove empty trailing/leading doc lines

Make sure all empty DocBlock lines on the beginning and end are removed.

Default value: _none_
Possible values: remove


Semicolon before closing PHP tag

Make sure there is or is not a semicolon before a closing PHP tag when possible.

Default value: _none_
Possible values: add, remove


Static array index whitespace

Make sure the whitespace for a static array index is consistent.

Default value: _none_
Possible values: no_space, whitespace


String operator whitespace

Make sure all the whitespace around a string operator is consistent.

Default value: _none_
Possible values: whitespace, no_space


Trailing whitespace

Make sure all trailing whitespace is removed from every line.

Default value: _none_
Possible values: remove


true/false casing

Make sure all true/false in the code are cased consistently.

Default value: _none_
Possible values: lower, upper


Type cast casing

Make sure all the type cast casing is consistent.

Default value: _none_
Possible values: lower, upper


Type cast inner whitespace

Make sure all whitespace inside a type cast is consistent.

Default value: _none_
Possible values: whitespace, no_space


Quotes

Make sure all the quotes that are used are consistent.

Default value: _none_
Possible values: single_quotes, double_quotes


Variable array index whitespace

Make sure the whitespace for a variable array index is consistent.

Default value: _none_
Possible values: whitespace, no_space


Whitespace after DocBlock asterisk

Make sure all DocBlock lines have the proper whitespace after the opening asterisk.

Default value: _none_
Possible values: single_space, double_space, tab


Whitespace after else

Make sure all whitespace after a 'else' is consistent (does not apply to 'elseif'.

Default value: _none_
Possible values: space, newline, no_space


Whitespace after function open

Make sure all the whitespace after a opening a new function is consistent.

Default value: _none_
Possible values: newline, no_space


Whitespace after function

Make sure the whitespace after a new function/method declaration is consistent.

Default value: _none_
Possible values: newline, double_newline


Whitespace before control structure brace

Make sure the whitespace before a control structure brace is consistent.

Default value: _none_
Possible values: space, newline, no_space


Whitespace before control structure parentheses

Make sure the whitespace before the control structures parentheses is consistent (including but not limited to 'if, foreach, for, switch').

Default value: _none_
Possible values: no_space, whitespace


Whitespace before DocBlock asterisk

Make sure all DocBlock lines have the proper whitespace indentation.

Default value: _none_
Possible values: space


Whitespace before else

Make sure all whitespace before a 'else' is consistent (does not apply to 'elseif'.

Default value: _none_
Possible values: space, newline, no_space


Whitespace before function brace

Make sure the whitespace before a function brace is consistent.

Default value: _none_
Possible values: space, newline, no_space


Whitespace before function close

Make sure all the whitespace before a function is closed is consistent.

Default value: _none_
Possible values: newline, no_space


Whitespace before function parentheses

Make sure all the whitespace before the function parentheses is consistent.

Default value: _none_
Possible values: no_space, whitespace



Still need help? Get in touch! Last modified on Sunday 11th Feb 2018