parameters tags alignement in docblocks

From: Date: Tue, 24 Jul 2007 20:41:46 +0000
Subject: parameters tags alignement in docblocks
Groups: php.pear.qa 
Request: Send a blank email to pear-qa+get-4458@lists.php.net to get a copy of this message
Hi guys, (This is a resend as I had issues sending emails in the past few days and you may have not received it. Also, since this is about alignments, the font of this email should be courier. I also attached the content as text file too as a backup.) Looking at the page or class docblocks in http://pear.php.net/manual/en/standards.sample.php, the tags contents are aligned which is fine: * @category CategoryName * @package PackageName * @author Original Author <author@example.com> * @author Another Author <another@example.com> * @copyright 1997-2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version CVS: $Id:$ * @link http://pear.php.net/package/PackageName * @see NetOther, Net_Sample::Net_Sample() * @since File available since Release 1.2.0 * @deprecated File deprecated in Release 2.0.0 Looking at the function docblock, the tags contents are not aligned after the tag keywords (there is just one space), which looks like a documentation error (please correct me if I am wrong).: * @param string $arg1 the string to quote * @param int $arg2 an integer of how many problems happened. * Indent to the description's starting point * for long ones. * * @return int the integer of the set mode used. FALSE if foo * foo could not be set. * @throws exceptionclass [description] * * @access public * @static * @see Net_Sample::$foo, Net_Other::someMethod() * @since Method available since Release 1.2.0 * @deprecated Method deprecated in Release 2.0.0 Should we expect this (#1): all contents are aligned on the longest tag keyword as in the page and class docblocks (as PHP_DocBlockGenerator generates docblocks)? * @param string $arg1 the string to quote * @param int $arg2 an integer of how many problems happened. * Indent to the description's starting point * for long ones. * * @return int the integer of the set mode used. FALSE if foo * foo could not be set. * @throws exceptionclass [description] * * @access public * @static * @see Net_Sample::$foo, Net_Other::someMethod() * @since Method available since Release 1.2.0 * @deprecated Method deprecated in Release 2.0.0 or that (#2): the parameter contents are aligned separately from the other tags (as PHP_CodeSniffer would expect)? * @param string $arg1 the string to quote * @param int $arg2 an integer of how many problems happened. * Indent to the description's starting point * for long ones. * * @return int the integer of the set mode used. FALSE if foo * foo could not be set. * @throws exceptionclass [description] * * @access public * @static * @see Net_Sample::$foo, Net_Other::someMethod() * @since Method available since Release 1.2.0 * @deprecated Method deprecated in Release 2.0.0 Also, is it mandatory or recommended or optional to add an empty line after the last parameter? Note, that I looked at the main class of packages written by you guys and found that some of you use #1, others #2, others something else :-) We need some guidance here so we can adjust PHP_CodeSniffer or PHP_DocBlockGenerator if necessary. Thanks, MC ----- Forwarded Message ---- From: Greg Sherwood <gsherwood@squiz.net> To: Michel Corne <mcorne@yahoo.com> Cc: Sascha.Grossenbacher@bit.admin.ch Sent: Saturday, July 21, 2007 12:40:00 AM Subject: Re: AW: PHP_DocBlockGenerator is not compatible with PHP_CodeSniffer Michel Corne wrote: Have you ever checked with the PEAR QA folks what the actual standard is? I haven't, but I have enquired about a few other don documented standards and they just pointed me at the sample file or said it was up to the developer. When I wrote PHP_CodeSniffer, I just tried to have it match what is in the standards doc as much as possible rather than the existing code because almost all existing code does not follow the PEAR coding standard. If you check with PEAR QA and they say the standard is wrong, I'd be happy to change PHP_CodeSniffer to enforce a new standard, or remove the check all together if there is no standard. Greg ----- Forwarded Message ---- From: Michel Corne <mcorne@yahoo.com> To: Greg Sherwood <gsherwood@squiz.net> Cc: Sascha.Grossenbacher@bit.admin.ch Sent: Friday, July 20, 2007 2:17:41 PM Subject: Re: AW: PHP_DocBlockGenerator is not compatible with PHP_CodeSniffer Hi Greg, You are definitely right about the the version tag within a class DocBlock. Good catch. Not sure how I missed that one! I will fix it. I will also adjust the license text lines over 85. This won't hurt and will avoid generating warnings with Code Sniffer. Regarding the parameter tags, I see your point. I hope you appreciate mine as well. So, I looked around. I checked the main class of some packages written by the folks who belong to the Pear QA group. There are people who align parameter tags separately from the other tags as per the PEAR manual example, as CodeSniffer would expect. Some of them also add an empty line after the parameters. Others align across all tags, as DocBlockGenerator would generate a DocBlock. It is kinda 50/50, maybe more of the latter, excluding others that use a mix of both methods. I guess I could add an option in DocBlockGenerator that does one of the other. Have you ever checked with the PEAR QA folks what the actual standard is? Regards, MC ----- Original Message ---- From: Greg Sherwood <gsherwood@squiz.net> To: Michel Corne <mcorne@yahoo.com> Cc: Sascha.Grossenbacher@bit.admin.ch Sent: Thursday, July 19, 2007 9:09:43 PM Subject: Re: AW: PHP_DocBlockGenerator is not compatible with PHP_CodeSniffer Michel Corne wrote: Hi guys, Here are my comments to your findings: 18 | WARNING | Line exceeds 85 characters; contains 103 characters 19 | WARNING | Line exceeds 85 characters; contains 89 characters [MC] => Some of the license text lines are longer than 85 chars. I am fine with the warning since the 85 char limit per line is just a PEAR recommendation and not mandatory. I could also look into re-arranging some of the license texts if some people feel strongly about that and file an enhancement request. That is up to you. 53 | WARNING | Invalid version "CVS: $Id:$" in class comment; Consider | | "Release: <package_version>" instead.. [MC] => I don't understand why there is such a warning. Most people use CVS or SVN to automatically change the file version. The file comment should have the CVS/SVN ID, but not the class comment. Check the file and class comments in the example file. 65 | ERROR | Expected 1 space before variable type 66 | ERROR | Last parameter comment requires a blank newline after it 66 | ERROR | Expected 1 space before variable type 80 | ERROR | Last parameter comment requires a blank newline after it 80 | ERROR | Expected 1 space before variable type [MC] => To the best of my understanding I believe that none of the above should be reported as errors, not even as warning. I found no specific instructions in the PEAR manual requiring specific space counts before variable types, or newlines after the last parameter. Looking at the PEAR example: http://pear.php.net/manual/en/standards..sample.php, you will note that what is after the tags is aligned in the file and line DocBlocks but not in the function DocBlocks, even though some tags are the same. My interpretation is that there is some freedom with regards to alignments within a DocBlock. When there is a lack of a written standard, the example file is used to determine what the standard is. The errors that PHPCS is throwing are actually wrong because PHPCS has become confused with the indentation. I will look into that problem. But the indentation does still not conform to the sample file, which is why I made some changes to it in the last file I attached. Greg ____________________________________________________________________________________ Looking for a deal? Find great prices on flights and hotels with Yahoo! FareChase. http://farechase.yahoo.com/ ____________________________________________________________________________________ Need a vacation? Get great deals to amazing places on Yahoo! Travel. http://travel.yahoo.com/

Looking at the page or class docblocks in http://pear.php.net/manual/en/standards.sample.php, the tags contents are aligned which is fine: * @category CategoryName * @package PackageName * @author Original Author <author@example.com> * @author Another Author <another@example.com> * @copyright 1997-2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version CVS: $Id:$ * @link http://pear.php.net/package/PackageName * @see NetOther, Net_Sample::Net_Sample() * @since File available since Release 1.2.0 * @deprecated File deprecated in Release 2.0.0 Looking at the function docblock, the tags contents are not aligned after the tag keywords (there is just one space), which looks like a documentation error (please correct me if I am wrong).: * @param string $arg1 the string to quote * @param int $arg2 an integer of how many problems happened. * Indent to the description's starting point * for long ones. * * @return int the integer of the set mode used. FALSE if foo * foo could not be set. * @throws exceptionclass [description] * * @access public * @static * @see Net_Sample::$foo, Net_Other::someMethod() * @since Method available since Release 1.2.0 * @deprecated Method deprecated in Release 2.0.0 Should we expect this (#1): all contents are aligned on the longest tag keyword as in the page and class docblocks (as PHP_DocBlockGenerator generates docblocks)? * @param string $arg1 the string to quote * @param int $arg2 an integer of how many problems happened. * Indent to the description's starting point * for long ones. * * @return int the integer of the set mode used. FALSE if foo * foo could not be set. * @throws exceptionclass [description] * * @access public * @static * @see Net_Sample::$foo, Net_Other::someMethod() * @since Method available since Release 1.2.0 * @deprecated Method deprecated in Release 2.0.0 or that (#2): the parameter contents are aligned separately from the other tags (as PHP_CodeSniffer would expect)? * @param string $arg1 the string to quote * @param int $arg2 an integer of how many problems happened. * Indent to the description's starting point * for long ones. * * @return int the integer of the set mode used. FALSE if foo * foo could not be set. * @throws exceptionclass [description] * * @access public * @static * @see Net_Sample::$foo, Net_Other::someMethod() * @since Method available since Release 1.2.0 * @deprecated Method deprecated in Release 2.0.0 Also, is it mandatory or recommended or optional to add an empty line after the last parameter?
« previous php.pear.qa (#4458) next »