Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

phpdoc: What's the proper way to document a constant

Tags:

php

phpdoc

Is there a proper way to document a constant defined using define()? @var doesn't really make sense. The only thing I can think of is to omit the tag, and just write the description in the PHPdoc comment.

like image 420
Matty Avatar asked Feb 14 '11 18:02

Matty


3 Answers

phpDocumentor does not recognize or utilize a @const tag. phpDocumentor recognizes a constant when it sees the "define" keyword in the code. Its output templates will show all constants in the output documentation, listed as constants. The only thing needed in the constant's docblock is a description, although many other "standard" tags are allowed if you feel like you need them [1].

[1] -- http://manual.phpdoc.org/HTMLSmartyConverter/HandS/phpDocumentor/tutorial_elements.pkg.html#procedural.define

like image 189
ashnazg Avatar answered Oct 17 '22 11:10

ashnazg


Use @const.

/**
  * @const FOO Bar
  */
define('FOO', 'Bar');

Documentation (Sorry, the only docs I can find are in German.)

like image 28
lonesomeday Avatar answered Oct 17 '22 10:10

lonesomeday


You actually want to use @type, see the Github PHP Documentation.

like image 1
Travis Smith Avatar answered Oct 17 '22 10:10

Travis Smith