- The first line of all
.php
files 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
.php
library file should contain one class exactly - Every
.php
library 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
final
keyword unless necessary - Avoid calling functions in global namespace