- Keep it simple, stupid. ( KISS )
- Don't Repeat Yourself ( DRY )
- Single Responsibility Principe ( SRP )
To help following these motto, we enforce the following rules from the Object Calisthenics
- One level of indentation per method
- Do not use the
else
keyword - Do not abbreviate
Other rules are encouraged but not forced upon for simplicity.
Style and indentation should follow the agreed upon PSR's:
- Sublime Text 3
- Install phpcs
composer global require "squizlabs/php_codesniffer=*"
and thensudo ln -s ~/.composer/vendor/bin/phpcs /usr/bin/phpcs
- Install php-cs-fixer
composer global require fabpot/php-cs-fixer @stable
and thensudo ln -s ~/.composer/vendor/bin/php-cs-fixer /usr/bin/php-cs-fixer
- Open the Package Control, install "Phpcs"
- Open its Preference > Package Settings > PHP Code Sniffer > user -settings and set this:
{
"php_cs_fixer_on_save": true,
"php_cs_fixer_executable_path": "php-cs-fixer",
"phpcs_executable_path": "phpcs",
}
- Use
<?= $myVar ?>
to echo a variable. - Do not use curly brakets. Use the Alternative syntax for control structures
- Taxes must be stored as decimal, not float and handled with 4 decimals.
- Always round (taxes, subtotals and totals) to two decimals for display purposes. Use number_format() for pages and round() for API responses.