diff --git a/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/MemberVarSpacingSniff.php b/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/MemberVarSpacingSniff.php index a41bd5c5db..f5cc07c1db 100644 --- a/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/MemberVarSpacingSniff.php +++ b/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/MemberVarSpacingSniff.php @@ -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; diff --git a/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.inc b/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.inc index 0ba0d42d70..ebaadffb1a 100644 --- a/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.inc +++ b/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.inc @@ -147,4 +147,8 @@ class Foo private $bar; + // here comes the comment + + private $caseStudy = null; + } diff --git a/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.inc.fixed b/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.inc.fixed index b4c04f135a..26109aec22 100644 --- a/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.inc.fixed +++ b/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.inc.fixed @@ -146,4 +146,7 @@ class Foo private $bar; + // here comes the comment + private $caseStudy = null; + } diff --git a/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.php b/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.php index e4f1a7bdae..003c811ac0 100644 --- a/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.php +++ b/CodeSniffer/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.php @@ -54,6 +54,7 @@ public function getErrorList() 86 => 1, 106 => 1, 115 => 1, + 150 => 1, ); }//end getErrorList() diff --git a/package.xml b/package.xml index 2fa8a01eb0..a117ad8112 100644 --- a/package.xml +++ b/package.xml @@ -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