-
Notifications
You must be signed in to change notification settings - Fork 1
Coding Standards
Raymond Feng edited this page Apr 16, 2021
·
4 revisions
Refer to this if you have any specific doubts of coding standards (with reference to PSR-1 and PSR-12): https://www.php-fig.org/psr
-
File names - PascalCase with underscores to separate MVC typing.
An exception for this is controllers, as these double as direct routes (i.e.Blog.phpcontroller class will map toexample.com/blog)
Utils.php
EnrollmentForm.php
// Notice that there is an underscore here, this is to separate out the fact that this class is a model
GoogleSheets_Model.php
- Classes - PascalCase with underscores to separate MVC typing (and matching file name, one class per file)
- Functions - camelCase
- Variables - camelCase
- Constants - UPPER_CASE
NOTE: We will reserve underscores in PHP functions to system functions (like mb_char(...))
/**
* This is a PHPDocs comment (used for documentation).
*
* @param string $customParameter
*
* @return string
*/
public function exampleFunction($customParameter)
{
// This is a comment
$customStringVariable = "Hello, world!";
return $customStringVariable;
}
Each function MUST have a PHPDoc style comment describing what the function does. Sentences should use correct grammar, i.e. full stops in the right places. Parameters and returned variables MUST have specified types.
If you have any doubts around correct usage, refer to older models (like GoogleSheets_Model.php)
This wiki and the README document contains a lot of information, please take your time and read these instructions carefully to understand this project before you begin your development.
