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:
parent
8572740fd1
commit
d3b612790c
1 changed files with 5 additions and 17 deletions
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue