- The first line of all
.phpfiles should be exactly "<?php" - Never use the closing PHP tag (
?>) - Never use PHP short tags
- All files must only use
UTF-8, withoutBOM - Always use UTC timezone to store date and time
- Every
.phplibrary file should contain one class exactly - Every
.phplibrary file should be side effect free
- Singular words (e.g. item, stylesheet, user) should be used throughout files and code instead of plurals
- Avoid Hungarian Notation, where file/variable names that indicate their type
- Limit function length
- Ensure return points are consistent
- A function should only ever do one thing, as indicated by its name
- Functions should either mutate or query the system, never both
- Use camelCase for variable naming
- Never use global variables
- Properties should always be declared
- Variables should always be declared at the top of the block they are used in
- Avoid using
finalkeyword unless necessary - Avoid calling functions in global namespace