Describing a variable
suggest changeThe @var
keyword can be used to describe the type and usage of:
- a class property
- a local or global variable
- a class or global constant
class Example {
/** @var string This is something that stays the same */
const UNCHANGING = "Untouchable";
/** @var string $some_str This is some string */
public $some_str;
/**
* @var array $stuff This is a collection of stuff
* @var array $nonsense These are nonsense
*/
private $stuff, $nonsense;
...
}
The type can be one of the built-in PHP types, or a user-defined class, including namespaces.
The name of the variable should be included, but can be omitted if the docblock applies to only one item.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents