codeworxtech Coding Standards

by Andy Prevost

Sunday December 31 2023

Starting with releases in 2024, all codeworxtech projects will follow a simple coding standard:

PHP Tags
<?php (preferred) or <?=

Character Encoding
PHP code must use UTF-8 without BOM 
PHP code lines use \n Unix style line endings

Side-Effects
Classes cause no side-effects (no executable code)

Namespace
Namespaces are defined in CamelCase as in:
codeworxtech\PHPMailerPro

Constants
Declared in CAPITAL case as in:
const VERSION = '1.1.0';

Properties
Declared in CamelCase with first letter after $ in lower case (no underscores), as in:
public $thisDate = "":

Methods (class functions)
Declared in CamelCase with first letter Capitalized (no underscores), as in:
public function GetName($param) {

Use of single quote marks and double quote marks

Arrays will use single quote marks as in:
$array['var'] = "test";

Variables and phrases (without embedded double quotes) will use double quote marks as in:
$var = "This is a variable";

Variables and phrases (with embedded double quotes) will use single quote marks as in:
$link = '<img src="assets/mailer/PHPMailerPro_logo.png" width="400" />';

We've been following this coding standard (well, most of it) for years – but some capitalization issues have crept in. We'll fix that in 2024. I understand this may cause some code issues. Sorry in advance.

◀ Previous Next ▶

Post a Comment