Lichen Coding Style
Lichens code follows a style similar to that seen for some Perl programs. The original author of Lichen liked this style. The other author didn't complain and just accepted it.
The coding style applies to PHP and JavaScript code written for Lichen.
Identifier names
Identifier names should be in camel case, with the leading letter lowercase.
Examples: processRequest(), $isFooBar, $insanelyLongVariableNameThatDrivesProgrammersBonkers.
The exception is settings or constants, which should be all uppercase, seperated with underscores.
Examples: $SMTP_PORT, $IMAP_SERVER.
Curly Braces
Opening curly braces should be on the end of the line that has the conditional or control structure that starts it.
Example:
if ( $foo ) {
doBar();
}
while ( $baz ) {
doFoo();
}
foreach ( $list as $item ) {
doBaz();
}
Parentheses
All parentheses should have a space between it and the next part of the list. This rule can (and has) in some cases been broken where there are too many parentheses.
Example:
if ( ( $foo == "bar" ) && ( $bar == "foo" ) ) {
}
if ( process( dataSource( $bar ), dataSource( $foo ) ) {
}
Function Prefixes
There are some locations where functions are given a prefix, and underscore, and then the real name of the function.
This is a crude way of giving these functions a different namespace.
Examples: request_getMessage(); render_messageComposer();
PHP specifics
PHP code should avoid the use of die() unless absolutely necessary.
Functional specifics
Whilst not critical, it is not advised to return from a function from anywhere other than the bottom of the function.
In loops, it is not a good idea to use continue and break, if this is possible without ending up with confusing code.
