Function Comments

Functions must have a non-empty doc comment. The short description must be on the second line of the comment. Each description must have one blank comment line before and after. There must be one blank line before the tags in the comments. There must be a tag for each of the parameters in the right order with the right variable names with a comment. There must be a return tag. Any throw tag must have an exception class.

Valid: A function doc comment is used.

<em>/** * Short description here. * * @return void */</em> function foo() { }

Invalid: No doc comment for the function.

function foo() { }

Valid: Short description is the second line of the comment.

/** * <em>Short description here.</em> * * @return void */ function foo() { }

Invalid: An extra blank line before the short description.

/** * <em></em> * <em>Short description here.</em> * * @return void */ function foo() { }

Valid: Exactly one blank line around descriptions.

/** * Short description here. * <em></em> * Long description here. * <em></em> * @return void */ function foo() { }

Invalid: Extra blank lines around the descriptions.

/** * Short description here. * <em></em> * <em></em> * Long description here. * <em></em> * <em></em> * @return void */ function foo() { }

Valid: Exactly one blank line before the tags.

/** * Short description here. * * Long description here. * <em></em> * @return void */ function foo() { }

Invalid: Extra blank lines before the tags.

/** * Short description here. * * Long description here. * <em></em> * <em></em> * @return void */ function foo() { }

Valid: Throws tag has an exception class.

/** * Short description here. * * @return void * @throws <em>FooException</em> */ function foo() { }

Invalid: No exception class given for throws tag.

/** * Short description here. * * @return void * <em>@throws</em> */ function foo() { }

Valid: Return tag present.

/** * Short description here. * * <em>@return void</em> */ function foo() { }

Invalid: No return tag.

/** * Short description here. */ function foo() { }

Valid: Param names are correct.

/** * Short description here. * * @param string <em>$foo</em> Foo parameter * @param string <em>$bar</em> Bar parameter * @return void */ function foo(<em>$foo</em>, <em>$bar</em>) { }

Invalid: Wrong parameter name doesn't match function signature.

/** * Short description here. * * @param string $foo Foo parameter * @param string <em>$qux</em> Bar parameter * @return void */ function foo($foo, <em>$bar</em>) { }

Valid: Param names are ordered correctly.

/** * Short description here. * * @param string <em>$foo</em> Foo parameter * @param string <em>$bar</em> Bar parameter * @return void */ function foo(<em>$foo</em>, <em>$bar</em>) { }

Invalid: Wrong parameter order.

/** * Short description here. * * @param string <em>$bar</em> Bar parameter * @param string <em>$foo</em> Foo parameter * @return void */ function foo(<em>$foo</em>, <em>$bar</em>) { }