This rules extends the PSR-1 and the PSR-12.
- Use strict types
- Set line length to 120 characters
- Follow Mozilla coding style for SQL
- Always remove
use
lines with unused classes - Always import classes or their family at the top of the script, under the namespace
- Use
sprintf
instead of concatenation - Try to avoid
else
operator - The ternary operator must be on the same line, or
:
and?
must start on a new line, offset by 1 tab
Follow these rules from symfony coding standarts:
- Place unary operators (
!
,--
,...
) adjacent to the affected variable - Always use identical comparison unless you need type juggling
- Use parentheses when instantiating classes regardless of the number of arguments the constructor has
- Do not use else, elseif, break after if and case conditions which return or throw something
These rules extends Laravel DocBlock style guide:
- Always add a DocBlock for methods and keep it up to date
- DocBlock must contain all exceptions
- Add blank lines around the
use
block of lines
Follow these rules modified based on symfony coding standarts:
- Add a single space after each comma delimiter
- Add a single space around binary operators (
==
,&&
,...
) - Add a comma after each array item in a multi-line array, even after the last one
- Add a blank line before return statements, unless the return is alone inside a statement-group (like an
if
statement) - Use braces to indicate control structure body regardless of the number of statements it contains
- Declare class properties before methods
- Declare public methods first, then protected ones and finally private ones