PHP: Difference between revisions
Jump to navigation
Jump to search
Line 3: | Line 3: | ||
* No deprecated functions | * No deprecated functions | ||
* No dead code | * No dead code | ||
* Check comments for file/class/function, the comments should be clear | |||
* Each function is doing only a single thing | |||
* A method should not be larger than 40 lines of code | |||
* Initialize the variable before using it in a function | |||
* No public class attributes | |||
* Use constants in the left hand side of the comparison | |||
* No mix the php code and template (view). A view should not contain any business logic code | |||
* Use single quote ( ‘ ) for php string without double quote (") | |||
* Always customize a general exception with a custom message | |||
* All the exceptions correctly shows correct / understandable error messages to the user | |||
* Never ever put up the error information of system crash that expose the internal behavior of the system. | |||
* Uniform a coding standard through a project (ex PHP Code Sniffer) | |||
* No magic numbers, should be define as a constant with clear comments | |||
* |
Revision as of 03:59, 4 May 2015
Php Checklist
- No syntax/runtime errors and warnings
- No deprecated functions
- No dead code
- Check comments for file/class/function, the comments should be clear
- Each function is doing only a single thing
- A method should not be larger than 40 lines of code
- Initialize the variable before using it in a function
- No public class attributes
- Use constants in the left hand side of the comparison
- No mix the php code and template (view). A view should not contain any business logic code
- Use single quote ( ‘ ) for php string without double quote (")
- Always customize a general exception with a custom message
- All the exceptions correctly shows correct / understandable error messages to the user
- Never ever put up the error information of system crash that expose the internal behavior of the system.
- Uniform a coding standard through a project (ex PHP Code Sniffer)
- No magic numbers, should be define as a constant with clear comments