Project

General

Profile

Actions

StandardsNaming » History » Revision 2

« Previous | Revision 2/3 (diff) | Next »
Vasily Bezruchkin, January 30, 2013 07:00


Naming Conventions

Classes

Classes should be given descriptive names. Avoid using abbreviations where possible. Use upper case letters as word separators (CamelCase), lower case for the rest of a word. Don't use underbars.

class Name
{
}

class SomeCompoundName
{
}

Functions and Methods

Functions and methods should be named using the "studly caps" style (also referred to as "bumpy case" or "camel caps"). The initial letter of the name (after the prefix) is lowercase, and each letter that starts a new "word" is capitalized.

Constants

Constants should always be all-uppercase, with underscores to separate words. We highly recommend to use a prefix for the constants. It's a common practice to use IA_ for Subrion CMS project constants.

Note: The true, false and null constants are excepted from the all-uppercase rule, and must always be lowercase.

Global Variables

All the global variables are stored in the $GLOBALS array. All the words in the name are uppercased with underbars as separators. E.g. $GLOBALS['MY_GLOBAL_VAR'].

Hook Names

The name of hooks should be intuitively obvious and should be show where hook is placed.

Recommendation name of hook:

typePartFileWhereWhat
  • type - the type of hook (php | smarty). It could be PHP or SMARTY hook.
  • part - the part of script (front | admin). In what part of script the hook.
  • file - the name of file in where hook is placed.
  • where - the place of any part of file. (after | before).
  • what - the part of file.

Examples:
phpFrontHeaderBeforeListingFieldsDisplay - It is the common PHP hook in the front end and it is placed before listings fields display action.

Updated by Vasily Bezruchkin over 6 years ago · 2 revisions