When documenting a php class with well named properties that has get
and set
methods for each property the phpdoc generated error report is full of errors like:
No summary for method getFirstName()
No summary for method setFirstName()
for each property. I'm using the default template. If firstName
is already documented:
/** @var string $firstName contact's first name */
protected $firstName;
it feels redundant to provide a summary for the get and set methods.
/**
* @return string
*/
public function getFirstName()
{
return $this->firstName;
}
/**
* @param string $firstName
*/
public function setFirstName($firstName)
{
$this->firstName = $firstName;
}
Is there a way to use one of the existing tags in phpDocumentor to avoid "no summary" showing up in the error report? I haven't be able to get @inheritdoc
to work as these methods aren't overriding anything in their base class, or in some cases there would be no base class.
I looked at docblock templates /**#@+
and /**#@-*/
tags, but wasn't able to get them to apply a summary across a group of enclosed methods. I tried with just the short summary and also with a long summary.
If not what is a DRY way to document classes like this?
No, there currently is not a way to suppress that.
Since you probably would not want to do this globally, controlling such capability would probably need to be done on a per-docblock basis via an annotation. So each docblock gets something... either a summary or an annotation.
If you want it disabled globally, then you're effectively saying "I don't care about summary warnings, no matter if it's accessor methods or not"... and in this case, you would just ignore all these warnings anyway.