TASK: Fix quality issues

This commit is contained in:
Daniel Siepmann 2017-03-23 16:40:03 +01:00
parent 6a115bd8d0
commit 842a54d5d9
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4
4 changed files with 23 additions and 8 deletions

View file

@ -212,8 +212,12 @@ abstract class AbstractClassnameChecker implements PhpCsSniff
* @param string $classname * @param string $classname
* @param bool $forceEmptyPrefix Defines whether '\\' prefix should be checked or always be left out. * @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 = '\\'; $prefix = '\\';
if ($forceEmptyPrefix || $phpcsFile->getTokens()[$classnamePosition -1]['code'] === T_NS_SEPARATOR) { if ($forceEmptyPrefix || $phpcsFile->getTokens()[$classnamePosition -1]['code'] === T_NS_SEPARATOR) {
$prefix = ''; $prefix = '';

View file

@ -60,7 +60,8 @@ class Typo3Update_Sniffs_LegacyClassnames_InlineCommentSniff extends AbstractCla
$this->originalTokenContent = $tokens[$stackPtr]['content']; $this->originalTokenContent = $tokens[$stackPtr]['content'];
$commentParts = preg_split('/\s+/', $this->originalTokenContent); $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; return;
} }

View file

@ -28,12 +28,17 @@ use Typo3Update\Sniffs\OptionsAccessTrait;
* Will check the configured file for whether a class is legacy and provides further methods. * Will check the configured file for whether a class is legacy and provides further methods.
* Also can update to add new migrated class names. * Also can update to add new migrated class names.
*/ */
class Mapping final class Mapping
{ {
use OptionsAccessTrait; use OptionsAccessTrait;
// Singleton implementation - Start // Singleton implementation - Start
static protected $instance = null; static protected $instance = null;
/**
* Get the singleton instance.
*
* @return Mapping
*/
public static function getInstance() public static function getInstance()
{ {
if (static::$instance === null) { if (static::$instance === null) {

View file

@ -59,11 +59,12 @@ class Typo3Update_Sniffs_LegacyClassnames_MissingNamespaceSniff extends Abstract
return; return;
} }
$classnamePosition = $phpcsFile->findNext(T_STRING, $stackPtr); $classnamePosition = $phpcsFile->findNext(T_STRING, $stackPtr);
if ($classnamePosition === false) { if ($classnamePosition === false) {
return; return;
} }
$classname = $tokens[$classnamePosition]['content'];
$classname = $tokens[$classnamePosition]['content'];
$this->addFixableError($phpcsFile, $classnamePosition, $classname); $this->addFixableError($phpcsFile, $classnamePosition, $classname);
} }
@ -94,8 +95,12 @@ class Typo3Update_Sniffs_LegacyClassnames_MissingNamespaceSniff extends Abstract
* @param string $classname * @param string $classname
* @param bool $forceEmptyPrefix Defines whether '\\' prefix should be checked or always be left out. * @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); parent::replaceLegacyClassname($phpcsFile, $classnamePosition, $classname, $forceEmptyPrefix);
$tokens = $phpcsFile->getTokens(); $tokens = $phpcsFile->getTokens();
@ -118,7 +123,7 @@ class Typo3Update_Sniffs_LegacyClassnames_MissingNamespaceSniff extends Abstract
/** /**
* @param PhpCsFile $phpcsFile * @param PhpCsFile $phpcsFile
* @return int * @return int|false
*/ */
protected function getNamespacePosition(PhpCsFile $phpcsFile) protected function getNamespacePosition(PhpCsFile $phpcsFile)
{ {