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 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 = '';

View file

@ -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;
}

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.
* 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) {

View file

@ -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)
{