- Never ever use tabs to indent, always 4 spaces
- Indent continued lines 4 spaces
- Use spaces around colon in conditions and loops
- Throughout PHP 5
- Zend coding style, strict
- Never change the
memory_limitin the code - Avoid methods with more than 10 lines
- Avoid classes with more than 100 lines
- Avoid methods with more than 4 parameters
- Prefer single quotes for strings
- No short tags
- Use
CamelCasefor classes,smallCamelCasefor variables and methods,SCREAMING_SNAKE_CASEfor constants - Never use
_camelCaseor_snake_casefor variables, not even in templates - Avoid unnecessary
returnandelsestatements - Prefer
array_key_existsoverisset - Prefer
require_onceoverinclude_once - Prefer
implodeover concatenating strings - Prefer colon syntax for conditions and loops within
phtmltemplates:
<ul>
<?php foreach ($items as $item) : ?>
<li><?php echo $item->getName(); ?></li>
<?php endforeach; ?>
</ul>- Use constants when possible
- Avoid unnecessary doc blocks without useful content
- Use exceptions for error handling
- Use type hinting and defaults in method definitions
- Avoid passing by reference