Introduction to the

Comment tags play a very important role in code comments, but many students may ignore the role of these tags in normal development, so I specially sort out some commonly used comment tags and show them with pictures and pictures, hoping to help you better understand the role of each comment tag.

Maybe you just need a tag ^_^

Project Address: github.com/yinggaozhen…


@deprecated

Deprecated: a function or member method marked by this will be deprecated in the next release, informing the applicable party that the method is no longer recommended.

Detailed code demo: github.com/yinggaozhen…

grammar

@deprecated [<version>] [<description>]

describe

  • @deprecatedYou can enter a version number. The rules for the version number are the same@version
  • If the marked method is simply obsolete because it has been replaced by another new method, it can be combined@seeTo represent the method being replaced

Effect of label


@inheritdoc

@inheritDoc: inherits the document annotations of the parent class.

Detailed code demo: github.com/yinggaozhen…

grammar

@inheritDoc

describe

  • @inheritDocInherits all document comments from the parent class. The specified field can be overridden after inheritance

Effect of label

1. Direct inheritance

2. Inheritance rewrite


@internal

@internal: Internal class/method marked by this tag. Scope is limited to the current file. External files are not callable.

Detailed code demo: github.com/yinggaozhen…

grammar

@internal [description]

Usage scenarios

This tag is usually used in unit tests. For example, if you define a test class in a unit test, you can add the @internal tag to the test class, so that if someone accidentally references the test class in normal logic, with the help of the IDE, you can immediately get feedback.

Effect of label


@link

@link: This tag will direct you to the specified external jump link.

Detailed code demo: github.com/yinggaozhen…

grammar

@link [URI] [<description>]

describe

This TAB has only 1 jump option

  • @external jump links: Must be satisfiedRFC2396Jump link, for examplegithub.com/yinggaozhen

And @see

@see @link
External links Square root Square root
The internal program Square root X

@see

@see: This TAB will direct you to the specified external jump link/internal program.

Detailed code demo: github.com/yinggaozhen…

grammar

@see [URI | FQSEN] [<description>]

describe

This TAB can have two jump options

  • @external jump links: Must be satisfiedRFC2396Jump link, for examplegithub.com/yinggaozhen
  • @Internal program links: Can jump to specified classes/methods/variables, such as class::method

And @Link

@see @link
External links Square root Square root
The internal program Square root X

@var

@var: Defines a data type.

Detailed code demo: github.com/yinggaozhen…

grammar

@var [Type] [$element_name] [<description>]

List of variables

Variable types instructions
string string
integer/int The number/type int
boolean/bool false/true
float/double Number/floating point number
object Object instance
specifiedType The specified class
mixed Any type
array/specifiedType[] Array that can be specified as an array of the specified type
resource File Resource type
void There is no return value
null
callable An executable callback function
function Methods that are not necessarily executable
self/$this The current instance

Effect of label

There are two ways to implement @var

1. Define a class member variable without specifying a variable name

2. Specify a name for a variable


@throws

Throws an exception to tell the caller that he/she needs to handle the exception.

Detailed code demo: github.com/yinggaozhen…

grammar

@throws [Type] [<description>]

Effect of label


The last

This article is limited, some of the tags are listed here, more tags are available at the following project address

Project Address: github.com/yinggaozhen…

The tabs will be updated from time to time. Welcome to Star & Fork

Your support is my biggest motivation to update ~~