Merge pull request #52 from DanielSiepmann/feature/49-deprecated-use-statements

FEATURE: Migrate legacy class names in use statements
This commit is contained in:
Daniel Hürtgen 2017-04-04 16:39:39 +02:00 committed by GitHub
commit da0adb7d5e

View file

@ -19,10 +19,13 @@
* 02110-1301, USA. * 02110-1301, USA.
*/ */
use PHP_CodeSniffer_File as PhpCsFile;
use Typo3Update\Sniffs\LegacyClassnames\AbstractClassnameChecker; use Typo3Update\Sniffs\LegacyClassnames\AbstractClassnameChecker;
/** /**
* Migrate old legacy class names in use statements. * Detect and migrate use statements with legacy classnames..
*
* According to PSR-2, only one class per use statement is expected.
*/ */
class Typo3Update_Sniffs_LegacyClassnames_UseSniff extends AbstractClassnameChecker class Typo3Update_Sniffs_LegacyClassnames_UseSniff extends AbstractClassnameChecker
{ {
@ -35,4 +38,21 @@ class Typo3Update_Sniffs_LegacyClassnames_UseSniff extends AbstractClassnameChec
{ {
return [T_USE]; return [T_USE];
} }
/**
* Overwrite to remove prefix.
*
* @param PhpCsFile $phpcsFile
* @param int $classnamePosition
* @param string $classname
* @param bool $forceEmptyPrefix Defines whether '\\' prefix should be checked or always be left out.
*/
protected function replaceLegacyClassname(
PhpCsFile $phpcsFile,
$classnamePosition,
$classname,
$forceEmptyPrefix = true
) {
return parent::replaceLegacyClassname($phpcsFile, $classnamePosition, $classname, $forceEmptyPrefix);
}
} }