2 Whitespace
LogMANOriginal edited this page 2018-11-05 13:31:49 +01:00

Add a new line at the end of a file

Each PHP/CSS/HTML file must end with a new line at the end of a file.

Example

Bad

{
    // code here
} // This is the end of the file

Good

{
    // code here
}
// This is the end of the file

Reference: PSR2.Files.EndFileNewline

Do not add a whitespace before a semicolon

A semicolon indicates the end of a line of code. Spaces before the semicolon is unnecessary and must be removed.

Example

Bad

echo 'Hello World!' ;

Good

echo 'Hello World!';

Reference: Squiz.WhiteSpace.SemicolonSpacing

Do not add whitespace at start or end of a file or end of a line

Whitespace at the end of lines or at the start or end of a file is invisible to the reader and absolutely unnecessary. Thus it must be removed.

Reference: Squiz.WhiteSpace.SuperfluousWhitespace