TASK: Make inline replacements work again

* As sometimes not the whole token should be replaces, but only the
  classname within the token, we replace them always this way.
* Before the refactoring, that was done in the concrete sniffs.
* Affected are e.g. php doc comments.

Relates: #72
This commit is contained in:
Daniel Siepmann 2017-04-25 13:45:46 +02:00
parent 8572740fd1
commit d3b612790c
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4

View file

@ -194,26 +194,14 @@ class LegacyClassnameFeature implements FeatureInterface
$phpcsFile->fixer->replaceToken(
$classnamePosition,
$this->getTokenForReplacement($prefix . $this->getNewClassname($classname), $classname, $phpcsFile)
str_replace(
$classname,
$prefix . $this->getNewClassname($classname),
$phpcsFile->getTokens()[$classnamePosition]['content']
)
);
}
/**
* String to use for replacing / fixing the token.
* Default is class name itself, can be overwritten in sniff for special behaviour.
*
* @param string $newClassname
* @param string $originalClassname
* @param PhpCsFile $phpcsFile
* @return string
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter) We need to match the signature.
*/
protected function getTokenForReplacement($newClassname, $originalClassname, PhpCsFile $phpcsFile)
{
return $newClassname;
}
/**
* Use this inside your getTokenForReplacement if $classname is inside a string.
* Strings will be converted to single quotes.