0

I currently have code like this:

/**
 * 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

Is there a more concise way to do that?

Ryan
  • 5,883
  • 13
  • 56
  • 93
  • Copy and paste? Maybe if you could be more specific... but the format is meant to be repetitive and somewhat large so that it's easy to read. – Matthew Poer Apr 23 '14 at 21:10
  • If it's that the annotations are so similar, maybe your functions are also very similar, and perhaps you could make your code more concise (and thus your annotations as well). – Matthew Poer Apr 23 '14 at 21:11

2 Answers2

1

Assuming the docblocks are actually identical, often the case when you're overriding an inherited method but maintaining the same signature, you can use @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)
    {
        ....
    }
}

but the sample docblocks for your thing1() and thing2() aren't identical, so there's no concise (lazy) way of doing so in that case

Mark Baker
  • 209,507
  • 32
  • 346
  • 385
0

You can use a @see if it is truly the same.

Documentation relating to this

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

/**
 * @see thing1
 */
function thing2() {
    //
}
Thomas Lomas
  • 1,553
  • 10
  • 22