Previous Up Next
@param phpDocumentor tags @return

@property

"Magic" Property of a class.

Chuck Burgess
Tag Documentation written by [email protected]
Copyright 2007, Chuck Burgess
(phpDocumentor 1.4+)
@property datatype description

Description

@property shows a "magic" property variable that is found inside the class.

datatype should be a valid PHP type or "mixed." phpDocumentor will display the optional description unmodified, and defaults to "mixed" if the datatype is not present.

The property is presumed to be available for both read and write operations. If the property is read-only, you should use the @property-read tag instead. If the property is write-only, use @property-write.

Example

  1. /**
  2.  * show off @property, @property-read, @property-write
  3.  *
  4.  * @property mixed $regular regular read/write property
  5.  * @property-read int $foo the foo prop
  6.  * @property-write string $bar the bar prop
  7.  */
  8. class Magician
  9. {
  10.     private $_thingy;
  11.     private $_bar;
  12.  
  13.     function __get($var)
  14.     {
  15.         switch ($var{
  16.             case 'foo' :
  17.                 return 45;
  18.             case 'regular' :
  19.                 return $this->_thingy;
  20.         }}
  21.  
  22.     function __set($var$val)
  23.     {
  24.         switch ($var{
  25.             case 'bar' :
  26.                 $this->_bar $val;
  27.                 break;
  28.             case 'regular' :
  29.                 if (is_string($val)) {
  30.                     $this->_thingy $val;
  31.                 }}}
  32. }

Using these "magic" tags will result in the tag info being listed in the "infomational" tag listing for the class itself. It does NOT generate actual "property" or "variable" entities in the document.

In the example above, when using PhpDocumentor with the HTML:Smarty:HandS converter and the "--parseprivate on" setting, you'll see "$_thingy" and "$_bar" shown in the "Property Summary" listing of your class variables, but you will NOT see "$regular", "$foo", or "$bar" there, because the latter three are not explicitly declared variables in your code. You WILL see "$regular", "$foo" and "$bar" in the class-level's "API Tags" listing, thanks to your "@property" tags in the class-level docblock.

Previous Up Next
@param phpDocumentor tags @return

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