From 5392e05498969eb466170931b6b5ae3ffbf712bc Mon Sep 17 00:00:00 2001 From: Cameron Date: Mon, 25 May 2020 11:50:40 -0700 Subject: [PATCH] Improved example --- e107-Coding-Standard.md | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/e107-Coding-Standard.md b/e107-Coding-Standard.md index f9baad8..5b2c626 100644 --- a/e107-Coding-Standard.md +++ b/e107-Coding-Standard.md @@ -60,17 +60,28 @@ Where numeric values represent a particular status, define a constant for that v ## Classes, Methods and Functions. -Class names must must use **lowercase** and use an **underscore** (_) if necessary. The corresponding file should use the same name and casing. Example: **login_shortcodes.php** - -``` -class login_shortcodes extends e_shortcode -{ - -} -``` +Class names must must use **lowercase** and use an **underscore** (_) if necessary. The corresponding file should use the same name and casing. Method/Function names should use **camelCase** unless they are shortcodes (eg. _sc_news_image()_) or methods within **e_admin_form_ui** in which case they should use **lowercase** to match the database field name. +Example: **myplugin_shortcodes.php** + +``` +class myplugin_shortcodes extends e_shortcode +{ + public function sc_myplugin_field($parm=null) + { + $value = $this->myCustomFunction(); + return $value; + } + + private function myCustomFunction() + { + // .... + } +} +``` + Routines are to be documented at both file and function level using phpDoc syntax. Where appropriate create supplementary pages of general documentation, and document individual variables. When passing more than three or so parameters to a function, consider passing some of them in an array (especially convenient if many are optional) or if within a class, consider using vars.