Table Of Contents

Previous topic

@uses & @used-by

Next topic

@version

@var

The @var tag is used to document a class property.

Syntax

@var [Type] [<description>]

@var [Type] [name] [<description>]

[<summary>]

@var [Type] [<description>]

[<summary>]

@var [Type] [name] [<description>]

Description

With the @var tag it is possible to document the type and function of a class property. When provided it MUST contain a Type to indicate what is expected; the description on the other hand is OPTIONAL yet RECOMMENDED in case of complicated structures, such as associative arrays.

The @var tag MAY have a multi-line description and does not need explicit delimiting.

It is RECOMMENDED when documenting to use this tag with every property.

This tag MUST NOT occur more than once per property in a PHPDoc and is limited to Structural Elements of type property.

Effects in phpDocumentor

Note

The name of the property will be ommitted from the documentation if you specify it. The name is derived from the variable itself.

Note

Specifying the summary is optional if there is a description.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
class DemoVar
{
   /**
    * Summary
    *
    * @var object Description
    */
   protected $varWithDescriptions;

   /**
    * @var \DemoVar $instance The class instance.
    */
   protected static $instance;

   /**
    * Summary for varWithWrongType
    *
    * @var boolean The varWithWrongType. Boolean will be put in the type.
    */
   protected $varWithWrongType = array();
}

Templates