Documenting class constants groups with phpDocumentor

Let's say I have a method that has a parameter whose real values ​​are declared as class constants (think PGSQL_ASSOC / PGSQL_NUM / PGSQL_BOTH ). And there is another method with a similar parameter, using a different set of class constants. Is there a way to describe phpDocumentor that each set of constants belongs to a logical group of alternatives? It would be useful if they were documented by groups and had the ability to refer to specific groups in the documentation of the method. Using docblock templates does not shorten it, because the short description of the template is ignored (adding useless clutter), while the long description of the template is added to the description with constant binding, which leads to the form of the inverse statement (for example, β€œBAR_MODE_1” is true. works for Foo :: bar () "instead of" Operating modes for Foo :: bar (): BAR_MODE_1 does this and that. ").

Example:

 class Foo { // this group of constants are valid modes for the bar() method const BAR_MODE_1 = 1; const BAR_MODE_2 = 2; const BAR_MODE_3 = 3; /** * @param int see Foo::BAR_MODE_* constants */ public function bar($mode) { ... } // this group of constants are valid modes for the baz() method const BAZ_MODE_1 = 1; const BAZ_MODE_2 = 2; const BAZ_MODE_3 = 3; /** * @param int see Foo::BAZ_MODE_* constants */ public function baz($mode) { ... } } 
+4
source share
2 answers

The first thing that comes to my mind is the @see tag - it displays a link to the documentation for the item.

 /** * @param int * @see Foo::BAR_MODE_* constants */ public function bar($mode) { ... } 

More information can be found here in the manual .

+2
source

Another style might be using PHPDocumentor DocBlock Templates

 /**#@+ * This comment applies to each in the block * * @var varType */ protected $_var1 = 1; protected $_var2 = 2; /**#@-*/ 

see http://manual.phpdoc.org/HTMLSmartyConverter/HandS/phpDocumentor/tutorial_phpDocumentor.howto.pkg.html#basics.docblock

+7
source

Source: https://habr.com/ru/post/1380755/


All Articles