cvs: pear /PHP_CodeSniffer package.xml /PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting DocCommentAlignmentSniff.php
/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Commenting DocCommentAlignmentUnitTest.inc DocCommentAlignmentUnitTest.php

From: Date: Sat, 12 Jan 2008 13:47:32 +0000
Subject: cvs: pear /PHP_CodeSniffer package.xml /PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting DocCommentAlignmentSniff.php
/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Commenting DocCommentAlignmentUnitTest.inc DocCommentAlignmentUnitTest.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-50264@lists.php.net to get a copy of this message
squiz Sat Jan 12 13:47:32 2008 UTC Modified files: /pear/PHP_CodeSniffer package.xml /pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting DocCommentAlignmentSniff.php /pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Commenting DocCommentAlignmentUnitTest.inc DocCommentAlignmentUnitTest.php Log: Squiz DocCommentAlignmentSniff now checks for a single space before tags inside docblocks. This sniff will end up in the PEAR standard, so it will be moved into the Generic standard sometime in the future. http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/package.xml?r1=1.200&r2=1.201&diff_format=u Index: pear/PHP_CodeSniffer/package.xml diff -u pear/PHP_CodeSniffer/package.xml:1.200 pear/PHP_CodeSniffer/package.xml:1.201 --- pear/PHP_CodeSniffer/package.xml:1.200 Sat Jan 12 08:45:13 2008 +++ pear/PHP_CodeSniffer/package.xml Sat Jan 12 13:47:32 2008 @@ -33,6 +33,7 @@ <license uri="http://matrix.squiz.net/developer/tools/php_cs/licence">BSD License</license> <notes> - Squiz ArrayDeclarationSniff now throws error if the array keyword is followed by a space + - Squiz DocCommentAlignmentSniff now checks for a single space before tags inside docblocks - Fixed a problem that caused the parentheses map to sometimes contain incorrect values - Fixed bug #12767 : Cant run phpcs from dir with PEAR subdir - Fixed bug #12773 : Reserved variables are not detected in strings http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php?r1=1.4&r2=1.5&diff_format=u Index: pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php diff -u pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php:1.4 pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php:1.5 --- pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php:1.4 Mon Jul 23 01:47:53 2007 +++ pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php Sat Jan 12 13:47:32 2008 @@ -10,7 +10,7 @@ * @author Marc McIntyre <mmcintyre@squiz.net> * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600) * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version CVS: $Id: DocCommentAlignmentSniff.php,v 1.4 2007/07/23 01:47:53 squiz Exp $ + * @version CVS: $Id: DocCommentAlignmentSniff.php,v 1.5 2008/01/12 13:47:32 squiz Exp $ * @link http://pear.php.net/package/PHP_CodeSniffer */ @@ -86,7 +86,29 @@ $requiredColumn += $tokens[$stackPtr]['column']; foreach ($comments as $commentPointer) { - $currentColumn = strpos($tokens[$commentPointer]['content'], '*'); + // Check the spacing after each asterisk. + $content = $tokens[$commentPointer]['content']; + $firstChar = substr($content, 0, 1); + $lastChar = substr($content, -1); + if ($firstChar !== '/' && $lastChar !== '/') { + $matches = array(); + preg_match('|^(\s+)?\*(\s+)?@|', $content, $matches); + if (empty($matches) === false) { + if (isset($matches[2]) === false) { + $error = "Expected 1 space between asterisk and tag; 0 found"; + $phpcsFile->addError($error, $commentPointer); + } else { + $length = strlen($matches[2]); + if ($length !== 1) { + $error = "Expected 1 space between asterisk and tag; $length found"; + $phpcsFile->addError($error, $commentPointer); + } + } + } + }//end foreach + + // Check the alignment of each asterisk. + $currentColumn = strpos($content, '*'); $currentColumn += $tokens[$commentPointer]['column']; if ($currentColumn === $requiredColumn) { @@ -99,7 +121,7 @@ $found = ($currentColumn - 1); $error = "Expected $expected before asterisk; $found found"; $phpcsFile->addError($error, $commentPointer); - } + }//end foreach }//end process() http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.inc?r1=1.1&r2=1.2&diff_format=u Index: pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.inc diff -u pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.inc:1.1 pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.inc:1.2 --- pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.inc:1.1 Tue Jan 2 00:10:14 2007 +++ pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.inc Sat Jan 12 13:47:32 2008 @@ -8,21 +8,21 @@ /** * Some info about the function here. * - * @return void + *@return void */ function myFunction() {} } /** - * Some info about the class here + * Some info about the class here * */ class MyClass { /** - * Some info about the function here. + *Some info about the function here. * - * @return void + * @return void */ function myFunction() {} } http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.php?r1=1.1&r2=1.2&diff_format=u Index: pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.php diff -u pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.php:1.1 pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.php:1.2 --- pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.php:1.1 Tue Jan 2 00:10:14 2007 +++ pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.php Sat Jan 12 13:47:32 2008 @@ -10,7 +10,7 @@ * @author Marc McIntyre <mmcintyre@squiz.net> * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600) * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version CVS: $Id: DocCommentAlignmentUnitTest.php,v 1.1 2007/01/02 00:10:14 squiz Exp $ + * @version CVS: $Id: DocCommentAlignmentUnitTest.php,v 1.2 2008/01/12 13:47:32 squiz Exp $ * @link http://pear.php.net/package/PHP_CodeSniffer */ @@ -44,12 +44,13 @@ public function getErrorList() { return array( + 11 => 1, 17 => 1, 18 => 1, 19 => 1, 23 => 1, 24 => 1, - 25 => 1, + 25 => 2, 26 => 1, 32 => 1, 33 => 1,

« previous php.pear.cvs (#50264) next »