Previous Up Next
@since phpDocumentor tags @staticvar

@static

Document a static property or method

Gregory Beaver
Tag Documentation written by [email protected]
Copyright 2002, Gregory Beaver
(phpDocumentor 1.1+)
@static

Description

Use the @static tag to declare a variable or method to be static. Static elements can be called without reference to an instantiated class object, as in class::variable and class::method().

Example

Here's an example:

  1. /**
  2.  * example of a class
  3.  * with a single static variable
  4.  * and method
  5.  */
  6. class myclass
  7. {
  8.    /**
  9.     * a static variable
  10.     * @static
  11.     */
  12.    public static $astaticvar 0;
  13.    /**
  14.     * normal variable
  15.     */
  16.    public $anormalvar 1;
  17.    /**
  18.     * a static function
  19.     * @static
  20.     */
  21.    function mystaticfunction()
  22.    {
  23.    ...
  24.    }
  25.    /**
  26.     * normal function
  27.     */
  28.    function mynormalfunction()
  29.    {
  30.    ...
  31.    }
  32. }
  33.  
  34. // example of usage of static methods
  35. myclass::mystaticvar;
  36. myclass::mystaticfunction();

Just using the static keyword in your code is enough for PhpDocumentor on PHP5 to recognize static variables and methods, and PhpDocumentor will mark them as static.

However, using the static tag will also result in PhpDocumentor marking the variable or method as static, even if the PHP code does not use the static keyword. So, using the tag but not the keyword actually means your code behavior will not match your API doc... so handle with care. The good news is that using both the keyword and the tag will not result in a double "static" in the resulting doc.

Ideally, the static keyword in your code is sufficient for the resulting docs to show your members are static. This tag appears to be a "helpful" tag for use in PHP4 code, allowing you to hint that you want the member to be treated as static, even if PHP4 doesn't have the ability to make it act that way. Most likely, you'll use this tag as a reminder that your intention with this member, once you move the code from PHP4 to PHP5, will be for that member to be static.

Previous Up Next
@since phpDocumentor tags @staticvar

Documentation generated on Mon, 05 Dec 2011 21:13:05 -0600 by phpDocumentor 1.4.4