ssb             Thu Aug 16 02:40:22 2001 EDT

  Modified files:              
    /phpdoc/en/pear     standards.xml 
  Log:
  * incorporated Jon's last changes to CODING_STANDARDS
  
  
Index: phpdoc/en/pear/standards.xml
diff -u phpdoc/en/pear/standards.xml:1.8 phpdoc/en/pear/standards.xml:1.9
--- phpdoc/en/pear/standards.xml:1.8    Sat Aug  4 18:20:47 2001
+++ phpdoc/en/pear/standards.xml        Thu Aug 16 02:40:22 2001
@@ -1,4 +1,4 @@
-<!-- $Revision: 1.8 $ -->
+<!-- $Revision: 1.9 $ -->
  <chapter id="pear.standards">
   <title>PEAR Coding Standards</title>
   <note>
@@ -347,15 +347,67 @@
    </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>


Reply via email to