A summary of phpdocument code annotation specifications

Source: Internet
Author: User
Tags comments define function integer php file php code

1. Install Phpdocumentor (not recommended for command line installation)
Download the latest version of Phpdoc in http://manual.phpdoc.org/
Placed in the Web server directory so that you can access it through the browser
Click the Files button to select a php file or folder to process
You can also omit processing of some files by specifying the file to ignore under this interface.
Then click the Output button to select the location and format of the generated document.
The final click on Create,phpdocumentor will automatically start to generate the document.

2. How to write PHP specification comments
all document tags are preceded by @ at the end of each line. If the mark in the middle of a passage comes out @, the mark will be ignored as plain content.
@access the tag is used to indicate access rights for a keyword: private, public, or proteced use scope: Class,function,var,define,module
@author Specify the author
@copyright Specify copyright information
@const usage: Define used to indicate define constants in PHP
@final Use scope: class,function,var Specifies that the keyword is a final class, method, property, and prohibits derivation and modification.
@global indicate the global variables referenced in this function
@name Specify an alias for the keyword.
@package is used to logically divide one or several keywords into one group.
@abstrcut indicate that the current class is an abstract class
@param indicate the parameters of a function
@return indicate the return value of a method or function
@static indicates that the closed word is static.
@var indicate the type of variable
@version indicate version information
@todo identify areas that should be improved or not implemented
@link can refer to any one of the keywords in the document by link
@ingore used to ignore the specified keyword in the document

Some annotation specifications
A. Annotations must be
/**
* XXXXXXX
*/
The form
B. For functions that reference global variables, you must use the glboal tag.
C. For variables, the type must be marked with VAR (int,string,bool ...). )
D. Functions must indicate their parameters and return values through param and returns tags
E. For the occurrence of two or more than two keywords, to pass Ingore ignored redundant, only one can
F. Where other functions or classes are invoked, link or other tags are linked to the appropriate section to facilitate the reading of documents.
G. Where necessary use of phpdoc annotations (comments before the unrecognized keyword) improves code readability.
H. Descriptive content as concise as possible, using phrases rather than sentences.
I. Global variables, static variables and constants must be indicated with the corresponding markup

Keywords that can be identified by Phpdoc:
Include
Require
Include_once
Require_once
Define
function
Global
Class

3. PHP Code for Specification comments:
<?php
/**
* filename (sample2.php)
*
* Feature description (abbreviated)
*
* @author St Eve * @version 1.0
* @package sample2
*/
/**
* include file
*/
Include_onc E ' sample3.php ';
/**
* Declares global variable
* @global integer $GLOBALS [' _myvar ']
* @name $_myvar
*/
$GLOBALS [' _myvar '] = 6;
/**
* Declare global constants
*/
Define (' NUM ', 6);
/**
* Class name
*
* class function Description
*
* @package sample2
* @subp Ackage classes (if the parent class is added)
*/
class MyClass {
/**
* declares normal variable
*
* @accessprivate
* @var integer|st Ring
*/
var $firstvar = 6;
/**
* Create constructor {@link $firstvar}
*/
Function MyClass () {
$this->fi Rstvar = 7;
}
/**
* Define function
*
Function Description
*
* @global string $_myvar
* @staticvar integer $staticvar
* @param string $param 1
* @param string $param 2
* @return integer|string
*/
Function Firstfunc ($param 1, $param2 = ' optional ') {
static $staticvar = 7;
Global $_myvar;
return $staticvar;
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.