Ответ 1
/**
* This is what the variable does. The var line contains the type stored in this variable.
* @var string
*/
private $foo;
Учитывайте следующий класс PHP 5:
class SomeClass
{
//I want to document this property...
private $foo;
function __construct()
{
}
public function SetFoo($value)
{
$this->foo = $value;
}
public function GetFoo()
{
return $this->foo;
}
}
Как в phpDocumentor я буду документировать свойство $foo? Я даже не уверен, что его нужно документировать, но я хотел бы знать, как, если нужно...
Я знаю, как документировать SetFoo() и GetFoo(), я просто не уверен в частной собственности (переменная?).
Спасибо!
/**
* This is what the variable does. The var line contains the type stored in this variable.
* @var string
*/
private $foo;
Я бы использовал, по крайней мере, тег @var
, чтобы указать тип переменной.
Например:
/**
* Some blah blah about what this is useful for
* @var MyClass $foo
*/
Это именно то, что сделано Zend Framework, например; см. Zend_Layout
(цитирование):
class Zend_Layout
{
/**
* Placeholder container for layout variables
* @var Zend_View_Helper_Placeholder_Container
*/
protected $_container;
/**
* Key used to store content from 'default' named response segment
* @var string
*/
protected $_contentKey = 'content';
Примечание: тег @access
был полезен с PHP 4 (когда не было public
/protected
/private
), но я никогда не использую его, когда я документирую код, написанный на PHP 5: код, используя видимость ключевые слова являются самодокументируемыми.
В случае использования магических методов __get и __set вы можете использовать @property
/**
* Description for the class
* @property type $foo Description for foo
* @property type $foo Description for bar
*/
class SomeClass
{
private $foo;
protected $bar;
public function __get(){
...
}
public function __set(){
...
}
}
Ссылки с дополнительной информацией:
/**
* docstring
*/
private $foo;
Важное примечание: должны быть два звездочки. Не один.