PHP Class & Function Comments

If you have seen that some PHP functions and classes are commented at the top, using a format like this:

/**
 *
 * Convert an object to an array
 *
 * @param    object  $object The object to convert
 * @return   array
 *
 */

So you might be interested what is this format of commenting and where can you find some information on it? so here I tell about commenting PHP functions and class in short!

Functions:

/**
 * Does something interesting
 *
 * @param  Place    $where  Where something interesting takes place
 * @param  integer  $repeat How many times something interesting should happen
 * @throws Some_Exception_Class If something interesting cannot happen
 * @return Status
 */

Classes:

/**
 * Short description for class
 *
 * Long description for class (if any)...
 *
 * @copyright  2006 Zend Technologies
 * @license    http://www.zend.com/license/3_0.txt   PHP License 3.0
 * @version    Release: @package_version@
 * @link       http://dev.zend.com/package/PackageName
 * @since      Class available since Release 1.2.0
 */

That’s basically phpDoc syntax.

You can read more here: phpDocumentor

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s