diff --git a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/AbstractClassnameChecker.php b/src/Standards/Typo3Update/Sniffs/LegacyClassnames/AbstractClassnameChecker.php index a01da60..2e9896b 100644 --- a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/AbstractClassnameChecker.php +++ b/src/Standards/Typo3Update/Sniffs/LegacyClassnames/AbstractClassnameChecker.php @@ -212,8 +212,12 @@ abstract class AbstractClassnameChecker implements PhpCsSniff * @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 = false) - { + protected function replaceLegacyClassname( + PhpCsFile $phpcsFile, + $classnamePosition, + $classname, + $forceEmptyPrefix = false + ) { $prefix = '\\'; if ($forceEmptyPrefix || $phpcsFile->getTokens()[$classnamePosition -1]['code'] === T_NS_SEPARATOR) { $prefix = ''; diff --git a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/InlineCommentSniff.php b/src/Standards/Typo3Update/Sniffs/LegacyClassnames/InlineCommentSniff.php index 2b7caaf..fcf9229 100644 --- a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/InlineCommentSniff.php +++ b/src/Standards/Typo3Update/Sniffs/LegacyClassnames/InlineCommentSniff.php @@ -60,7 +60,8 @@ class Typo3Update_Sniffs_LegacyClassnames_InlineCommentSniff extends AbstractCla $this->originalTokenContent = $tokens[$stackPtr]['content']; $commentParts = preg_split('/\s+/', $this->originalTokenContent); - if (count($commentParts) !== 5 || $commentParts[1] !== '@var' || ($commentParts[2][0] !== '$' && $commentParts[3][0] !== '$')) { + if (count($commentParts) !== 5 || $commentParts[1] !== '@var' + || ($commentParts[2][0] !== '$' && $commentParts[3][0] !== '$')) { return; } diff --git a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/Mapping.php b/src/Standards/Typo3Update/Sniffs/LegacyClassnames/Mapping.php index c7c455e..16a8acf 100644 --- a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/Mapping.php +++ b/src/Standards/Typo3Update/Sniffs/LegacyClassnames/Mapping.php @@ -28,12 +28,17 @@ use Typo3Update\Sniffs\OptionsAccessTrait; * Will check the configured file for whether a class is legacy and provides further methods. * Also can update to add new migrated class names. */ -class Mapping +final class Mapping { use OptionsAccessTrait; // Singleton implementation - Start static protected $instance = null; + /** + * Get the singleton instance. + * + * @return Mapping + */ public static function getInstance() { if (static::$instance === null) { diff --git a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingNamespaceSniff.php b/src/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingNamespaceSniff.php index 3e3acac..3f8a197 100644 --- a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingNamespaceSniff.php +++ b/src/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingNamespaceSniff.php @@ -59,11 +59,12 @@ class Typo3Update_Sniffs_LegacyClassnames_MissingNamespaceSniff extends Abstract return; } $classnamePosition = $phpcsFile->findNext(T_STRING, $stackPtr); + if ($classnamePosition === false) { return; } - $classname = $tokens[$classnamePosition]['content']; + $classname = $tokens[$classnamePosition]['content']; $this->addFixableError($phpcsFile, $classnamePosition, $classname); } @@ -94,8 +95,12 @@ class Typo3Update_Sniffs_LegacyClassnames_MissingNamespaceSniff extends Abstract * @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) - { + protected function replaceLegacyClassname( + PhpCsFile $phpcsFile, + $classnamePosition, + $classname, + $forceEmptyPrefix = true + ) { parent::replaceLegacyClassname($phpcsFile, $classnamePosition, $classname, $forceEmptyPrefix); $tokens = $phpcsFile->getTokens(); @@ -118,7 +123,7 @@ class Typo3Update_Sniffs_LegacyClassnames_MissingNamespaceSniff extends Abstract /** * @param PhpCsFile $phpcsFile - * @return int + * @return int|false */ protected function getNamespacePosition(PhpCsFile $phpcsFile) {