34

次のPHP5クラスを考慮してください。

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()を文書化する方法を知っていますが、プライベートプロパティ(変数?)についてはよくわかりません。

ありがとう!

4

4 に答える 4

50
/**
 * This is what the variable does. The var line contains the type stored in this variable.
 * @var string
 */
private $foo;
于 2010-02-03T19:31:40.193 に答える
19

@var私は通常、これが変数のタイプであることを示すために、少なくともタグを使用します。

例えば ​​:

/**
 * Some blah blah about what this is useful for
 * @var MyClass $foo
 */


これは、たとえばZendFrameworkによって行われることとまったく同じです。(引用)を参照してください: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で役立ちました( //がない場合)が、publicprotectedprivate PHP 5で記述されたコードを文書化するときは決して使用しません:コード、可視性キーワードの使用は自己文書化です。

于 2010-02-03T19:32:38.863 に答える
6

__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(){
         ...
     }
 }

詳細情報へのリンク:

于 2013-08-28T07:15:18.867 に答える
0
/**
 * docstring
 */
private $foo;

重要な注意:2つのアスタリスクが必要です。ない1。

于 2016-03-24T05:56:09.637 に答える