TASK: Update phpdocs
* Remove unnecessary docs. * Add necessary docs.
This commit is contained in:
parent
003609342e
commit
11db09a303
6 changed files with 72 additions and 29 deletions
|
@ -23,8 +23,14 @@ namespace Typo3Update;
|
|||
use PHP_CodeSniffer_File as PhpCsFile;
|
||||
use Typo3Update\RemovedByYamlConfiguration;
|
||||
|
||||
/**
|
||||
* Base class for all classes working with removed configuration through yaml files.
|
||||
*/
|
||||
abstract class AbstractYamlRemovedUsage
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $configured;
|
||||
|
||||
public function __construct()
|
||||
|
@ -35,6 +41,9 @@ abstract class AbstractYamlRemovedUsage
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Callable
|
||||
*/
|
||||
protected function getPrepareStructureCallback()
|
||||
{
|
||||
return function (array $typo3Versions) {
|
||||
|
@ -42,10 +51,22 @@ abstract class AbstractYamlRemovedUsage
|
|||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $typo3Versions
|
||||
* @return array
|
||||
*/
|
||||
abstract protected function prepareStructure(array $typo3Versions);
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
abstract protected function getRemovedConfigFiles();
|
||||
|
||||
/**
|
||||
* @param PhpCsFile $phpcsFile
|
||||
* @param int $stackPtr
|
||||
* @param array $removed
|
||||
*/
|
||||
protected function addWarning(PhpCsFile $phpcsFile, $stackPtr, array $removed)
|
||||
{
|
||||
$phpcsFile->addWarning(
|
||||
|
@ -61,6 +82,10 @@ abstract class AbstractYamlRemovedUsage
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $config
|
||||
* @return string
|
||||
*/
|
||||
protected function getReplacement(array $config)
|
||||
{
|
||||
$newCall = $config['replacement'];
|
||||
|
|
|
@ -31,6 +31,10 @@ class RemovedByYamlConfiguration
|
|||
*/
|
||||
protected $configured = [];
|
||||
|
||||
/**
|
||||
* @param array $configFiles
|
||||
* @param Callable $prepareStructure
|
||||
*/
|
||||
public function __construct(array $configFiles, $prepareStructure)
|
||||
{
|
||||
foreach ($configFiles as $file) {
|
||||
|
@ -41,16 +45,26 @@ class RemovedByYamlConfiguration
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $identifier
|
||||
* @return bool
|
||||
*/
|
||||
public function isRemoved($identifier)
|
||||
{
|
||||
return isset($this->configured[$identifier]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getAllRemoved()
|
||||
{
|
||||
return $this->configured;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getRemoved($identifier)
|
||||
{
|
||||
if (!$this->isRemoved($identifier)) {
|
||||
|
|
|
@ -24,11 +24,18 @@ use PHP_CodeSniffer_File as PhpCsFile;
|
|||
|
||||
abstract class AbstractGenericPhpUsage extends AbstractGenericUsage
|
||||
{
|
||||
/**
|
||||
* @return int[]
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
return [T_STRING];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $typo3Versions
|
||||
* @return array
|
||||
*/
|
||||
protected function prepareStructure(array $typo3Versions)
|
||||
{
|
||||
$newStructure = [];
|
||||
|
@ -51,6 +58,11 @@ abstract class AbstractGenericPhpUsage extends AbstractGenericUsage
|
|||
return $newStructure;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PhpCsFile $phpcsFile
|
||||
* @param int $stackPtr
|
||||
* @return array
|
||||
*/
|
||||
protected function findRemoved(PhpCsFile $phpcsFile, $stackPtr)
|
||||
{
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
|
@ -104,6 +116,10 @@ abstract class AbstractGenericPhpUsage extends AbstractGenericUsage
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $identifier
|
||||
* @param array &$config
|
||||
*/
|
||||
protected function handleStatic($identifier, array &$config)
|
||||
{
|
||||
$split = preg_split('/::|->/', $identifier);
|
||||
|
@ -118,6 +134,10 @@ abstract class AbstractGenericPhpUsage extends AbstractGenericUsage
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $config
|
||||
* @return string
|
||||
*/
|
||||
protected function getIdentifier(array $config)
|
||||
{
|
||||
$name = $config['name'];
|
||||
|
@ -128,5 +148,9 @@ abstract class AbstractGenericPhpUsage extends AbstractGenericUsage
|
|||
return $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $config
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function getOldUsage(array $config);
|
||||
}
|
||||
|
|
|
@ -26,8 +26,17 @@ use Typo3Update\AbstractYamlRemovedUsage as BaseAbstractYamlRemovedUsage;
|
|||
|
||||
abstract class AbstractGenericUsage extends BaseAbstractYamlRemovedUsage implements PhpCsSniff
|
||||
{
|
||||
/**
|
||||
* @param PhpCsFile $phpcsFile
|
||||
* @param int $stackPtr
|
||||
* @return array
|
||||
*/
|
||||
abstract protected function findRemoved(PhpCsFile $phpcsFile, $stackPtr);
|
||||
|
||||
/**
|
||||
* @param PhpCsFile $phpcsFile
|
||||
* @param int $stackPtr
|
||||
*/
|
||||
public function process(PhpCsFile $phpcsFile, $stackPtr)
|
||||
{
|
||||
foreach ($this->findRemoved($phpcsFile, $stackPtr) as $removed) {
|
||||
|
|
|
@ -24,9 +24,6 @@ use Typo3Update\Options;
|
|||
use Typo3Update\Sniffs\ExtendedPhpCsSupportTrait;
|
||||
use Typo3Update\Sniffs\Removed\AbstractGenericPhpUsage;
|
||||
|
||||
/**
|
||||
* Sniff that handles all calls to removed functions.
|
||||
*/
|
||||
class Typo3Update_Sniffs_Removed_GenericFunctionCallSniff extends AbstractGenericPhpUsage
|
||||
{
|
||||
use ExtendedPhpCsSupportTrait;
|
||||
|
|
|
@ -24,9 +24,6 @@ use PHP_CodeSniffer_File as PhpCsFile;
|
|||
use Typo3Update\Options;
|
||||
use Typo3Update\Sniffs\Removed\AbstractGenericUsage;
|
||||
|
||||
/**
|
||||
* Check usage of removed or breaking changed TypoScript.
|
||||
*/
|
||||
class Typo3Update_Sniffs_Removed_TypoScriptSniff extends AbstractGenericUsage
|
||||
{
|
||||
/**
|
||||
|
@ -37,11 +34,6 @@ class Typo3Update_Sniffs_Removed_TypoScriptSniff extends AbstractGenericUsage
|
|||
'TYPOSCRIPT',
|
||||
];
|
||||
|
||||
/**
|
||||
* Returns the token types that this sniff is interested in.
|
||||
*
|
||||
* @return array<int>
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
return [
|
||||
|
@ -50,12 +42,6 @@ class Typo3Update_Sniffs_Removed_TypoScriptSniff extends AbstractGenericUsage
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares structure from config for later usage.
|
||||
*
|
||||
* @param array $typo3Versions
|
||||
* @return array
|
||||
*/
|
||||
protected function prepareStructure(array $typo3Versions)
|
||||
{
|
||||
$newStructure = [];
|
||||
|
@ -80,13 +66,6 @@ class Typo3Update_Sniffs_Removed_TypoScriptSniff extends AbstractGenericUsage
|
|||
return $newStructure;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the current token is removed.
|
||||
*
|
||||
* @param PhpCsFile $phpcsFile
|
||||
* @param int $stackPtr
|
||||
* @return bool
|
||||
*/
|
||||
protected function findRemoved(PhpCsFile $phpcsFile, $stackPtr)
|
||||
{
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
|
@ -105,11 +84,6 @@ class Typo3Update_Sniffs_Removed_TypoScriptSniff extends AbstractGenericUsage
|
|||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return file names containing removed configurations.
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
protected function getRemovedConfigFiles()
|
||||
{
|
||||
return Options::getRemovedTypoScriptConfigFiles();
|
||||
|
|
Loading…
Reference in a new issue