-
-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generic/DocComment: add XML documentation #247
Changes from 7 commits
bb5cd16
6089ac6
5843ebe
ad2cc5c
15eb2db
1c68da9
500f492
d592b6f
f266412
250effa
b42cc51
80dee19
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,268 @@ | ||||||||||||||||||||||||||||||||||||
<documentation title="Doc Comment"> | ||||||||||||||||||||||||||||||||||||
<standard> | ||||||||||||||||||||||||||||||||||||
<![CDATA[ | ||||||||||||||||||||||||||||||||||||
Enforces several rules related to the formatting of DocBlocks in PHP code. | ||||||||||||||||||||||||||||||||||||
]]> | ||||||||||||||||||||||||||||||||||||
</standard> | ||||||||||||||||||||||||||||||||||||
<standard> | ||||||||||||||||||||||||||||||||||||
<![CDATA[ | ||||||||||||||||||||||||||||||||||||
DocBlock must not be empty. | ||||||||||||||||||||||||||||||||||||
rodrigoprimo marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||
]]> | ||||||||||||||||||||||||||||||||||||
</standard> | ||||||||||||||||||||||||||||||||||||
<code_comparison> | ||||||||||||||||||||||||||||||||||||
<code title="Valid: DocBlock with some content."> | ||||||||||||||||||||||||||||||||||||
<![CDATA[ | ||||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||||
* <em>Some content.</em> | ||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||
]]> | ||||||||||||||||||||||||||||||||||||
</code> | ||||||||||||||||||||||||||||||||||||
<code title="Invalid: Empty DocBlock."> | ||||||||||||||||||||||||||||||||||||
<![CDATA[ | ||||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||||
* <em></em> | ||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||
]]> | ||||||||||||||||||||||||||||||||||||
</code> | ||||||||||||||||||||||||||||||||||||
</code_comparison> | ||||||||||||||||||||||||||||||||||||
<standard> | ||||||||||||||||||||||||||||||||||||
<![CDATA[ | ||||||||||||||||||||||||||||||||||||
The opening and closing DocBlock tags must be the only content on the line. | ||||||||||||||||||||||||||||||||||||
]]> | ||||||||||||||||||||||||||||||||||||
</standard> | ||||||||||||||||||||||||||||||||||||
<code_comparison> | ||||||||||||||||||||||||||||||||||||
<code title="Valid: The opening and closing DocBlock tags are the only content on the line."> | ||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "on the line" is confusing as the line for the opening/closing tags will be on different lines. Not sure if this is better, but maybe you want to have a think about the phrasing (here and in the "invalid" example too).
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Implemented in dc22715 |
||||||||||||||||||||||||||||||||||||
<![CDATA[ | ||||||||||||||||||||||||||||||||||||
<em>/**</em> | ||||||||||||||||||||||||||||||||||||
* Short description. | ||||||||||||||||||||||||||||||||||||
<em>*/</em> | ||||||||||||||||||||||||||||||||||||
]]> | ||||||||||||||||||||||||||||||||||||
</code> | ||||||||||||||||||||||||||||||||||||
<code title="Invalid: The opening and closing DocBlock tags are not the only content on the line."> | ||||||||||||||||||||||||||||||||||||
<![CDATA[ | ||||||||||||||||||||||||||||||||||||
<em>/** Short description.</em> | ||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||||
<em>* Short description */</em> | ||||||||||||||||||||||||||||||||||||
rodrigoprimo marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||
]]> | ||||||||||||||||||||||||||||||||||||
</code> | ||||||||||||||||||||||||||||||||||||
</code_comparison> | ||||||||||||||||||||||||||||||||||||
<standard> | ||||||||||||||||||||||||||||||||||||
<![CDATA[ | ||||||||||||||||||||||||||||||||||||
There must be no additional blank lines before the closing DocBlock tag. | ||||||||||||||||||||||||||||||||||||
rodrigoprimo marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||
]]> | ||||||||||||||||||||||||||||||||||||
</standard> | ||||||||||||||||||||||||||||||||||||
<code_comparison> | ||||||||||||||||||||||||||||||||||||
<code title="Valid: no additional blank lines before the closing DocBlock tag."> | ||||||||||||||||||||||||||||||||||||
<![CDATA[ | ||||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||||
* Short description. | ||||||||||||||||||||||||||||||||||||
<em></em> */ | ||||||||||||||||||||||||||||||||||||
rodrigoprimo marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||
]]> | ||||||||||||||||||||||||||||||||||||
</code> | ||||||||||||||||||||||||||||||||||||
<code title="Invalid: additional blank lines before the closing DocBlock tag."> | ||||||||||||||||||||||||||||||||||||
<![CDATA[ | ||||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||||
* Short description. | ||||||||||||||||||||||||||||||||||||
<em> *</em> | ||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||
]]> | ||||||||||||||||||||||||||||||||||||
</code> | ||||||||||||||||||||||||||||||||||||
</code_comparison> | ||||||||||||||||||||||||||||||||||||
<standard> | ||||||||||||||||||||||||||||||||||||
<![CDATA[ | ||||||||||||||||||||||||||||||||||||
The DocBlock must have a short description, and it must be on the first line. | ||||||||||||||||||||||||||||||||||||
]]> | ||||||||||||||||||||||||||||||||||||
</standard> | ||||||||||||||||||||||||||||||||||||
<code_comparison> | ||||||||||||||||||||||||||||||||||||
<code title="Valid: DocBlock with a short description on the first line."> | ||||||||||||||||||||||||||||||||||||
<![CDATA[ | ||||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||||
* <em>Short description.</em> | ||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||
]]> | ||||||||||||||||||||||||||||||||||||
</code> | ||||||||||||||||||||||||||||||||||||
<code title="Invalid: DocBlock without a short description or short description not on the first line."> | ||||||||||||||||||||||||||||||||||||
<![CDATA[ | ||||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||||
* <em></em>@return int | ||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||||
<em> *</em> | ||||||||||||||||||||||||||||||||||||
* Short description. | ||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||
]]> | ||||||||||||||||||||||||||||||||||||
</code> | ||||||||||||||||||||||||||||||||||||
</code_comparison> | ||||||||||||||||||||||||||||||||||||
<standard> | ||||||||||||||||||||||||||||||||||||
<![CDATA[ | ||||||||||||||||||||||||||||||||||||
The short and long descriptions must start with a capital letter. | ||||||||||||||||||||||||||||||||||||
rodrigoprimo marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||
]]> | ||||||||||||||||||||||||||||||||||||
</standard> | ||||||||||||||||||||||||||||||||||||
<code_comparison> | ||||||||||||||||||||||||||||||||||||
<code title="Valid: Short and long descriptions start with a capital letter."> | ||||||||||||||||||||||||||||||||||||
rodrigoprimo marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||
<![CDATA[ | ||||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||||
* <em>S</em>hort description. | ||||||||||||||||||||||||||||||||||||
* | ||||||||||||||||||||||||||||||||||||
* <em>L</em>ong description. | ||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||
]]> | ||||||||||||||||||||||||||||||||||||
</code> | ||||||||||||||||||||||||||||||||||||
<code title="Invalid: Short or long descriptions don't start with a capital letter."> | ||||||||||||||||||||||||||||||||||||
rodrigoprimo marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||
<![CDATA[ | ||||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||||
* <em>s</em>hort description. | ||||||||||||||||||||||||||||||||||||
* | ||||||||||||||||||||||||||||||||||||
* <em>l</em>ong description. | ||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||
]]> | ||||||||||||||||||||||||||||||||||||
</code> | ||||||||||||||||||||||||||||||||||||
</code_comparison> | ||||||||||||||||||||||||||||||||||||
<standard> | ||||||||||||||||||||||||||||||||||||
<![CDATA[ | ||||||||||||||||||||||||||||||||||||
There must be exactly one blank line separating the short description, the long description and tag groups. | ||||||||||||||||||||||||||||||||||||
]]> | ||||||||||||||||||||||||||||||||||||
</standard> | ||||||||||||||||||||||||||||||||||||
<code_comparison> | ||||||||||||||||||||||||||||||||||||
<code title="Valid: One blank line separating the short description, the long description and tag groups."> | ||||||||||||||||||||||||||||||||||||
<![CDATA[ | ||||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||||
* Short description. | ||||||||||||||||||||||||||||||||||||
<em> *<em> | ||||||||||||||||||||||||||||||||||||
* Long description. | ||||||||||||||||||||||||||||||||||||
<em> *</em> | ||||||||||||||||||||||||||||||||||||
* @param int $foo | ||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||
]]> | ||||||||||||||||||||||||||||||||||||
</code> | ||||||||||||||||||||||||||||||||||||
<code title="Invalid: More than one or no blank line separating the short description, the long description and tag groups."> | ||||||||||||||||||||||||||||||||||||
<![CDATA[ | ||||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||||
* Short description. | ||||||||||||||||||||||||||||||||||||
<em> * | ||||||||||||||||||||||||||||||||||||
* | ||||||||||||||||||||||||||||||||||||
</em> | ||||||||||||||||||||||||||||||||||||
rodrigoprimo marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||
* Long description. | ||||||||||||||||||||||||||||||||||||
* @param int $foo | ||||||||||||||||||||||||||||||||||||
rodrigoprimo marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||
]]> | ||||||||||||||||||||||||||||||||||||
</code> | ||||||||||||||||||||||||||||||||||||
</code_comparison> | ||||||||||||||||||||||||||||||||||||
<standard> | ||||||||||||||||||||||||||||||||||||
<![CDATA[ | ||||||||||||||||||||||||||||||||||||
Parameter tags must be grouped together. | ||||||||||||||||||||||||||||||||||||
]]> | ||||||||||||||||||||||||||||||||||||
</standard> | ||||||||||||||||||||||||||||||||||||
<code_comparison> | ||||||||||||||||||||||||||||||||||||
<code title="Valid: Parameter tags grouped together."> | ||||||||||||||||||||||||||||||||||||
<![CDATA[ | ||||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||||
* Short description. | ||||||||||||||||||||||||||||||||||||
* | ||||||||||||||||||||||||||||||||||||
<em> * @param int $foo | ||||||||||||||||||||||||||||||||||||
* @param string $bar</em> | ||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||
]]> | ||||||||||||||||||||||||||||||||||||
</code> | ||||||||||||||||||||||||||||||||||||
<code title="Invalid: Parameter tags not grouped together."> | ||||||||||||||||||||||||||||||||||||
<![CDATA[ | ||||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||||
* Short description. | ||||||||||||||||||||||||||||||||||||
* | ||||||||||||||||||||||||||||||||||||
* @param int $foo | ||||||||||||||||||||||||||||||||||||
<em> *</em> | ||||||||||||||||||||||||||||||||||||
* @param string $bar | ||||||||||||||||||||||||||||||||||||
jrfnl marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||
]]> | ||||||||||||||||||||||||||||||||||||
</code> | ||||||||||||||||||||||||||||||||||||
</code_comparison> | ||||||||||||||||||||||||||||||||||||
<standard> | ||||||||||||||||||||||||||||||||||||
<![CDATA[ | ||||||||||||||||||||||||||||||||||||
Parameter tags must not be grouped together with other tags. | ||||||||||||||||||||||||||||||||||||
]]> | ||||||||||||||||||||||||||||||||||||
</standard> | ||||||||||||||||||||||||||||||||||||
<code_comparison> | ||||||||||||||||||||||||||||||||||||
<code title="Valid: Parameter tags are not grouped together with other tags."> | ||||||||||||||||||||||||||||||||||||
<![CDATA[ | ||||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||||
* Short description. | ||||||||||||||||||||||||||||||||||||
* | ||||||||||||||||||||||||||||||||||||
* @param int $foo | ||||||||||||||||||||||||||||||||||||
* | ||||||||||||||||||||||||||||||||||||
<em> * @author Some Author | ||||||||||||||||||||||||||||||||||||
* @return int</em> | ||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While valid, the
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As the rule is about the param tags, would it make sense for the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree and I implemented it in dc22715 |
||||||||||||||||||||||||||||||||||||
]]> | ||||||||||||||||||||||||||||||||||||
</code> | ||||||||||||||||||||||||||||||||||||
<code title="Invalid: Parameter tags grouped together with other tags."> | ||||||||||||||||||||||||||||||||||||
<![CDATA[ | ||||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||||
* Short description. | ||||||||||||||||||||||||||||||||||||
* | ||||||||||||||||||||||||||||||||||||
<em> * @param int $foo | ||||||||||||||||||||||||||||||||||||
* @author Some Author | ||||||||||||||||||||||||||||||||||||
* @return int</em> | ||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||
rodrigoprimo marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||
]]> | ||||||||||||||||||||||||||||||||||||
</code> | ||||||||||||||||||||||||||||||||||||
</code_comparison> | ||||||||||||||||||||||||||||||||||||
<standard> | ||||||||||||||||||||||||||||||||||||
<![CDATA[ | ||||||||||||||||||||||||||||||||||||
Tag values for different tags in the same group must be aligned with each other. | ||||||||||||||||||||||||||||||||||||
]]> | ||||||||||||||||||||||||||||||||||||
</standard> | ||||||||||||||||||||||||||||||||||||
<code_comparison> | ||||||||||||||||||||||||||||||||||||
<code title="Valid: Tag values for different tags in the same tag group are aligned with each other."> | ||||||||||||||||||||||||||||||||||||
<![CDATA[ | ||||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||||
* Short description. | ||||||||||||||||||||||||||||||||||||
* | ||||||||||||||||||||||||||||||||||||
* @deprecated <em>1.0.0</em> | ||||||||||||||||||||||||||||||||||||
* @return <em>bool</em> | ||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That makes sense. I added this change in commit dc22715. |
||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In a lot of coding standards, the What about this instead ?
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also implemented in dc22715 |
||||||||||||||||||||||||||||||||||||
]]> | ||||||||||||||||||||||||||||||||||||
</code> | ||||||||||||||||||||||||||||||||||||
<code title="Invalid: Tag values for different tags in the same tag group are not aligned with each other."> | ||||||||||||||||||||||||||||||||||||
<![CDATA[ | ||||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||||
* Short description. | ||||||||||||||||||||||||||||||||||||
* | ||||||||||||||||||||||||||||||||||||
* @deprecated <em>1.0.0</em> | ||||||||||||||||||||||||||||||||||||
* @return <em>bool</em> | ||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||
]]> | ||||||||||||||||||||||||||||||||||||
</code> | ||||||||||||||||||||||||||||||||||||
</code_comparison> | ||||||||||||||||||||||||||||||||||||
<standard> | ||||||||||||||||||||||||||||||||||||
<![CDATA[ | ||||||||||||||||||||||||||||||||||||
Parameter tags must be defined before other tags in a DocBlock. | ||||||||||||||||||||||||||||||||||||
]]> | ||||||||||||||||||||||||||||||||||||
</standard> | ||||||||||||||||||||||||||||||||||||
<code_comparison> | ||||||||||||||||||||||||||||||||||||
<code title="Valid: Parameter tags are defined first."> | ||||||||||||||||||||||||||||||||||||
<![CDATA[ | ||||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||||
* Short description. | ||||||||||||||||||||||||||||||||||||
* | ||||||||||||||||||||||||||||||||||||
* <em>@param string $foo</em> | ||||||||||||||||||||||||||||||||||||
* | ||||||||||||||||||||||||||||||||||||
* @return void | ||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||
]]> | ||||||||||||||||||||||||||||||||||||
</code> | ||||||||||||||||||||||||||||||||||||
<code title="Invalid: Parameter tags are not defined first."> | ||||||||||||||||||||||||||||||||||||
<![CDATA[ | ||||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||||
* Short description. | ||||||||||||||||||||||||||||||||||||
* | ||||||||||||||||||||||||||||||||||||
* @return void | ||||||||||||||||||||||||||||||||||||
* | ||||||||||||||||||||||||||||||||||||
* <em>@param string $bar</em> | ||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||
]]> | ||||||||||||||||||||||||||||||||||||
</code> | ||||||||||||||||||||||||||||||||||||
</code_comparison> | ||||||||||||||||||||||||||||||||||||
</documentation> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sniff is named "Doc Comment", while it really is about DocBlocks. Changing the name would be a BC-break, so is not on the table, but maybe it would be good to make it clear what a DocBlock is in this summary
standard
block and maybe also "explain" that the "Doc Comment" from the sniff name is really DocBlock.This page might provide inspiration for creating a good explanation of what a DocBlock is: https://docs.phpdoc.org/3.0/guide/references/phpdoc/basic-syntax.html#what-is-a-docblock
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just pushed a new commit suggesting a new description for the sniff including the points that you mentioned. I'm afraid the result might be a bit too long. Please let me know what you think.