PHP

From Officience
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.


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
  • Should have unit test with 100% coverage
  • Always commit /Rollback database transaction at the earliest