PHP file comment marks and specification summary

  • 2020-05-16 06:34:54
  • OfStack

PHP comment tag

@access
Use scope: class, function var, define, module
This tag is used to specify access rights for a keyword: private, public, or proteced

@author
Indicate the author

@copyright
Scope of use: class, function, var, define, module, use
Specifying copyright information

@deprecated
Usage: class, function, var, define, module, constent, global, include
Indicates a keyword that is not used or discarded

@example
This tag is used to parse 1 segment of the file and highlight them. Phpdoc will attempt to read the contents of the file from the file path given by the tag

@const
Scope of use: define
Used to specify the constant of define in php

@final
Scope of use: class,function,var
Specifies that the keyword is a final class, method, property, and does not allow derivation or modification.

@filesource
Similar to example, except that this tag will read the contents of the currently parsed php file directly and display it.

@global
Specifies the global variables referenced in this function

@ingore
Used to ignore a specified keyword in a document

@license
Equivalent to the html tag < a > First, URL, and then the content to display
For example, < a href = "http: / / www baidu. com" > baidu < /a >
Can write @ license http: / / www baidu. com baidu

@link
Similar to license
But you can also point to any keyword in the document through link

@name
Specify a single name for the keyword.

@package
Scope of use: page level - > define, function, include
Class level - > class, var, methods
Used to logically group one or more keywords into one group.

@abstrcut
Indicates that the current class is an abstract class

@param
Specify the parameters of a function

@return
Specifies the return pointer of a method or function

@static
Indicates that the custom character is static.

@var
Specify variable type

@version
Specified version information

@todo
Indicate areas that should be improved or are not implemented

@throws
Specifies the error exceptions that this function may throw, and the circumstances in which they occur

Common document markup tags must begin each line with the @ tag. In addition, there is another tag called inline tag, which is represented by {@}, including the following:

{@link}
@ link usage

{@source}
Displays the contents of a function or method

Annotation specifications

a. Comments must be

/**
* comment content
*/

In the form of

b. For functions that reference global variables, you must use the glboal flag.

c. For variables, you must mark their type with var (int,string,bool...).

The d. function must specify its parameters and return values through the param and return tags

e. For keywords that appear twice or more, ingore should be used to ignore the superfluous ones and only keep one

f. Where other functions or classes are called, use link or other tags to link to the appropriate section for easy documentation reading.

g. Use non-documentation comments where necessary to improve code readability.

Be brief and to the point. Use phrases instead of sentences whenever possible.

i. Global variables, static variables, and constants must be marked accordingly

Related articles: