Documentation Blocks

All source code files should contain a "file-level" docblock at the top of each file and a "class-level" docblock immediately above each class. The only exception to this rule is where a file contains a single class. In this case only the class docblock is required. Included is a brief example of such docblocks, see the index below for more in-depth examples.

/**
 * @file
 *
 * Short description for file.
 *
 * Long description for file (if any)...
 *
 * @ingroup    GroupName
 * @author     Original Author <author@example.com>
 * @author     Another Author <another@example.com>
 * @copyright  1997-2005 Supernerd, LLC and Contributors
 * @license    http://www.gnu.org/copyleft/gpl.html  GPL License 2 or later
 * @version    CVS: $Id:$
 * @link       http://www.zoopframework.com/
 * @see        zoop::zoop
 * @since      File available since Release 1.2.0
 * @deprecated File deprecated in Release 2.0.0
 */
 
/*
 * Place includes, constant defines and $_GLOBAL settings here.
 * Make sure they have appropriate docblocks to avoid phpDocumentor
 * construing they are documented by the page-level docblock.
 */
 
/**
 * Short description for class.
 *
 * Long description for class (if any)...
 *
 * @ingroup    GroupName
 * @ingroup    AnotherGroup
 * @author     Original Author <author@example.com>
 * @author     Another Author <another@example.com>
 * @copyright  1997-2005 Supernerd, LLC and Contributors
 * @license    http://www.gnu.org/copyleft/gpl.html  GPL License 2 or later
 * @version    CVS: $Id:$
 * @link       http://www.zoopframework.com
 * @see        zoop, zoop::zoop()
 * @since      Class available since Release 1.2.0
 * @deprecated Class deprecated in Release 2.0.0
 */
class foo {
 
    /**
     * Brief method description.
     *
     * Extended description for method (if any)...
     * 
     * @code
     *   //code examples can be added with @ code blocks
     *   $var = fooFunction($arg);
     * @endcode
     *
     * @param mixed $arg1 Argument 1 description.
     * @param mixed $arg3 Argument 2 short description.
     *   Extended description for Argument 2. Perhaps talk about the default value?
     * @access public
     * @return mixed Return value description.
     *   Can also have an extended definition.
     */
    function fooFunction($arg1, $arg2 = 'default') {
        if (condition) {
            statement;
        }
        return $val;
    }
}

Eclipse PDT

Eclipse makes doc blocks really easy to add to your PHP code plus it contains doc block hints to make documentation easier. When you finish a function start typing /** right above your function name and eclipse fills in a lot of information for you.

jmorant@cloud9l... 09 Sep 2008