PHPCS: Zend
Personal documentation for the sniffs available in the PHPCS Zend Coding Standards to help build an own rulesets and search for error explanations.
Generic.Files.LineEndings | [ref]
Unix-style line endings are preferred ("\n" instead of "\r\n").
Generic.Files.LineLength | [ref]
It is recommended to keep lines at approximately 80 characters long for better code readability.
Generic.Functions.FunctionCallArgumentSpacing | [ref]
Function arguments should have one space after a comma, and single spaces surrounding the equals sign for default values.
| Valid: Single spaces after a comma. | Invalid: No spaces after a comma. | 
|---|---|
|  |  | 
| Valid: Single spaces around an equals sign in function declaration. | Invalid: No spaces around an equals sign in function declaration. | 
|---|---|
|  |  | 
Generic.Functions.OpeningFunctionBraceBsdAllman | [ref]
Function declarations follow the "BSD/Allman style". The function brace is on the line following the function declaration and is indented to the same column as the start of the function declaration.
| Valid: brace on next line | Invalid: brace on same line | 
|---|---|
|  |  | 
Generic.PHP.DisallowShortOpenTag | [ref]
Always use <?php ?> to delimit PHP code, not the <? ?> shorthand. This is the most portable way to include PHP code on differing operating systems and setups.
Generic.WhiteSpace.DisallowTabIndent | [ref]
Spaces should be used for indentation instead of tabs.
PEAR.Classes.ClassDeclaration | [ref]
The opening brace of a class must be on the line after the definition by itself.
| Valid: Opening brace on the correct line. | Invalid: Opening brace on same line as declaration. | 
|---|---|
|  |  | 
PEAR.ControlStructures.ControlSignature | [ref]
Control structures should use one space around the parentheses in conditions. The opening brace should be preceded by one space and should be at the end of the line.
| Valid: Correct spacing around the condition. | Invalid: Incorrect spacing around the condition. | 
|---|---|
|  |  | 
| Valid: Correct placement of the opening brace. | Invalid: Incorrect placement of the opening brace on a new line. | 
|---|---|
|  |  | 
PEAR.Functions.FunctionCallSignature | [ref]
Functions should be called with no spaces between the function name, the opening parenthesis, and the first parameter; and no space between the last parameter, the closing parenthesis, and the semicolon.
| Valid: spaces between parameters | Invalid: additional spaces used | 
|---|---|
|  |  | 
PEAR.Functions.ValidDefaultValue | [ref]
Arguments with default values go at the end of the argument list.
| Valid: argument with default value at end of declaration | Invalid: argument with default value at start of declaration | 
|---|---|
|  |  | 
PEAR.WhiteSpace.ScopeClosingBrace | [ref]
Closing braces should be indented at the same level as the beginning of the scope.
| Valid: Consistent indentation level for scope. | Invalid: The ending brace is indented further than the if statement. | 
|---|---|
|  |  | 
Squiz.Functions.GlobalFunction | [ref]
Zend.Debug.CodeAnalyzer | [ref]
PHP Code should pass the zend code analyzer.
| Valid: Valid PHP Code. | Invalid: There is an unused function parameter. | 
|---|---|
|  |  | 
Zend.Files.ClosingTag | [ref]
Files should not have closing php tags.
| Valid: No closing tag at the end of the file. | Invalid: A closing php tag is included at the end of the file. | 
|---|---|
|  |  | 
Zend.NamingConventions.ValidVariableName | [ref]
Variable names should be camelCased with the first letter lowercase. Private and protected member variables should begin with an underscore
| Valid: A multi-word variable uses camel casing. | Invalid: A multi-word variable uses underscores and initial capitalization. | 
|---|---|
|  |  | 
| Valid: A private member variable begins with an underscore. | Invalid: A private member variable does not begin with an underscore. | 
|---|---|
|  |  | 

 Looking For a Developer Who 
Truly Cares About Your Business? 
My team and I provide expert consultations, top-notch coding, and comprehensive audits to elevate your success.
Feedback
How satisfied you are after reading this article?