From d3b612790ce26e5f49ee7c668b2166510ab707a4 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Tue, 25 Apr 2017 13:45:46 +0200 Subject: [PATCH] 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 --- .../Feature/LegacyClassnameFeature.php | 22 +++++-------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/src/Standards/Typo3Update/Feature/LegacyClassnameFeature.php b/src/Standards/Typo3Update/Feature/LegacyClassnameFeature.php index 72edd35..c5d27f5 100644 --- a/src/Standards/Typo3Update/Feature/LegacyClassnameFeature.php +++ b/src/Standards/Typo3Update/Feature/LegacyClassnameFeature.php @@ -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.