PageRenderTime 58ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/docs/PSR.md

https://github.com/raulduc/phpDocumentor2
Markdown | 2006 lines | 1499 code | 507 blank | 0 comment | 0 complexity | e89569c20aa3b171d38d64b7684debdc MD5 | raw file
Possible License(s): LGPL-3.0

Large files files are truncated, but you can click here to view the full file

  1. PSR-n: PHPDoc
  2. =============
  3. Author(s):
  4. Mike van Riel (@mvriel) <mike.vanriel@naenius.com>
  5. Acknowledgements:
  6. The author(s) wish to thank Chuck Burgess (@ashnazg), Gary Jones (@GaryJ)
  7. and all other people who commented and contributed on various versions of
  8. this proposal.
  9. Obsoletes:
  10. [De-facto PHPDoc Standard][DEFACTO]
  11. ## Table Of Contents
  12. 1. Introduction
  13. 2. Conventions Used In This Document
  14. 3. Definitions
  15. 4. Basic Principles
  16. 5. The PHPDoc Format
  17. 5.1. Short Description
  18. 5.2. Long Description
  19. 5.3. Tags
  20. 5.3.1. Tag Name
  21. 5.3.2. Tag Signature
  22. 5.3.3. Inline PHPDoc
  23. 5.4. Examples
  24. 6. Inheritance
  25. 6.1. Class Or Interface
  26. 6.2. Function Or Method
  27. 6.3. Constant Or Property
  28. 7. Describing hashes
  29. 8. Describing anonymous functions
  30. 8. Tags
  31. 8.1. @api
  32. 8.2. @author
  33. 8.3. @category [deprecated]
  34. 8.4. @copyright
  35. 8.5. @deprecated
  36. 8.6. @example
  37. 8.7. @global
  38. 8.8. @internal
  39. 8.9. @license
  40. 8.10. @link
  41. 8.11. @method
  42. 8.12. @package
  43. 8.13. @param
  44. 8.14. @property
  45. 8.15. @return
  46. 8.16. @see
  47. 8.17. @since
  48. 8.18. @struct
  49. 8.19. @subpackage [deprecated]
  50. 8.20. @throws
  51. 8.21. @todo
  52. 8.22. @type
  53. 8.23. @uses
  54. 8.24. @var [deprecated]
  55. 8.25. @version
  56. Appendix A. Types
  57. Appendix B. Differences Compared With The De-facto PHPDoc Standard
  58. ## 1. Introduction
  59. The main purpose of this PSR is to provide a complete and formal definition of
  60. the PHPDoc standard. This PSR deviates from its predecessor, the de-facto PHPDoc
  61. Standard associated with [phpDocumentor 1.x][PHPDOC.ORG], to provide
  62. support for newer features in the PHP language and to address some of the
  63. shortcomings of its predecessor.
  64. This document SHALL NOT:
  65. * Describe a standard for implementing annotations via PHPDoc. Although it does
  66. offer versatility which makes it possible to create a subsequent PSR based on
  67. current practices. See [chapter 5.3](#53-tags) for more information on this
  68. topic.
  69. * Describe best practices or recommendations for Coding Standards on the
  70. application of the PHPDoc standard. This document is limited to a formal
  71. specification of syntax and intention.
  72. ## 2. Conventions Used In This Document
  73. The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD",
  74. "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be
  75. interpreted as described in [RFC 2119][RFC2119].
  76. ## 3. Definitions
  77. * "PHPDoc" is a section of documentation which provides information on several
  78. aspects of a "Structural Element".
  79. > It is important to note that the PHPDoc and the DocBlock are two separate
  80. > entities. The DocBlock is the combination of a DocComment, which is a type
  81. > of comment, and a PHPDoc entity. It is the PHPDoc entity that contains the
  82. > syntax as described in chapter 5 such as the description and tags.
  83. * "Structural Element" is a collection of Programming Constructs which SHOULD be
  84. preceded by a DocBlock. The collection contains the following constructs:
  85. * namespace
  86. * require(_once)
  87. * include(_once)
  88. * class
  89. * interface
  90. * trait
  91. * function (including methods)
  92. * property
  93. * constant
  94. * variables, both local and global scope.
  95. It is RECOMMENDED to precede a "Structural Element" with a DocBlock with its
  96. definition and not with each usage.
  97. Example:
  98. ```php
  99. /** @type int $int This is a counter. */
  100. $int = 0;
  101. // there should be no docblock here
  102. $int++;
  103. ```
  104. or
  105. ```php
  106. /**
  107. * This class acts as an example on where to position a DocBlock.
  108. */
  109. class Foo
  110. {
  111. /** @type string|null $description Should contain a description */
  112. protected $description = null;
  113. /**
  114. * This method sets a description.
  115. *
  116. * @param string $description A text with a maximum of 80 characters.
  117. *
  118. * @return void
  119. */
  120. public function setDescription($description)
  121. {
  122. // there should be no docblock here
  123. $this->description = $description;
  124. }
  125. }
  126. ```
  127. An example of use that falls beyond the scope of this Standard is to document
  128. the variable in a foreach explicitly; several IDEs use this information to
  129. assist their auto-completion functionality.
  130. This Standard does not cover this specific instance as a `foreach` statement
  131. is not considered to be a "Structural Element" but a Control Flow statement.
  132. ```php
  133. /** @type \Sqlite3 $sqlite */
  134. foreach($connections as $sqlite) {
  135. // there should be no docblock here
  136. $sqlite->open('/my/database/path');
  137. <...>
  138. }
  139. ```
  140. * "DocComment" is a special type of comment which starts with `/**`, ends
  141. with `*/` and may contain any number of lines in between.
  142. When a DocComment spans multiple lines, every line SHOULD start with an
  143. asterisk that is aligned with the first asterisk of the opening clause.
  144. In case a DocComment spans multiple lines then every line should start with
  145. an asterisk (`*`) that is aligned with the first asterisk of the opening
  146. clause.
  147. Single line example:
  148. ```php
  149. /** <...> */
  150. ```
  151. Multiline example:
  152. ```php
  153. /**
  154. * <...>
  155. */
  156. ```
  157. * "DocBlock" is a "DocComment" containing a single "PHPDoc" structure and
  158. represents the basic in-source representation.
  159. * "Tag" is a single piece of meta information regarding a "Structural Element"
  160. or a component thereof.
  161. * "Inline PHPDoc" is a "PHPDoc" that is related to a "Tag" instead of a
  162. "Structural element". It replaces the description part of the "Tag".
  163. * "Type" is the determination of what type of data is associated with an element.
  164. This is commonly used when determining the exact values of arguments, constants,
  165. properties and more.
  166. See Appendix A for more detailed information about types.
  167. * "Semantic Version" refers to the definition as set in the [Semantic Versioning
  168. Specification 2.0.0][SEMVER2].
  169. * "FQSEN" is an abbreviation for Fully Qualified Structural Element Name. This
  170. notation expands on the Fully Qualified Class Name and adds a notation to
  171. identify class/interface/trait members and re-apply the principles of the FQCN
  172. to Interfaces, Traits, Functions and global Constants.
  173. The following notations can be used per type of "Structural Element":
  174. *Namespace*: `\My\Space`
  175. *Function*: `\My\Space\myFunction()`
  176. *Constant*: `\My\Space\MY_CONSTANT`
  177. *Class*: `\My\Space\MyClass`
  178. *Interface*: `\My\Space\MyInterface`
  179. *Trait*: `\My\Space\MyTrait`
  180. *Method*: `\My\Space\MyClass::myMethod()`
  181. *Property*: `\My\Space\MyClass::$my_property`
  182. *Class Constant*: `\My\Space\MyClass::MY_CONSTANT`
  183. * "FQSEN" is short for 'Fully Qualified Structural Element Name'. This is the
  184. unique identifier for each Structural Element and should not occur more than
  185. once in a project.
  186. A FQSEN has the following [ABNF][RFC5234]
  187. definition:
  188. FQSEN = fqnn / fqcn / constant / method / property / function
  189. fqnn = "\" [name] *("\" [name])
  190. fqcn = fqnn "\" name
  191. constant = (fqnn "\" / fqcn "::") name
  192. method = fqcn "::" name "()"
  193. property = fqcn "::$" name
  194. function = fqnn "\" name "()"
  195. name = (ALPHA / "_") *(ALPHA / DIGIT / "_")
  196. Example, namespace:
  197. `\My\Space`
  198. Example, function:
  199. `\My\Space\function()`
  200. Example, constant:
  201. `\My\Space\constant`
  202. Example, trait:
  203. `\My\Space\FactoryTrait`
  204. Example, interface:
  205. `\My\Space\FactoryInterface`
  206. Example, class:
  207. `\My\Space\Factory`
  208. Example, method:
  209. `\My\Space\Factory::method()`
  210. Example, class constant:
  211. `\My\Space\Factory::constant`
  212. ## 4. Basic Principles
  213. * A PHPDoc MUST always be contained in a "DocComment"; the combination of these
  214. two is called a "DocBlock".
  215. * A DocBlock MUST directly precede a "Structural Element"
  216. > An exception to this principle is the File-level DocBlock which MUST be
  217. > placed at the top of a PHP source code file.
  218. ## 5. The PHPDoc Format
  219. The PHPDoc format has the following [ABNF][RFC5234]
  220. definition:
  221. PHPDoc = [short-description] [long-description] [tags]
  222. inline-phpdoc = "{" *SP PHPDoc *SP "}"
  223. short-description = *CHAR ("." 1*CRLF / 2*CRLF)
  224. long-description = 1*(CHAR / inline-tag) 1*CRLF ; any amount of characters
  225. ; with inline tags inside
  226. tags = *(tag 1*CRLF)
  227. inline-tag = "{" tag "}"
  228. tag = "@" tag-name [tag-details]
  229. tag-name = (ALPHA / "\") *(ALPHA / DIGIT / "\" / "-" / "_")
  230. tag-details = *SP (SP tag-description / tag-signature / inline-phpdoc)
  231. tag-description = 1*CHAR
  232. tag-signature = "(" *tag-argument ")"
  233. tag-argument = *SP 1*CHAR [","] *SP
  234. Examples of use are included in chapter 5.4.
  235. ### 5.1. Short Description
  236. A short description MUST contain an abstract of the "Structural Element"
  237. defining the purpose. It is RECOMMENDED for short descriptions to span a single
  238. line or at most two but not more than that.
  239. A short description MUST end with either
  240. * a full stop (.) followed by a line break
  241. * or two sequential line breaks.
  242. If a long description is provided, then it MUST be preceded by a short
  243. description. Otherwise the long description will be considered the short
  244. description, until the stop of the short description is encountered.
  245. Tags do not have to be preceded by a short description but it is RECOMMENDED
  246. to do so.
  247. ### 5.2. Long Description
  248. The long description is OPTIONAL but SHOULD be included when the
  249. "Structural Element", which this DocBlock precedes, contains more operations, or
  250. more complex operations, than can be described in the short description alone.
  251. Any application parsing the long description is RECOMMENDED to support the
  252. Markdown mark-up language for this field so that it is possible for the author
  253. to provide formatting and a clear way of representing code examples.
  254. Common uses for the long description are (amongst others):
  255. * To provide more detail than the short description on what this method does.
  256. * To specify of what child elements an input or output array, or object, is
  257. composed.
  258. * To provide a set of common use cases or scenarios in which the
  259. "Structural Element" may be applied.
  260. ### 5.3. Tags
  261. Tags provide a way for authors to supply concise meta-data regarding the
  262. succeeding "Structural Element". They commonly consist of a name followed by
  263. white-space and a description or Inline PHPDoc.
  264. If a description is provided, it MAY span multiple lines and COULD follow a
  265. strict format dictated by the type of tag, as indicated by its name.
  266. The meta-data supplied by tags could result in a change of actual runtime behaviour
  267. of the succeeding "Structural Element", in which case the term "Annotation" is
  268. commonly used instead of "Tag".
  269. A variation of this is where, instead of a description, a tag-signature is used;
  270. in most cases the tag will in fact be an "Annotation". The tag-signature is
  271. able to provide the annotation with parameters regarding its operation.
  272. If a tag-signature is present then there MUST NOT be a description present in
  273. the same tag.
  274. Annotations will not be described in further detail in this specification as
  275. this falls beyond scope. This specification provides a basis on top of which
  276. annotations may be implemented.
  277. #### 5.3.1. Tag Name
  278. Tag names indicate what type of information is represented by this tag, or in
  279. case of annotations which behaviour must be injected into the succeeding
  280. "Structural Element".
  281. In support of annotations, it is allowable to introduce a set of tags designed
  282. specifically for an individual application or subset of applications (and thus
  283. not covered by this specification).
  284. These tags, or annotations, MUST provide a namespace by either
  285. * prefixing the tag name with a PHP-style namespace, or by
  286. * prefixing the tag name with a single vendor-name followed by a hyphen.
  287. Example of a tag name prefixed with a php-style namespace (the prefixing slash
  288. is OPTIONAL):
  289. ```php
  290. @\Doctrine\Orm\Mapping\Entity()
  291. ```
  292. > *Note*: The PHPDoc Standard DOES NOT make assumptions on the meaning of a tag
  293. > unless specified in this document or subsequent additions or extensions.
  294. >
  295. > This means that you CAN use namespace aliases as long as a prefixing namespace
  296. > element is provided. Thus the following is legal as well:
  297. >
  298. > @Mapping\Entity()
  299. >
  300. > Your own library or application may check for namespace aliases and make a
  301. > FQCN from this; this has no impact on this standard.
  302. > *Important*: Individual Documentation Generation Applications (DGAs) MAY
  303. > interpret namespaces that are registered with that application and apply
  304. > custom behaviour.
  305. Example of a tag name prefixed with a vendor name and hyphen:
  306. ```php
  307. @phpdoc-event transformer.transform.pre
  308. ```
  309. Tag names that are not prefixed with a vendor or namespace MUST be described in
  310. this specification (see chapter 7) and/or any official addendum.
  311. #### 5.3.2. Tag Signature
  312. Tag signatures are commonly used for annotations to supply additional meta-data
  313. specific to the current tag.
  314. The supplied meta-data can influence the behavior of the owning annotation and
  315. as such influence the behavior of the succeeding "Structural Element".
  316. The contents of a signature are to be determined by the tag type (as described
  317. in the tag-name) and fall beyond the scope of this specification. However, a
  318. tag-signature MUST NOT be followed by a description or other form of meta-data.
  319. #### 5.3.3. Inline PHPDoc
  320. Specific Tags MAY have an "Inline PHPDoc" section at the end of the "Tag"
  321. definition. An "Inline PHPDoc" is a "PHPDoc" element enclosed in braces and is
  322. only present at the end of a "Tag" sequence unless specified otherwise in a
  323. "Tag" definition, the "Inline PHPDoc" element MUST replace any description that
  324. COULD have been provided.
  325. An example can be the @method tag. This tag may be augmented using an
  326. "Inline PHPDoc" to provide additional information regarding the parameters,
  327. return value or any other tag supported by functions and methods.
  328. Chapter 5.4 contains an example of use for this construct.
  329. ### 5.4. Examples
  330. The following examples serve to illustrate the basic use of DocBlocks; it is
  331. advised to read through the list of tags in chapter 8.
  332. A complete example could look like the following example:
  333. ```php
  334. /**
  335. * This is a short description.
  336. *
  337. * This is a long description. It may span multiple lines
  338. * or contain 'code' examples using the _Markdown_ markup
  339. * language.
  340. *
  341. * @see Markdown
  342. *
  343. * @param int $parameter1 A parameter description.
  344. * @param \Exception $e Another parameter description.
  345. *
  346. * @\Doctrine\Orm\Mapper\Entity()
  347. *
  348. * @return string
  349. */
  350. function test($parameter1, $e)
  351. {
  352. ...
  353. }
  354. ```
  355. It is also allowed to omit the long description:
  356. ```php
  357. /**
  358. * This is a short description.
  359. *
  360. * @see Markdown
  361. *
  362. * @param int $parameter1 A parameter description.
  363. * @param \Exception $parameter2 Another parameter description.
  364. *
  365. * @\Doctrine\Orm\Mapper\Entity()
  366. *
  367. * @return string
  368. */
  369. function test($parameter1, $parameter2)
  370. {
  371. }
  372. ```
  373. Or even omit the tags section as well (though in the following example is not
  374. encouraged as you are missing information on the parameters and return value):
  375. ```php
  376. /**
  377. * This is a short description.
  378. */
  379. function test($parameter1, $parameter2)
  380. {
  381. }
  382. ```
  383. A DocBlock may also span a single line as shown in the following example.
  384. ```php
  385. /** @type \ArrayObject $array */
  386. public $array = null;
  387. ```
  388. Some tags may even feature an "Inline PHPDoc" as shown in the following example.
  389. ```php
  390. /**
  391. * @method integer MyMagicMethod(string $argument1) {
  392. * This is the short description for MyMagicMethod.
  393. *
  394. * @param string $argument1
  395. *
  396. * @return integer
  397. * }
  398. */
  399. class MyMagicClass
  400. {
  401. ...
  402. }
  403. ```
  404. ## 6. Inheritance
  405. PHPDoc's also have the ability to inherit information when the succeeding
  406. "Structural Element" has a super-element (such as a super-class or a method with
  407. the same name in a super-class or implemented in a super-interface).
  408. Every "Structural Element" MUST inherit the following PHPDoc parts by default:
  409. * [Short description](#51-short-description)
  410. * [Long description](#52-long-description)
  411. * A specific subset of [tags](#53-tags)
  412. * [@version](#724-version)
  413. * [@author](#72-author)
  414. * [@copyright](#74-copyright)
  415. Each specific "Structural Element" MUST also inherit a specialized subset as
  416. defined in the sub-chapters.
  417. The PHPDoc parts MUST NOT be inherited when a replacement is available in the
  418. sub-element. The exception to this rule is when the {@inheritdoc} inline tag is
  419. present in the long description. When present the parser MUST insert the
  420. super-element's long description at the location of the {@inheritdoc} inline
  421. tag, while still including the current element's description.
  422. Inheritance takes place from the root of a class hierarchy graph to its leafs.
  423. This means that anything inherited in the bottom of the tree MUST 'bubble' up to
  424. the top unless overridden.
  425. > Note: a special circumstance here would be when the Long Description must be
  426. > overridden but the Short Description should stay intact. It would be difficult
  427. > for a reader to distinguish which is overridden.
  428. >
  429. > In this case the writer MUST use the {@inheritdoc} inline tag as
  430. > Short Description and override the Long Description with the intended text.
  431. >
  432. > Without the {@inheritdoc} inline tag the reader MUST interpret any text
  433. > as if the Short Description would be overridden and long description MAY
  434. > appear overridden if the block of text contains a Short Description ending
  435. > as defined in the ABNF.
  436. ### 6.1. Class Or Interface
  437. In addition to the inherited descriptions and tags as defined in this chapter's
  438. root, a class or interface MUST inherit the following tags:
  439. * [@package](#712-package)
  440. A class or interface SHOULD inherit the following deprecated tags if supplied:
  441. * [@subpackage](#718-subpackage)
  442. The @subpackage MUST NOT be inherited if the @package annotation of the
  443. super-class (or interface) is not the same as the @package of the child class
  444. (or interface).
  445. Example:
  446. ```php
  447. /**
  448. * @package Framework
  449. * @subpackage Controllers
  450. */
  451. class Framework_ActionController
  452. {
  453. <...>
  454. }
  455. /**
  456. * @package My
  457. *
  458. class My_ActionController extends Framework_ActionController
  459. {
  460. <...>
  461. }
  462. ```
  463. In the example above the My_ActionController MUST NOT inherit the subpackage
  464. _Controllers_.
  465. ### 6.2. Function Or Method
  466. In addition to the inherited descriptions and tags as defined in this chapter's
  467. root, a function or method in a class or interface MUST inherit the following tags:
  468. * [@param](#713-param)
  469. * [@return](#715-return)
  470. * [@throws](#719-throws)
  471. ### 6.3. Constant Or Property
  472. In addition to the inherited descriptions and tags as defined in this chapter's
  473. root, a constant or property in a class MUST inherit the following tags:
  474. * [@type](#721-type)
  475. A constant or property SHOULD inherit the following deprecated tags if supplied:
  476. * [@var](#723-var)
  477. ## 7. Describing hashes
  478. The structure of a hash may be described using an "Inline PHPDoc" as part of a
  479. @type, @param or @return declaration or using the @struct tag in the Class'
  480. DocBlock.
  481. In either case each element of the hash is denoted with a @type declaration in
  482. the "Inline PHPDoc". Using this tag it is possible to indicate type, name and
  483. purpose of the element.
  484. Please note that the variable name part of the @type tag still needs to be
  485. preceded by a dollar sign for readability and parsability of the tag.
  486. Example:
  487. ```php
  488. /**
  489. * Initializes this class with the given options.
  490. *
  491. * @param string[] $options {
  492. * @type boolean $required Whether this element is required
  493. * @type string $label The display name for this element
  494. * }
  495. */
  496. public function __construct(array $options = array())
  497. {
  498. <...>
  499. }
  500. ```
  501. ### As @struct declaration
  502. In some cases a hash should be documented multiple times in the same class. For
  503. these purposes you COULD declare it as a 'virtual' "Structural Element" using
  504. the @struct tag in the declaration of a Class or Interface.
  505. It is RECOMMENDED to use native language constructs in these situations, such as
  506. a class.
  507. Please see the @struct documentation on how to use this tag.
  508. ## 8. Tags
  509. Unless specifically mentioned in the description each tag MAY occur zero or more
  510. times in each "DocBlock".
  511. ### 8.1. @api
  512. The @api tag is used to declare "Structural Elements" as being suitable for
  513. consumption by third parties.
  514. #### Syntax
  515. @api
  516. #### Description
  517. The @api tag represents those "Structural Elements" with a public visibility
  518. which are intended to be the public API components for a library or framework.
  519. Other "Structural Elements" with a public visibility serve to support the
  520. internal structure and are not recommended to be used by the consumer.
  521. The exact meaning of "Structural Elements" tagged with @api MAY differ per
  522. project. It is however RECOMMENDED that all tagged "Structural Elements" SHOULD
  523. NOT change after publication unless the new version is tagged as breaking
  524. Backwards Compatibility.
  525. #### Examples
  526. ```php
  527. /**
  528. * This method will not change until a major release.
  529. *
  530. * @api
  531. *
  532. * @return void
  533. */
  534. function showVersion()
  535. {
  536. <...>
  537. }
  538. ```
  539. ### 8.2. @author
  540. The @author tag is used to document the author of any "Structural Element".
  541. #### Syntax
  542. @author [name] [<email address>]
  543. #### Description
  544. The @author tag can be used to indicate who has created a "Structural Element"
  545. or has made significant modifications to it. This tag MAY also contain an
  546. e-mail address. If an e-mail address is provided it MUST follow
  547. the author's name and be contained in chevrons, or angle brackets, and MUST
  548. adhere to the syntax defined in RFC 2822.
  549. #### Examples
  550. ```php
  551. /**
  552. * @author My Name
  553. * @author My Name <my.name@example.com>
  554. */
  555. ```
  556. ### 8.3. @category [deprecated]
  557. The @category tag is used to organize groups of packages together but is
  558. deprecated in favour of occupying the top-level with the @package tag.
  559. As such, usage of this tag is NOT RECOMMENDED.
  560. #### Syntax
  561. @category [description]
  562. #### Description
  563. The @category tag was meant in the original de-facto Standard to group several
  564. @packages into one category. These categories could then be used to aid
  565. in the generation of API documentation.
  566. This was necessary since the @package tag as defined in the original Standard did
  567. not contain more then one hierarchy level; since this has changed this tag SHOULD
  568. NOT be used.
  569. Please see the documentation for `@package` for details of its usage.
  570. This tag MUST NOT occur more than once in a "DocBlock".
  571. #### Examples
  572. ```php
  573. /**
  574. * Page-Level DocBlock
  575. *
  576. * @category MyCategory
  577. * @package MyPackage
  578. */
  579. ```
  580. ### 8.4. @copyright
  581. The @copyright tag is used to document the copyright information of any
  582. "Structural element".
  583. #### Syntax
  584. @copyright <description>
  585. #### Description
  586. The @copyright tag defines who holds the copyright over the "Structural Element".
  587. The copyright indicated with this tag applies to the "Structural Element" to
  588. which it applies and all child elements unless otherwise noted.
  589. The format of the description if governed by the coding standard of each
  590. individual project. It is RECOMMENDED to mention the year or years which are
  591. covered by this copyright and the organization involved.
  592. #### Examples
  593. ```php
  594. /**
  595. * @copyright 1997-2005 The PHP Group
  596. */
  597. ```
  598. ### 8.5. @deprecated
  599. The @deprecated tag is used to indicate which 'Structural elements' are
  600. deprecated and are to be removed in a future version.
  601. #### Syntax
  602. @deprecated [<"Semantic Version">] [<description>]
  603. #### Description
  604. The @deprecated tag declares that the associated 'Structural elements' will
  605. be removed in a future version as it has become obsolete or its usage is
  606. otherwise not recommended.
  607. This tag MAY also contain a version number up till which it is guaranteed to be
  608. included in the software. Starting with the given version will the function be
  609. removed or may be removed without further notice.
  610. It is RECOMMENDED to provide an additional description stating why the
  611. associated element is deprecated.
  612. If it is superceded by another method it is RECOMMENDED to add a @see tag in the
  613. same 'PHPDoc' pointing to the new element.
  614. #### Examples
  615. ```php
  616. /**
  617. * @deprecated
  618. * @deprecated 1.0.0
  619. * @deprecated No longer used by internal code and not recommended.
  620. * @deprecated 1.0.0 No longer used by internal code and not recommended.
  621. */
  622. ```
  623. ### 8.6. @example
  624. The @example tag is used to link to an external source code file which contains
  625. an example of use for the current "Structural element". An inline variant exists
  626. with which code from an example file can be shown inline with the Long
  627. Description.
  628. #### Syntax
  629. @example [URI] [<description>]
  630. or inline:
  631. {@example [URI] [:<start>..<end>]}
  632. #### Description
  633. The example tag refers to a file containing example code demonstrating the
  634. purpose and use of the current "Structural element". Multiple example tags may
  635. be used per "Structural element" in case several scenarios are described.
  636. The URI provided with the example tag is resolved according to the following
  637. rules:
  638. 1. If a URI is proceeded by a scheme or root folder specifier such as `phar://`,
  639. `http://`, `/` or `C:\` then it is considered to be an absolute path.
  640. 2. If the URI is deemed relative and a location for the example files has been
  641. provided then the path relative to the given location is resolved.
  642. 3. If the previous path was not readable or the user has not provided a path
  643. then the application should try to search for a folder 'examples' in the
  644. same folder as the source file featuring the example tag. If found then an
  645. attempt to resolve the path by combining the relative path given in the
  646. example tag and the found folder should be made.
  647. 4. If the application was unable to resolve a path given the previous rules then
  648. it should check if a readable folder 'examples' is found in the root folder
  649. of the project containing the source file of the "Structural Element".
  650. > The root folder of a project is the highest folder common to all files
  651. > that are being processed by a consuming application.
  652. If a consumer intends to display the contents of the example file then it is
  653. RECOMMENDED to use a syntax highlighting solution to improve user experience.
  654. The rules as described above also apply to the inline tags. The inline tag
  655. has 2 additional parameters with which to limit which lines of code
  656. are shown in the Long Description. Due to this, consuming applications MUST
  657. show the example code in case an inline example tag is used.
  658. The start and end argument may be omitted but the ellipsis should remain in
  659. case either is used to give a clear visual indication. The same rules as
  660. specified with the [substr][PHP_SUBSTR] function of PHP are in effect with
  661. regards to the start and end limit.
  662. > A consuming application MAY choose to support the limit format as used in the
  663. > previous standard but it is deprecated per this PSR.
  664. > The previous syntax was: {@example [URI] [<start>] [<end>]} and did not support
  665. > the same rules as the substr function.
  666. #### Examples
  667. ```php
  668. /**
  669. * Counts the number of items.
  670. * {@example http://example.com/foo-inline.https:2..8}
  671. *
  672. * @example http://example.com/foo.phps
  673. *
  674. * @return integer Indicates the number of items.
  675. */
  676. function count()
  677. {
  678. <...>
  679. }
  680. ```
  681. ### 8.7. @global
  682. TODO: The definition of this item should be discussed and whether it may or
  683. may not be superceded in part or in whole by the @type tag.
  684. The @global tag is used to denote a global variable or its usage.
  685. #### Syntax
  686. @global ["Type"] [name]
  687. @global ["Type"] [description]
  688. #### Description
  689. Since there is no standard way to declare global variables, a @global tag MAY
  690. be used in a DocBlock preceding a global variable's definition. To support
  691. previous usages of @global, there is an alternate syntax that applies to
  692. DocBlocks preceding a function, used to document usage of global
  693. variables. In other words, there are two usages of @global: definition and
  694. usage.
  695. ##### Syntax for the Global's Definition
  696. Only one @global tag MAY be allowed per global variable DocBlock. A global
  697. variable DocBlock MUST be followed by the global variable's definition before
  698. any other element or DocBlock occurs.
  699. The name MUST be the exact name of the global variable as it is declared in
  700. the source.
  701. ##### Syntax for the Global's Usage
  702. The function/method @global syntax MAY be used to document usage of global
  703. variables in a function, and MUST NOT have a $ starting the third word. The
  704. "Type" will be ignored if a match is made between the declared global
  705. variable and a variable documented in the project.
  706. #### Examples
  707. (TODO: Examples for this tag should be added)
  708. ### 8.8. @internal
  709. The @internal tag is used to denote that the associated "Structural Element" is
  710. a structure internal to this application or library. It may also be used inside
  711. a long description to insert a piece of text that is only applicable for
  712. the developers of this software.
  713. #### Syntax
  714. @internal
  715. or inline:
  716. {@internal [description]}}
  717. The inline version of this tag may, contrary to other inline tags, contain
  718. text but also other inline tags. To increase readability and ease parsing
  719. the tag should be terminated with a double closing brace, instead of a single
  720. one.
  721. #### Description
  722. The @internal tag can be used as counterpart of the @api tag, indicating that
  723. the associated "Structural Element" is used purely for the internal workings of
  724. this piece of software.
  725. When generating documentation from PHPDoc comments it is RECOMMENDED to hide the
  726. associated element unless the user has explicitly indicated that internal elements
  727. should be included.
  728. An additional use of @internal is to add internal comments or additional
  729. description text inline to the Long Description. This may be done, for example,
  730. to withhold certain business-critical or confusing information when generating
  731. documentation from the source code of this piece of software.
  732. #### Examples
  733. Mark the count function as being internal to this project:
  734. ```php
  735. /**
  736. * @internal
  737. *
  738. * @return integer Indicates the number of items.
  739. */
  740. function count()
  741. {
  742. <...>
  743. }
  744. /**
  745. * Counts the number of Foo.
  746. *
  747. * {@internal Silently adds one extra Foo to compensate for lack of Foo }}
  748. *
  749. * @return integer Indicates the number of items.
  750. */
  751. function count()
  752. {
  753. <...>
  754. }
  755. ```
  756. ### 8.9. @license
  757. The @license tag is used to indicate which license is applicable for the
  758. associated 'Structural Elements'.
  759. #### Syntax
  760. @license [<url>] [name]
  761. #### Description
  762. The @license tag provides the user with the name and URL of the license that is
  763. applicable to 'Structural Elements' and any of their child elements.
  764. It is NOT RECOMMENDED to apply @license tags to any 'PHPDoc' other than
  765. file-level PHPDocs as this may cause confusion which license applies at which
  766. time.
  767. Whenever multiple licenses apply there MUST be one @license tag per applicable
  768. license.
  769. Instead of providing a URL an identifier as identified in the
  770. [SPDX Open Source License Registry][SPDX] MAY be provided
  771. and this SHOULD be interpreted as if having the URL mentioned in the registry.
  772. #### Examples
  773. ```php
  774. /**
  775. * @license MIT
  776. * @license http://www.spdx.org/licenses/MIT MIT License
  777. */
  778. ```
  779. ### 8.10. @link
  780. The @link tag indicates a custom relation between the associated
  781. "Structural Element" and a website, which is identified by an absolute URI.
  782. #### Syntax
  783. @link [URI] [description]
  784. or inline
  785. @link [URI] [description]
  786. #### Description
  787. The @link tag can be used to define a relation, or link, between the
  788. "Structural Element", or part of the long description when used inline,
  789. to an URI.
  790. The URI MUST be complete and welformed as specified in RFC 2396.
  791. The @link tag MAY have a description appended to indicate the type of relation
  792. defined by this occurrence.
  793. #### Examples
  794. ```php
  795. /**
  796. * @link http://example.com/my/bar Documentation of Foo.
  797. *
  798. * @return integer Indicates the number of items.
  799. */
  800. function count()
  801. {
  802. <...>
  803. }
  804. /**
  805. * This method counts the occurences of Foo.
  806. *
  807. * When no more Foo ({@link http://example.com/my/bar}) are given this
  808. * function will add one as there must always be one Foo.
  809. *
  810. * @return integer Indicates the number of items.
  811. */
  812. function count()
  813. {
  814. <...>
  815. }
  816. ```
  817. ### 8.11. @method
  818. The @method allows a class to know which 'magic' methods are callable.
  819. #### Syntax
  820. @method [return type] [name]([type] [parameter], [...]) [description]
  821. #### Description
  822. The @method tag is used in situation where a class contains the `__call()` magic
  823. method and defines some definite uses.
  824. An example of this is a child class whose parent has a `__call()` to have dynamic
  825. getters or setters for predefined properties. The child knows which getters and
  826. setters need to be present but relies on the parent class to use the `__call()`
  827. method to provide it. In this situation, the child class would have a @method
  828. tag for each magic setter or getter method.
  829. The @method tag allows the author to communicate the type of the arguments and
  830. return value by including those types in the signature.
  831. When the intended method does not have a return value then the return type MAY
  832. be omitted; in which case 'void' is implied.
  833. @method tags MUST NOT be used in a PHPDoc that is not associated with a
  834. *class* or *interface*.
  835. #### Examples
  836. ```php
  837. class Parent
  838. {
  839. public function __call()
  840. {
  841. <...>
  842. }
  843. }
  844. /**
  845. * @method string getString()
  846. * @method void setInteger(integer $integer)
  847. * @method setString(integer $integer)
  848. */
  849. class Child extends Parent
  850. {
  851. <...>
  852. }
  853. ```
  854. ### 8.12. @package
  855. The @package tag is used to categorize "Structural Elements" into logical
  856. subdivisions.
  857. #### Syntax
  858. @package [level 1]\[level 2]\[etc.]
  859. #### Description
  860. The @package tag can be used as a counterpart or supplement to Namespaces.
  861. Namespaces provide a functional subdivision of "Structural Elements" where the
  862. @package tag can provide a *logical* subdivision in which way the elements can
  863. be grouped with a different hierarchy.
  864. If, across the board, both logical and functional subdivisions are equal is
  865. it NOT RECOMMENDED to use the @package tag, to prevent maintenance overhead.
  866. Each level in the logical hierarchy MUST separated with a backslash (`\`) to
  867. be familiar to Namespaces. A hierarchy MAY be of endless depth but it is
  868. RECOMMENDED to keep the depth at less or equal than six levels.
  869. Please note that the @package applies to different "Structural Elements"
  870. depending where it is defined.
  871. 1. If the @package is defined in the *file-level* DocBlock then it only applies
  872. to the following elements in the applicable file:
  873. * global functions
  874. * global constants
  875. * global variables
  876. * requires and includes
  877. 2. If the @package is defined in a *namespace-level* or *class-level* DocBlock
  878. then the package applies to that namespace, class or interface and their
  879. contained elements.
  880. This means that a function which is contained in a namespace with the
  881. @package tag assumes that package.
  882. This tag MUST NOT occur more than once in a "DocBlock".
  883. #### Examples
  884. ```php
  885. /**
  886. * @package PSR\Documentation\API
  887. */
  888. ```
  889. ### 8.13. @param
  890. The @param tag is used to document a single parameter of a function or method.
  891. #### Syntax
  892. @param ["Type"] [name] [<description>]
  893. #### Description
  894. With the @param tag it is possible to document the type and function of a
  895. single parameter of a function or method. When provided it MUST contain a
  896. "Type" to indicate what is expected; the description on the other hand is
  897. OPTIONAL yet RECOMMENDED. For complex structures such as option arrays it is
  898. RECOMMENDED to use an "Inline PHPDoc" to describe the option array.
  899. The @param tag MAY have a multi-line description and does not need explicit
  900. delimiting.
  901. It is RECOMMENDED when documenting to use this tag with every function and
  902. method. Exceptions to this recommendation are:
  903. This tag MUST NOT occur more than once per parameter in a "PHPDoc" and is
  904. limited to "Structural Elements" of type method or function.
  905. #### Examples
  906. ```php
  907. /**
  908. * Counts the number of items in the provided array.
  909. *
  910. * @param mixed[] $array Array structure to count the elements of.
  911. *
  912. * @return int Returns the number of elements.
  913. */
  914. function count(array $items)
  915. {
  916. <...>
  917. }
  918. ```
  919. The following example demonstrates the use of an "Inline PHPDoc" to document
  920. an option array with 2 elements: 'required' and 'label'.
  921. ```php
  922. /**
  923. * Initializes this class with the given options.
  924. *
  925. * @param string[] $options {
  926. * @type boolean $required Whether this element is required
  927. * @type string $label The display name for this element
  928. * }
  929. */
  930. public function __construct(array $options = array())
  931. {
  932. <...>
  933. }
  934. ```
  935. ### 8.14. @property
  936. The @property tag allows a class to know which 'magic' properties are present.
  937. #### Syntax
  938. @property ["Type"] [name] [<description>]
  939. #### Description
  940. The @property tag is used in the situation where a class contains the
  941. `__get()` and `__set()` magic methods and allows for specific names.
  942. An example of this is a child class whose parent has a `__get()`. The child
  943. knows which properties need to be present but relies on the parent class to use the
  944. `__get()` method to provide it.
  945. In this situation, the child class would have a @property tag for each magic
  946. property.
  947. @property tags MUST NOT be used in a "PHPDoc" that is not associated with
  948. a *class* or *interface*.
  949. #### Examples
  950. ```php
  951. class Parent
  952. {
  953. public function __get()
  954. {
  955. <...>
  956. }
  957. }
  958. /**
  959. * @property string $myProperty
  960. */
  961. class Child extends Parent
  962. {
  963. <...>
  964. }
  965. ```
  966. ### 8.15. @return
  967. The @return tag is used to document the return value of functions or methods.
  968. #### Syntax
  969. @return <"Type"> [description]
  970. #### Description
  971. With the @return tag it is possible to document the return type of a
  972. function or method. When provided, it MUST contain a "Type" (See Appendix A)
  973. to indicate what is returned; the description on the other hand is OPTIONAL yet
  974. RECOMMENDED in case of complicated return structures, such as associative arrays.
  975. The @return tag MAY have a multi-line description and does not need explicit
  976. delimiting.
  977. It is RECOMMENDED to use this tag with every function and method.
  978. Exceptions to this recommendation are:
  979. 1. **constructors**: the @return tag MAY be omitted here, in which case an
  980. interpreter MUST interpret this as if `@return self` is provided.
  981. 2. **functions and methods without a `return` value**: the @return tag MAY be
  982. omitted here, in which case an interpreter MUST interpret this as if
  983. `@return void` is provided.
  984. This tag MUST NOT occur more than once in a "DocBlock" and is limited to the
  985. "DocBlock" of a "Structural Element" of a method or function.
  986. #### Examples
  987. ```php
  988. /**
  989. * @return integer Indicates the number of items.
  990. */
  991. function count()
  992. {
  993. <...>
  994. }
  995. /**
  996. * @return string|null The label's text or null if none provided.
  997. */
  998. function getLabel()
  999. {
  1000. <...>
  1001. }
  1002. ```
  1003. ### 8.16. @see
  1004. The @see tag indicates a reference from the associated "Structural Elements" to
  1005. a website or other "Structural Elements".
  1006. #### Syntax
  1007. @see [URI | "FQSEN"] [<:type:>] [<description>]
  1008. #### Description
  1009. The @see tag can be used to define a reference to other
  1010. "Structural Elements" or to an URI.
  1011. When defining a reference to another "Structural Elements" you can refer to a
  1012. specific element by appending a double colon and providing the name of that
  1013. element (also called the "FQSEN").
  1014. A URI MUST be complete and well-formed as specified in [RFC 2396][RFC2396].
  1015. The type of reference MAY be provided after the URI or FQSEN by mentioning a
  1016. string wrapped in colons that defines the type of relation.
  1017. (TODO: where do we keep a list of recommended relation types? here? separate
  1018. RFC (my preference) or somewhere on the internet?)
  1019. The @see tag SHOULD have a description appended to provide additional
  1020. information regarding the relationship between the 2 elements.
  1021. #### Examples
  1022. ```php
  1023. /**
  1024. * @see number_of() :alias:
  1025. * @see MyClass::$items For the property whose items are counted.
  1026. * @see MyClass::setItems() To set the items for this collection.
  1027. * @see http://example.com/my/bar Documentation of Foo.
  1028. *
  1029. * @return integer Indicates the number of items.
  1030. */
  1031. function count()
  1032. {
  1033. <...>
  1034. }
  1035. ```
  1036. ### 8.17. @since
  1037. The @since tag is used to denote _when_ an element was introduced or modified,
  1038. using some description of "versioning" to that element.
  1039. #### Syntax
  1040. @since [<"Semantic Version">] [<description>]
  1041. #### Description
  1042. Documents the "version" of the introduction or modification of any element.
  1043. It is RECOMMENDED that the version matches a semantic version number (x.x.x)
  1044. and MAY have a description to provide additional information.
  1045. This information can be used to generate a set of API Documentation where the
  1046. consumer is informed which application version is necessary for a specific
  1047. element.
  1048. The @since tag SHOULD NOT be used to show the current version of an element, the
  1049. @version tag MAY be used for that purpose.
  1050. #### Examples
  1051. ```php
  1052. /**
  1053. * This is Foo
  1054. * @version MyApp 2.1.7
  1055. * @since 2.0.0 introduced
  1056. */
  1057. class Foo
  1058. {
  1059. /**
  1060. * Make a bar.
  1061. *
  1062. * @since 2.1.5 bar($arg1 = '', $arg2 = null)
  1063. * introduced the optional $arg2
  1064. * @since 2.1.0 bar($arg1 = '')
  1065. * introduced the optional $arg1
  1066. * @since 2.0.0 bar()
  1067. * introduced new method bar()
  1068. */
  1069. public function bar($arg1 = '', $arg2 = null)
  1070. {
  1071. <...>
  1072. }
  1073. }
  1074. ```
  1075. ### 8.18. @struct
  1076. TODO: specify details
  1077. TODO: determine whether this is a correct approach
  1078. ### 8.19. @subpackage [deprecated]
  1079. The @subpackage tag is used to categorize "Structural Elements" into logical
  1080. subdivisions.
  1081. #### Syntax
  1082. @subpackage [name]
  1083. #### Description
  1084. The @subpackage tag MAY be used as a counterpart or supplement to Namespaces.
  1085. Namespaces provide a functional subdivision of "Structural Elements" where
  1086. the @subpackage tag can provide a *logical* subdivision in which way the
  1087. elements can be grouped with a different hierarchy.
  1088. If, across the board, both logical and functional subdivisions are equal is it
  1089. NOT RECOMMENDED to use the @subpackage tag, to prevent maintenance overhead.
  1090. The @subpackage tag MUST only be used in a specific series of DocBlocks, as is
  1091. described in the documentation for the @package tag.
  1092. This tag MUST accompany a @package tag and MUST NOT occur more than once per
  1093. DocBlock.
  1094. #### Examples
  1095. ```php
  1096. /**
  1097. * @package PSR
  1098. * @subpackage Documentation\API
  1099. */
  1100. ```
  1101. ### 8.20. @throws
  1102. The @throws tag is used to indicate whether "Structural Elements" throw a
  1103. specific type of exception.
  1104. #### Syntax
  1105. @throws ["Type"] [<description>]
  1106. #### Description
  1107. The @throws tag MAY be used to indicate that "Structural Elements" throw a
  1108. specific type of error.
  1109. The type provided with this tag MUST represent an object of the class Exception
  1110. or any subclass thereof.
  1111. This tag is used to present in your documentation which error COULD occur and
  1112. under which circumstances. It is RECOMMENDED to provide a description that
  1113. describes the reason an exception is thrown.
  1114. It is also RECOMMENDED that this tag occurs for every occurrence of an
  1115. exception, even if it has the same type. By documenting every occurrence a
  1116. detailed view is created and the consumer knows for which errors to check.
  1117. #### Examples
  1118. ```php
  1119. /**
  1120. * Counts the number of items in the provided array.
  1121. *
  1122. * @param mixed[] $array Array structure to count the elements of.
  1123. *
  1124. * @throws InvalidArgumentException if the provided argument is not of type
  1125. * 'array'.
  1126. *
  1127. * @return int Returns the number of elements.
  1128. */
  1129. function count($items)
  1130. {
  1131. <...>
  1132. }
  1133. ```
  1134. ### 8.21. @todo
  1135. The @todo tag is used to indicate whether any development activities should
  1136. still be executed on associated "Structural Elements".
  1137. #### Syntax
  1138. @todo [description]
  1139. #### Description
  1140. The @todo tag is used to indicate that an activity surrounding the associated
  1141. "Structural Elements" must still occur. Each tag MUST be accompanied by
  1142. a description that communicates the intent of the original author; this could
  1143. however be as short as providing an issue number.
  1144. #### Examples
  1145. ```php
  1146. /**
  1147. * Counts the number of items in the provided array.
  1148. *
  1149. * @todo add an array parameter to count
  1150. *
  1151. * @return int Returns the number of elements.
  1152. */
  1153. function count()
  1154. {
  1155. <...>
  1156. }
  1157. ```
  1158. ### 8.22. @type
  1159. You may use the @type tag to document the "Type" of the following
  1160. "Structural Elements":
  1161. * Constants, both class and global
  1162. * Properties
  1163. * Variables, both global and local scope
  1164. #### Syntax
  1165. @type ["Type"] [element_name] [<description>]
  1166. #### Description
  1167. The @type tag is the successor of the @var tag and serves the purpose of defining
  1168. which type of data is contained in a Constant, Property or Variable.
  1169. Each Constant or Property *definition* MUST be preceded by a DocBlock
  1170. containing the @type tag. Each Variable, where the type is ambiguous or unknown,
  1171. SHOULD be preceded by a DocBlock containing the @type tag. Any other
  1172. variable MAY be preceeded with a similar DocBlock.
  1173. The @type tag MUST contain the name of the element it documents. This is used
  1174. when compound statements are used to define a series of Constants or Properties.
  1175. Such a compound statement can only have one DocBlock while several items are
  1176. represented.
  1177. It is NOT RECOMMENDED to use the @var alias unless it is necessary in order for
  1178. the application, or associated tools, to function correctly.
  1179. #### Examples
  1180. ```php
  1181. /** @type int $int This is a counter. */
  1182. $int = 0;
  1183. // there should be no docblock here
  1184. $int++;
  1185. ```
  1186. Or:
  1187. ```php
  1188. class Foo
  1189. {
  1190. /** @type string|null $description Should contain a description */
  1191. protected $description = null;
  1192. public function setDescription($description)
  1193. {
  1194. // there should be no docblock here
  1195. $this->description = $description;
  1196. }
  1197. }
  1198. ```
  1199. Another example is to document the variable in a foreach explicitly; many IDEs
  1200. use this information to help you with auto-completion:
  1201. ```php
  1202. /** @type \Sqlite3 $sqlite */
  1203. foreach($connections as $sqlite) {
  1204. // there should be no docblock here
  1205. $sqlite->open('/my/database/path');
  1206. <...>
  1207. }
  1208. ```
  1209. Even compound statements may be documented:
  1210. ```php
  1211. class Foo
  1212. {
  1213. /**
  1214. * @type string $name Should contain a description
  1215. * @type string $description Should contain a description
  1216. */
  1217. protected $name, $description;
  1218. }
  1219. ```
  1220. Or constants:
  1221. ```php
  1222. class Foo
  1223. {
  1224. /**
  1225. * @type string MY_CONST1 Should contain a description
  1226. * @type string MY_CONST2 Should contain a description
  1227. */
  1228. const MY_CONST1 = "1", MY_CONST2 = "2";
  1229. }
  1230. ```
  1231. ### 8.22. @uses
  1232. Indicates whether the current "Structural Element" consumes the
  1233. "Structural Element", or project file, that is provided as target.
  1234. #### Syntax
  1235. @uses [file | "FQSEN"] [<description>]
  1236. #### Description
  1237. The @uses tag describes whether any part of the associated "Structural Element"
  1238. uses, or consumes, another "Structural Element" or a file that is situated in
  1239. the current project.
  1240. When defining a reference to another "Structural Element" you can refer to a
  1241. specific element by appending a double colon and providing the name of that
  1242. element (also called the "FQSEN").
  1243. Files that are contained in this project can be referred to by this tag. This
  1244. can be used, for example, to indicate a relationship between a Controller and
  1245. a template file (as View).
  1246. This tag MUST NOT be used to indicate relations to elements outside of the
  1247. system, so URLs are not usable. To indicate relations with outside elements the
  1248. @see tag can be used.
  1249. Applications consuming this tag, such as generators, are RECOMMENDED to provide
  1250. a `@used-by` tag on the destination element. This can be used to provide a
  1251. bi-directional experience and allow for static analysis.
  1252. #### Examples
  1253. ```php
  1254. <?php
  1255. /**
  1256. * @uses \SimpleXMLElement::__construct()
  1257. */
  1258. function initializeXml()
  1259. {
  1260. <...>
  1261. }
  1262. ```
  1263. ```php
  1264. <?php
  1265. /**
  1266. * @uses MyView.php
  1267. */
  1268. function executeMyView()
  1269. {
  1270. <...>
  1271. }
  1272. ```
  1273. The @var tag is a **deprecated** alias for `@type`. Please see the documentation
  1274. for `@type` for details of its usage.
  1275. ### 8.25. @version
  1276. The @version tag is used to denote some description of "versioning" to an
  1277. element.
  1278. #### Syntax
  1279. @version ["Semantic Version"] [<description>]
  1280. #### Description
  1281. Documents the current "version" of any element.
  1282. This information can be used to generate a set of API Documentation where the
  1283. consumer is informed about elements at a particular version.
  1284. It is RECOMMENDED that the version number matches a semantic version number as
  1285. described in the [Semantic Versioning Standard version 2.0][SEMVER2].
  1286. Version vectors from Version Control Systems are also supported, though they
  1287. MUST follow the form:
  1288. name-of-vcs: $vector$
  1289. A description MAY be provided, for the purpose of communicating any additional
  1290. version-specific information.
  1291. The @version tag MAY NOT be used to show the last modified or introduction
  1292. version of an element, the @since tag SHOULD be used for that purpose.
  1293. #### Examples
  1294. ```php
  1295. /**
  1296. * File for class Foo
  1297. * @version 2.1.7 MyApp
  1298. * (this string denotes the application's overall version number)
  1299. * @version @package_version@
  1300. * (this PEAR replacement keyword expands upon package installation)
  1301. * @version $Id$
  1302. * (this CVS keyword expands to show the CVS file revision number)
  1303. */
  1304. /**
  1305. * This is Foo
  1306. */
  1307. class Foo
  1308. {
  1309. <...>
  1310. }
  1311. ```
  1312. ## Appendix A. Types
  1313. ### ABNF
  1314. type-expression = 1*(array-of-type-expression|array-of-type|type ["|"])
  1315. array-of-type-expression = "(" type-expression ")[]"
  1316. array-of-type = type "[]"
  1317. type

Large files files are truncated, but you can click here to view the full file