Skip to content

Commit

Permalink
Fixed ReferenceUsedNamesOnlySniff
Browse files Browse the repository at this point in the history
  • Loading branch information
kukulich committed Jun 11, 2018
1 parent 9296d4f commit de4a6fe
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,12 @@ public function process(\PHP_CodeSniffer\Files\File $phpcsFile, $openTagPointer)
if ($reference->fromDocComment) {
$fixedDocComment = preg_replace_callback('~(\\s|\|)(' . preg_quote($name, '~') . ')(\\s|\||\[|$)~', function (array $matches): string {
return $matches[1] . ltrim($matches[2], '\\\\') . $matches[3];
}, $tokens[$startPointer]['content']);
}, TokenHelper::getContent($phpcsFile, $startPointer, $reference->endPointer));

$phpcsFile->fixer->replaceToken($startPointer, $fixedDocComment);
for ($i = $startPointer; $i <= $reference->endPointer; $i++) {
$phpcsFile->fixer->replaceToken($i, '');
}
$phpcsFile->fixer->addContent($startPointer, $fixedDocComment);
} else {
$phpcsFile->fixer->replaceToken($startPointer, substr($tokens[$startPointer]['content'], 1));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/**
* @param \Some\Exception $e
* @throws \Exception
* @throws Exception
*/
function bar(\Some\Exception $e)
{
Expand Down Expand Up @@ -30,3 +30,11 @@ class Ipsum extends Bar
{

}

/**
* @return Lorem
*/
function getLorem(): Lorem
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,11 @@ class Ipsum extends \Bar
{

}

/**
* @return \Lorem
*/
function getLorem(): \Lorem
{

}

0 comments on commit de4a6fe

Please sign in to comment.