Skip to content

Commit

Permalink
Fixed bug #893 : Squiz.WhiteSpace.MemberVarSpacing.AfterComment fails…
Browse files Browse the repository at this point in the history
… to fix error when comment is not a docblock
  • Loading branch information
gsherwood committed May 12, 2016
1 parent e2e4756 commit 0434c48
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ protected function processMemberVar(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
$fix = $phpcsFile->addFixableError($error, $prev, 'AfterComment', $data);
if ($fix === true) {
$phpcsFile->fixer->beginChangeset();
// Inline comments have the newline included in the content but
// docblock do not.
if ($tokens[$prev]['code'] === T_COMMENT) {
$phpcsFile->fixer->replaceToken($prev, rtrim($tokens[$prev]['content']));
}

for ($i = ($prev + 1); $i <= $stackPtr; $i++) {
if ($tokens[$i]['line'] === $tokens[$stackPtr]['line']) {
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,8 @@ class Foo

private $bar;

// here comes the comment

private $caseStudy = null;

}
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,7 @@ class Foo

private $bar;

// here comes the comment
private $caseStudy = null;

}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public function getErrorList()
86 => 1,
106 => 1,
115 => 1,
150 => 1,
);

}//end getErrorList()
Expand Down
1 change: 1 addition & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
- Fixed bug #973 : Anonymous class declaration and PSR1.Files.SideEffects.FoundWithSymbols
- Fixed bug #974 : Error when file ends with "function"
- Fixed bug #979 : Anonymous function with return type hint is not refactored as expected
- Fixed bug #893 : Squiz.WhiteSpace.MemberVarSpacing.AfterComment fails to fix error when comment is not a docblock
</notes>
<contents>
<dir name="/">
Expand Down

0 comments on commit 0434c48

Please sign in to comment.