diff --git a/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php b/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php index e417c83508..e9fe65757f 100644 --- a/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php +++ b/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php @@ -201,12 +201,11 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) }//end if // Only want to check multi-keyword structures from here on. - if ($tokens[$stackPtr]['code'] === T_TRY - || $tokens[$stackPtr]['code'] === T_DO - ) { + if ($tokens[$stackPtr]['code'] === T_DO) { $closer = $tokens[$stackPtr]['scope_closer']; } else if ($tokens[$stackPtr]['code'] === T_ELSE || $tokens[$stackPtr]['code'] === T_ELSEIF + || $tokens[$stackPtr]['code'] === T_CATCH ) { $closer = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true); if ($closer === false || $tokens[$closer]['code'] !== T_CLOSE_CURLY_BRACKET) { diff --git a/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.inc b/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.inc index f9e36f9032..0f2f1dff59 100644 --- a/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.inc +++ b/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.inc @@ -144,3 +144,13 @@ elseif ($a == 6) : else : echo "a is neither 5 nor 6"; endif; + +try { + // try body +} +catch (FirstExceptionType $e) { + // catch body +} +catch (OtherExceptionType $e) { + // catch body +} diff --git a/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.inc.fixed b/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.inc.fixed index 1c1be5b38f..644501285f 100644 --- a/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.inc.fixed +++ b/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.inc.fixed @@ -147,3 +147,11 @@ elseif ($a == 6) : else : echo "a is neither 5 nor 6"; endif; + +try { + // try body +} catch (FirstExceptionType $e) { + // catch body +} catch (OtherExceptionType $e) { + // catch body +} diff --git a/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php b/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php index 1e023eed9b..c29984f61e 100644 --- a/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php +++ b/CodeSniffer/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php @@ -73,8 +73,10 @@ public function getErrorList($testFile='ControlSignatureUnitTest.inc') $errors[122] = 1; $errors[130] = 2; $errors[134] = 1; + $errors[150] = 1; + $errors[153] = 1; } - + return $errors; }//end getErrorList() diff --git a/package.xml b/package.xml index c5189260a9..753b0ff205 100644 --- a/package.xml +++ b/package.xml @@ -45,6 +45,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> - Fixed bug #515 : Spaces in JS block incorrectly flagged as indentation error - Fixed bug #523 : Generic ScopeIndent errors for IF in FINALLY - Fixed bug #527 : Closure inside IF statement is not tokenized correctly + - Fixed bug #551 : Multiple catch blocks not checked in Squiz.ControlStructures.ControlSignature sniff