User Login    
 + Register
  • Main navigation
Login
Username:

Password:

Remember me



Lost Password?

Register now!
Who's Online
82 user(s) are online (13 user(s) are browsing XoopsWiki)

Members: 3
Guests: 79

kontrolfreek, ianez, robekras, more...
[Main Page]

Dev:module comment standards

From XOOPS Project

Main Page | Recent changes | Edit this page | Page history | Switch to MediaWiki mode

Printable version | Disclaimers | Privacy policy
Category: Development

Contents

Start Of the Document

/**

* Xoops Module Documentation Quickstart
*
* This file demonstrates the rich information
* that can be included in-code and subsequently
* used to generate documentation for xoops
* modules using phpDocumentor
*
* This is a copy of sample2.php by Greg Beaver of
* php.net and is provided with phpDocumentor package.
*
* @author copy/pasted by fatman < :) >
* @package sample
*/


Add descriptions to included files

/**

* Provide a description of 'include' or 'required'
* and its purpose
*/

include_once 'sample3.php';


Use special declaration for global variables.

/**

* Special global variable declaration DocBlock
* @global integer $GLOBALS['_myvar']
* @name $_myvar
*/

$GLOBALS['_myvar'] = 6;


Use special declaration for Constants.

/**#@+

* Constants
*/

/**

* first constant
*/

define('testing', 6); /**

* second constant
*/

define('anotherconstant', strlen('hello'));

/**#@-*/

Functions or Methods have lots of valuable information you can declare

/**

* A sample function docblock
* @global string document that this function uses $_myvar
* @staticvar integer $staticvar this is what is returned
* @param string $param1 name to declare
* @param string $param2 value of the name
* @return integer
*/

function firstFunc($param1, $param2 = 'optional') {

   static $staticvar = 7;
   global $_myvar;
   return $staticvar;

}


Many special declarations for Classes as well.

/**

* The first example class, this is in the same
* package as declared at the start of file but
* this example has a defined subpackage
* @package sample
* @subpackage classes
*/

class myclass {

   /**
    * A sample private variable, this can be hidden with the --parseprivate
    * option
    * @access private
    * @var integer|string
    */
   var $firstvar = 6;
   /**
    * @link http://www.example.com Example link
    * @see myclass()
    * @uses testing, anotherconstant
    * @var array
    */
   var $secondvar =
       array(
           'stuff' =>
               array(
                   6,
                   17,
                   'armadillo'
               ),
           testing => anotherconstant
       );
   /**
    * Constructor sets up {@link $firstvar}
    */
   function myclass()
   {
       $this->firstvar = 7;
   }
   /**
    * Return a thingie based on $paramie
    * @param boolean $paramie
    * @return integer|babyclass
    */
   function parentfunc($paramie)
   {
       if ($paramie) {
           return 6;
       } else {
           return new babyclass;
       }
   }

}


Here is a child class of the previous example.

/**

* @package sample1
*/

class babyclass extends myclass {

   /**
    * The answer to Life, the Universe and Everything
    * @var integer
    */
   var $secondvar = 42;
   /**
    * Configuration values
    * @var array
    */
   var $thirdvar;
   /**
    * Calls parent constructor, then increments {@link $firstvar}
    */
   function babyclass()
   {
       parent::myclass();
       $this->firstvar++;
   }
   /**
    * This always returns a myclass
    * @param ignored $paramie
    * @return myclass
    */
   function parentfunc($paramie)
   {
       return new myclass;
   }

}


Back to the Main Page

Retrieved from "http://www.xoops.org/modules/mediawiki/index.php/Dev:module_comment_standards"

This page has been accessed 474 times. This page was last modified 02:07, 16 December 2007. Content is available under XOOPS Project.


Developers for Hire
Local Support Sites
Make a donation
Please select an amount to donate


Do you want your username revealed with your donation?
Yes - List me as a Generous Donor
No - List my donation as from an Anonymous Donor


Powered by
XOOPS Code hosted on SourceForge

Powered by PHP



Powered by MySQL

Powered by Smarty

OSI certified

All content on this site is subject to the Creative Commons License
Advertisement