mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
* incorporated Jon's last changes to CODING_STANDARDS
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@55092 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
5be1e3b79e
commit
183674077a
1 changed files with 62 additions and 10 deletions
|
@ -1,4 +1,4 @@
|
|||
<!-- $Revision: 1.8 $ -->
|
||||
<!-- $Revision: 1.9 $ -->
|
||||
<chapter id="pear.standards">
|
||||
<title>PEAR Coding Standards</title>
|
||||
<note>
|
||||
|
@ -347,15 +347,67 @@ T package.xml
|
|||
</para>
|
||||
</sect1>
|
||||
|
||||
<sect1 id="pear.standards.constants">
|
||||
<title>Naming Constants</title>
|
||||
<para>
|
||||
Constants should always be all-uppercase, with underscores to seperate
|
||||
words. Prefix constant names with the name of the class/package
|
||||
they are used in. For example, the constants used by the
|
||||
<literal>DB::</literal> package all begin with
|
||||
"<literal>DB_</literal>".
|
||||
</para>
|
||||
<sect1 id="pear.standards.naming">
|
||||
<title>Naming Conventions</title>
|
||||
<sect2>
|
||||
<title>Functions and Methods</title>
|
||||
<para>
|
||||
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. Some examples:
|
||||
<informaltable>
|
||||
<tgroup cols="3">
|
||||
<tbody>
|
||||
<row>
|
||||
<entry><simpara>connect()</simpara></entry>
|
||||
<entry><simpara>getData()</simpara></entry>
|
||||
<entry><simpara>buildSomeWidget()</simpara></entry>
|
||||
<entry><simpara>XML_RPC_serializeData()</simpara></entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
</para>
|
||||
<para>
|
||||
Private class members (meaning class members that an intented to
|
||||
be used only from within the same class in which they are
|
||||
declared; PHP does not yet support truly-enforceable private
|
||||
namespaces) are preceeded by a single underscore. For example:
|
||||
<informaltable>
|
||||
<tgroup cols="3">
|
||||
<tbody>
|
||||
<row>
|
||||
<entry><simpara>_sort()</simpara></entry>
|
||||
<entry><simpara>_initTree()</simpara></entry>
|
||||
<entry><simpara>$this->_status</simpara></entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
</para>
|
||||
</sect2>
|
||||
<sect2>
|
||||
<title>Constants</title>
|
||||
<para>
|
||||
Constants should always be all-uppercase, with underscores to
|
||||
seperate words. Prefix constant names with the uppercased name
|
||||
of the class/package they are used in. For example, the constants
|
||||
used by the <literal>DB::</literal> package all begin with
|
||||
"<literal>DB_</literal>".
|
||||
</para>
|
||||
</sect2>
|
||||
<sect2>
|
||||
<title>Global Variables</title>
|
||||
<para>
|
||||
If your package needs to define global variables, their name
|
||||
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.
|
||||
</para>
|
||||
</sect2>
|
||||
</sect1>
|
||||
|
||||
</chapter>
|
||||
|
|
Loading…
Reference in a new issue