0

現在、次のようなコードがあります。

/**
 * blah blah blah thing1
 *
 * @return string a thing1
 */
function thing1() {
    //
}

/**
 * blah blah blah thing2
 *
 * @return string a thing2
 */
function thing2() {
    //
}

//dozens more with the same format

それを行うためのより簡潔な方法はありますか?

4

2 に答える 2

1

docblock が実際には同一であると仮定すると、多くの場合、継承されたメソッドをオーバーライドしているが同じ署名を維持している場合に、@see...を使用できます。

abstract class MyBaseModel
    /**
     * @param Boolean $excludeDeleted Should soft-deleted records be excluded
     */
    public function newQuery($excludeDeleted = true)
    {
        ....
    }
}

class MyExtendedModel extends MyBaseModel
    /**
     * Overload the base newQuery() method so that we can inject any security filters into the query
     *
     * @see MyBaseModel::newQuery
     */
    public function newQuery($excludeDeleted = true)
    {
        ....
    }
}

thing1()しかし、あなたのとのサンプル docblockthing2()は同一ではないため、その場合、簡潔な (怠惰な) 方法はありません。

于 2014-04-23T21:09:52.427 に答える
0

本当に同じなら @see を使うことができます。

これに関連するドキュメント

/**
 * blah blah blah thing1
 *
 * @return string a thing1
 */
function thing1() {
    //
}

/**
 * @see thing1
 */
function thing2() {
    //
}
于 2014-04-23T21:10:39.520 に答える