|
Classes
Classes should be given descriptive names. Avoid using abbreviations
where possible. Class names should always begin with an uppercase
letter. The Mambo class hierarchy is also reflected in the class name,
each level of the hierarchy separated with a single underscore.
Functions and Methods
Functions and methods should be named using the "studly caps" style
(also referred to as "bumpy case" or "camel caps"). Functions should in
addition have the package name as a prefix, to avoid name collisions
between packages. The initial letter of the name (after the prefix) is
lowercase, and each letter that starts a new "word" is capitalized.
eg.
connect()
getData()
buildSomeWidget()
XML_RPC_serializeData()
Private class members (meaning class members that are intended to
be used only from within the same class in which they are declared; PHP
4 does not support truly-enforceable private namespaces) are preceded
by a single underscore. For example:
_sort()
_initTree()
$this->_status
Note: The following applies to PHP5.
Protected class members (meaning class members that are intended to be used only from within the same class in which they are declared or from subclasses that extend it) are not preceded by a single underscore. For example:
protected $somevar
protected function initTree()
Constants
Constants should always be all-uppercase, with underscores to separate
words. Prefix constant names with the uppercased name of the
class/package they are used in. For example, the constants used by the
DB:: package all begin with DB_.
Note: The true, false and null constants are excepted from the all-uppercase rule, and must always be lowercase.
Global Variables
Global variables should start with a single underscore followed by the
package name and another underscore. For example, the PEAR package uses
a global variable called $_PEAR_destructor_object_list.
Filenames
All documentation files should have the filename extension ".txt" to
make viewing them on Windows systems easier. Also, the filenames for
such files should be all-caps (e.g. README.txt instead of readme.txt)
while the extension itself is all-lowercase (i.e. txt instead of TXT).
Examples: README.txt, INSTALL.txt, TODO.txt, CHANGELOG.txt etc.
|