diff --git a/Sniffs/Formatting/BlankLineBeforeReturnSniff.php b/Sniffs/Formatting/BlankLineBeforeReturnSniff.php index 0586e97..604811c 100644 --- a/Sniffs/Formatting/BlankLineBeforeReturnSniff.php +++ b/Sniffs/Formatting/BlankLineBeforeReturnSniff.php @@ -67,6 +67,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) while ($current >= 0 && $tokens[$current]['line'] >= $previousLine) { if ($tokens[$current]['line'] == $previousLine && $tokens[$current]['type'] !== 'T_WHITESPACE' + && $tokens[$current]['type'] !== 'T_DOC_COMMENT' && $tokens[$current]['type'] !== 'T_COMMENT' ) { $prevLineTokens[] = $tokens[$current]['type']; diff --git a/Sniffs/Instaclick/BlankLineBeforeIfSniff.php b/Sniffs/Instaclick/BlankLineBeforeIfSniff.php index c597a50..58ca960 100644 --- a/Sniffs/Instaclick/BlankLineBeforeIfSniff.php +++ b/Sniffs/Instaclick/BlankLineBeforeIfSniff.php @@ -67,6 +67,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) while ($current >= 0 && $tokens[$current]['line'] >= $previousLine) { if ($tokens[$current]['line'] == $previousLine && $tokens[$current]['type'] !== 'T_WHITESPACE' + && $tokens[$current]['type'] !== 'T_DOC_COMMENT' && $tokens[$current]['type'] !== 'T_COMMENT' ) { $prevLineTokens[] = $tokens[$current]['type']; diff --git a/Tests/Formatting/BlankLineBeforeReturnUnitTest.inc b/Tests/Formatting/BlankLineBeforeReturnUnitTest.inc index 4e2a58d..2040155 100644 --- a/Tests/Formatting/BlankLineBeforeReturnUnitTest.inc +++ b/Tests/Formatting/BlankLineBeforeReturnUnitTest.inc @@ -17,6 +17,20 @@ function validFunctionReturnThree() return; } +function validFunctionReturnFour() +{ + // comment + return; +} + +function validFunctionReturnFive() +{ + /** + * multi-line + */ + return; +} + function invalidFunctionReturnOne() { echo ""; diff --git a/Tests/Formatting/BlankLineBeforeReturnUnitTest.php b/Tests/Formatting/BlankLineBeforeReturnUnitTest.php index ed48ac5..65b88b2 100644 --- a/Tests/Formatting/BlankLineBeforeReturnUnitTest.php +++ b/Tests/Formatting/BlankLineBeforeReturnUnitTest.php @@ -38,7 +38,7 @@ class Symfony2_Tests_Formatting_BlankLineBeforeReturnUnitTest extends AbstractSn public function getErrorList() { return array( - 23 => 1, + 37 => 1, ); } diff --git a/Tests/Instaclick/BlankLineBeforeIfUnitTest.inc b/Tests/Instaclick/BlankLineBeforeIfUnitTest.inc index 04ff974..d2bedca 100644 --- a/Tests/Instaclick/BlankLineBeforeIfUnitTest.inc +++ b/Tests/Instaclick/BlankLineBeforeIfUnitTest.inc @@ -20,6 +20,29 @@ function validFunctionIfThree() } } +function validFunctionIfFour() +{ + /* comment */ + if (true) { + } +} + +function validFunctionIfFive() +{ + // single line comment + if (true) { + } +} + +function validFunctionIfSix() +{ + /** + * multi-line doc block + */ + if (true) { + } +} + function invalidFunctionIfOne() { echo ""; diff --git a/Tests/Instaclick/BlankLineBeforeIfUnitTest.php b/Tests/Instaclick/BlankLineBeforeIfUnitTest.php index f6a0bbe..4f536d3 100644 --- a/Tests/Instaclick/BlankLineBeforeIfUnitTest.php +++ b/Tests/Instaclick/BlankLineBeforeIfUnitTest.php @@ -38,7 +38,7 @@ class Symfony2_Tests_Instaclick_BlankLineBeforeIfUnitTest extends AbstractSniffU public function getErrorList() { return array( - 26 => 1, + 49 => 1, ); }