Skip to content

Commit

Permalink
Update BlankLineBefore Return/If sniffs to be satisfied if preceded b…
Browse files Browse the repository at this point in the history
…y doc block comment
  • Loading branch information
robocoder committed Jan 4, 2013
1 parent e5174a6 commit da9e7f8
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 2 deletions.
1 change: 1 addition & 0 deletions Sniffs/Formatting/BlankLineBeforeReturnSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down
1 change: 1 addition & 0 deletions Sniffs/Instaclick/BlankLineBeforeIfSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down
14 changes: 14 additions & 0 deletions Tests/Formatting/BlankLineBeforeReturnUnitTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@ function validFunctionReturnThree()
return;
}

function validFunctionReturnFour()
{
// comment
return;
}

function validFunctionReturnFive()
{
/**
* multi-line
*/
return;
}

function invalidFunctionReturnOne()
{
echo "";
Expand Down
2 changes: 1 addition & 1 deletion Tests/Formatting/BlankLineBeforeReturnUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Symfony2_Tests_Formatting_BlankLineBeforeReturnUnitTest extends AbstractSn
public function getErrorList()
{
return array(
23 => 1,
37 => 1,
);
}

Expand Down
23 changes: 23 additions & 0 deletions Tests/Instaclick/BlankLineBeforeIfUnitTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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 "";
Expand Down
2 changes: 1 addition & 1 deletion Tests/Instaclick/BlankLineBeforeIfUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Symfony2_Tests_Instaclick_BlankLineBeforeIfUnitTest extends AbstractSniffU
public function getErrorList()
{
return array(
26 => 1,
49 => 1,
);
}

Expand Down

0 comments on commit da9e7f8

Please # to comment.