TASK: Cleanup before PR

* Adjust some comments and formating.
* Add missing, but used, properties.
* Shorten variables used only once.

Resolves: #36
This commit is contained in:
Daniel Siepmann 2017-03-23 16:24:22 +01:00
parent 9b3d5d9515
commit 6a115bd8d0
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4
4 changed files with 12 additions and 9 deletions

View file

@ -43,6 +43,11 @@ abstract class AbstractClassnameChecker implements PhpCsSniff
*/
public $legacyExtensions = ['Extbase', 'Fluid'];
/**
* @var Mapping
*/
protected $legacyMapping;
public function __construct()
{
$this->legacyMapping = Mapping::getInstance();
@ -205,6 +210,7 @@ abstract class AbstractClassnameChecker implements PhpCsSniff
* @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 = false)
{

View file

@ -50,9 +50,7 @@ class Mapping
}
private function __construct()
{
$mappingFile = $this->getMappingFile();
$this->mappings = require $mappingFile;
$this->mappings = require $this->getMappingFile();
}
// Singleton implementation - End
@ -112,10 +110,8 @@ class Mapping
return;
}
$mappingFile = $this->getMappingFile();
file_put_contents(
$mappingFile,
$this->getMappingFile(),
'<?php' . PHP_EOL . 'return ' . var_export($this->mappings, true) . ';'
);
}

View file

@ -92,6 +92,7 @@ class Typo3Update_Sniffs_LegacyClassnames_MissingNamespaceSniff extends Abstract
* @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)
{
@ -138,9 +139,9 @@ class Typo3Update_Sniffs_LegacyClassnames_MissingNamespaceSniff extends Abstract
}
/**
* Returns namespace, without vendor, based on legacy class name.
* Returns namespace, based on legacy class name.
*
* E.g. Tx_ExtName_FolderName_FileName -> ExtName\FolderName
* E.g. Tx_ExtName_FolderName_FileName -> VENDOR\ExtName\FolderName
*
* @param string $classname
* @return string

View file

@ -84,7 +84,7 @@ class Typo3Update_Sniffs_LegacyClassnames_MissingVendorForPluginsAndModulesSniff
if ($fix === true) {
$phpcsFile->fixer->replaceToken(
$firstArgument,
"'{$this->getVendor()}.' . " . $tokens[$firstArgument]['content']
"'{$this->getVendor()}.' . {$tokens[$firstArgument]['content']}"
);
}
}