cvs: pear /PHP_CodeSniffer package.xml /PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures SwitchDeclarationSniff.php
/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/ControlStructures SwitchDeclarationUnitTest.inc

From: Date: Mon, 12 Feb 2007 23:23:47 +0000
Subject: cvs: pear /PHP_CodeSniffer package.xml /PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures SwitchDeclarationSniff.php
/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/ControlStructures SwitchDeclarationUnitTest.inc
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-44635@lists.php.net to get a copy of this message
squiz Mon Feb 12 23:23:47 2007 UTC Modified files: /pear/PHP_CodeSniffer package.xml /pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures SwitchDeclarationSniff.php /pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/ControlStructures SwitchDeclarationUnitTest.inc Log: Fixed problem where closing brace was checked for indentation twice. THe first time it was checked, an error was being incorrectly reported. http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/package.xml?r1=1.29&r2=1.30&diff_format=u Index: pear/PHP_CodeSniffer/package.xml diff -u pear/PHP_CodeSniffer/package.xml:1.29 pear/PHP_CodeSniffer/package.xml:1.30 --- pear/PHP_CodeSniffer/package.xml:1.29 Tue Jan 30 03:49:27 2007 +++ pear/PHP_CodeSniffer/package.xml Mon Feb 12 23:23:47 2007 @@ -38,6 +38,7 @@ - Squiz FunctionCommentSniff now checks that param comments start with a captial letter and end with a full stop - Squiz FunctionSpacingSniff now reports incorrect lines below function on closing brace, not function keyword - Squiz FileCommentSniff now checks that there are no blank lines between the open PHP tag and the comment + - Fixed incorrect error with switch closing brace in Squiz SwitchDeclarationSniff - Fixed bug #9844 : throw new Exception(\n accidently reported as error but it ain't </notes> <contents> http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php?r1=1.3&r2=1.4&diff_format=u Index: pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php diff -u pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php:1.3 pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php:1.4 --- pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php:1.3 Thu Jan 11 01:09:58 2007 +++ pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php Mon Feb 12 23:23:47 2007 @@ -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: SwitchDeclarationSniff.php,v 1.3 2007/01/11 01:09:58 squiz Exp $ + * @version CVS: $Id: SwitchDeclarationSniff.php,v 1.4 2007/02/12 23:23:47 squiz Exp $ * @link http://pear.php.net/package/PHP_CodeSniffer */ @@ -108,6 +108,11 @@ // This will be handled by the next CASE statement. break; } + + if ($tokens[$nextContent]['code'] === T_CLOSE_CURLY_BRACKET) { + // This will be handled by the closing brace check. + break; + } // If the space is an empty line, we don't need to check it. if ($tokens[$nextContent]['line'] !== ($tokens[$nextSpace]['line'] + 1)) { @@ -118,7 +123,7 @@ // it needs to be indented at least 4 spaces after the CASE. $requiredIndent = ($tokens[$nextCase]['column'] + 4); if ($tokens[$nextContent]['column'] < $requiredIndent) { - $error = 'Line not indented correctly. Expected at least '.$requiredIndent.' spaces, but found '.$tokens[$nextContent]['column'].'.'; + $error = 'Line not indented correctly; expected at least '.($requiredIndent - 1).' spaces, found '.($tokens[$nextContent]['column'] - 1); $phpcsFile->addError($error, $nextContent); } }//end while @@ -170,7 +175,7 @@ // it needs to be indented at least 4 spaces after the DEFAULT. $requiredIndent = ($tokens[$default]['column'] + 4); if ($tokens[$nextContent]['column'] < $requiredIndent) { - $error = 'Line not indented correctly. Expected at least '.$requiredIndent.' spaces, but found '.$tokens[$nextContent]['column'].'.'; + $error = 'Line not indented correctly; expected at least '.$requiredIndent.' spaces, found '.$tokens[$nextContent]['column']; $phpcsFile->addError($error, $nextContent); } }//end while http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.inc?r1=1.1&r2=1.2&diff_format=u Index: pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.inc diff -u pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.inc:1.1 pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.inc:1.2 --- pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.inc:1.1 Thu Dec 21 00:48:15 2006 +++ pear/PHP_CodeSniffer/CodeSniffer/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.inc Mon Feb 12 23:23:47 2007 @@ -100,4 +100,11 @@ $something = 'hello'; $other = 'hi'; } + +// Valid +switch ($condition) { + case 'string': + $varStr = 'test'; +} + ?> \ No newline at end of file

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