Patch for Updates to "Naming Conventions"
| From: | Chuck Burgess | Date: | Thu, 10 Apr 2008 12:52:57 +0000 |
| Subject: | Patch for Updates to "Naming Conventions" | ||
| Groups: | php.pear.doc | ||
| Request: | Send a blank email to pear-doc+get-10644@lists.php.net to get a copy of this message | ||
### Eclipse Workspace Patch 1.0
#P peardoc
Index: en/chapters/standards.xml
===================================================================
RCS file: /repository/peardoc/en/chapters/standards.xml,v
retrieving revision 1.64
diff -u -r1.64 standards.xml
--- en/chapters/standards.xml 11 Mar 2008 16:31:06 -0000 1.64
+++ en/chapters/standards.xml 10 Apr 2008 12:52:02 -0000
@@ -695,6 +695,32 @@
<sect1 id="standards.naming">
<title>Naming Conventions</title>
<sect2>
+ <title>Global Variables and Functions</title>
+ <para>
+ If your package needs to define global variables, their names
+ 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>
+ <para>
+ Global functions should be named using the <quote>studly caps</quote>
+ style (also referred to as <quote>bumpy case</quote> or <quote>camel
+ caps</quote>). In addition, they should 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 <quote>word</quote> is capitalized. An example:
+ <informaltable>
+ <tgroup cols="1">
+ <tbody>
+ <row>
+ <entry><simpara>XML_RPC_serializeData()</simpara></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+ </sect2>
+ <sect2>
<title>Classes</title>
<para>
Classes should be given descriptive names. Avoid using abbreviations
@@ -716,23 +742,20 @@
</para>
</sect2>
<sect2>
- <title>Functions and Methods</title>
+ <title>Class Variables and Methods</title>
<para>
- Functions and methods should be named using the
- <quote>studly caps</quote> style (also referred to as
- <quote>bumpy case</quote> or <quote>camel caps</quote>).
- 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 <quote>word</quote> is capitalized. Some examples:
+ Class variables (a.k.a properties) and methods should
+ be named using the <quote>studly caps</quote> style (also referred
+ to as <quote>bumpy case</quote> or <quote>camel caps</quote>).
+ Some examples (these would be <quote>public</quote> members):
<informaltable>
- <tgroup cols="4">
+ <tgroup cols="5">
<tbody>
<row>
+ <entry><simpara>$counter</simpara></entry>
<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>
@@ -747,9 +770,9 @@
<tgroup cols="3">
<tbody>
<row>
+ <entry><simpara>$_status</simpara></entry>
<entry><simpara>_sort()</simpara></entry>
<entry><simpara>_initTree()</simpara></entry>
- <entry><simpara>$this->_status</simpara></entry>
</row>
</tbody>
</tgroup>
@@ -780,9 +803,17 @@
<para>
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 <literal>DB::</literal> package all begin with
- <literal>DB_</literal>.
+ of the class/package they are used in. Some examples:
+ <informaltable>
+ <tgroup cols="2">
+ <tbody>
+ <row>
+ <entry><simpara>DB_DATASOURCENAME</simpara></entry>
+ <entry><simpara>SERVICES_AMAZON_S3_LICENSEKEY</simpara></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
<note>
<simpara>
The <literal>true</literal>, <literal>false</literal> and
@@ -792,15 +823,6 @@
</note>
</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>
<sect1 id="standards.file">