TASK: Update phpdocs

* Remove unnecessary docs.
* Add necessary docs.
This commit is contained in:
Daniel Siepmann 2017-04-27 15:40:02 +02:00
parent 003609342e
commit 11db09a303
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4
6 changed files with 72 additions and 29 deletions

View file

@ -23,8 +23,14 @@ namespace Typo3Update;
use PHP_CodeSniffer_File as PhpCsFile; use PHP_CodeSniffer_File as PhpCsFile;
use Typo3Update\RemovedByYamlConfiguration; use Typo3Update\RemovedByYamlConfiguration;
/**
* Base class for all classes working with removed configuration through yaml files.
*/
abstract class AbstractYamlRemovedUsage abstract class AbstractYamlRemovedUsage
{ {
/**
* @var array
*/
protected $configured; protected $configured;
public function __construct() public function __construct()
@ -35,6 +41,9 @@ abstract class AbstractYamlRemovedUsage
); );
} }
/**
* @return \Callable
*/
protected function getPrepareStructureCallback() protected function getPrepareStructureCallback()
{ {
return function (array $typo3Versions) { return function (array $typo3Versions) {
@ -42,10 +51,22 @@ abstract class AbstractYamlRemovedUsage
}; };
} }
/**
* @param array $typo3Versions
* @return array
*/
abstract protected function prepareStructure(array $typo3Versions); abstract protected function prepareStructure(array $typo3Versions);
/**
* @return array
*/
abstract protected function getRemovedConfigFiles(); abstract protected function getRemovedConfigFiles();
/**
* @param PhpCsFile $phpcsFile
* @param int $stackPtr
* @param array $removed
*/
protected function addWarning(PhpCsFile $phpcsFile, $stackPtr, array $removed) protected function addWarning(PhpCsFile $phpcsFile, $stackPtr, array $removed)
{ {
$phpcsFile->addWarning( $phpcsFile->addWarning(
@ -61,6 +82,10 @@ abstract class AbstractYamlRemovedUsage
); );
} }
/**
* @param array $config
* @return string
*/
protected function getReplacement(array $config) protected function getReplacement(array $config)
{ {
$newCall = $config['replacement']; $newCall = $config['replacement'];

View file

@ -31,6 +31,10 @@ class RemovedByYamlConfiguration
*/ */
protected $configured = []; protected $configured = [];
/**
* @param array $configFiles
* @param Callable $prepareStructure
*/
public function __construct(array $configFiles, $prepareStructure) public function __construct(array $configFiles, $prepareStructure)
{ {
foreach ($configFiles as $file) { foreach ($configFiles as $file) {
@ -41,16 +45,26 @@ class RemovedByYamlConfiguration
} }
} }
/**
* @param string $identifier
* @return bool
*/
public function isRemoved($identifier) public function isRemoved($identifier)
{ {
return isset($this->configured[$identifier]); return isset($this->configured[$identifier]);
} }
/**
* @return array
*/
public function getAllRemoved() public function getAllRemoved()
{ {
return $this->configured; return $this->configured;
} }
/**
* @return array
*/
public function getRemoved($identifier) public function getRemoved($identifier)
{ {
if (!$this->isRemoved($identifier)) { if (!$this->isRemoved($identifier)) {

View file

@ -24,11 +24,18 @@ use PHP_CodeSniffer_File as PhpCsFile;
abstract class AbstractGenericPhpUsage extends AbstractGenericUsage abstract class AbstractGenericPhpUsage extends AbstractGenericUsage
{ {
/**
* @return int[]
*/
public function register() public function register()
{ {
return [T_STRING]; return [T_STRING];
} }
/**
* @param array $typo3Versions
* @return array
*/
protected function prepareStructure(array $typo3Versions) protected function prepareStructure(array $typo3Versions)
{ {
$newStructure = []; $newStructure = [];
@ -51,6 +58,11 @@ abstract class AbstractGenericPhpUsage extends AbstractGenericUsage
return $newStructure; return $newStructure;
} }
/**
* @param PhpCsFile $phpcsFile
* @param int $stackPtr
* @return array
*/
protected function findRemoved(PhpCsFile $phpcsFile, $stackPtr) protected function findRemoved(PhpCsFile $phpcsFile, $stackPtr)
{ {
$tokens = $phpcsFile->getTokens(); $tokens = $phpcsFile->getTokens();
@ -104,6 +116,10 @@ abstract class AbstractGenericPhpUsage extends AbstractGenericUsage
); );
} }
/**
* @param string $identifier
* @param array &$config
*/
protected function handleStatic($identifier, array &$config) protected function handleStatic($identifier, array &$config)
{ {
$split = preg_split('/::|->/', $identifier); $split = preg_split('/::|->/', $identifier);
@ -118,6 +134,10 @@ abstract class AbstractGenericPhpUsage extends AbstractGenericUsage
} }
} }
/**
* @param array $config
* @return string
*/
protected function getIdentifier(array $config) protected function getIdentifier(array $config)
{ {
$name = $config['name']; $name = $config['name'];
@ -128,5 +148,9 @@ abstract class AbstractGenericPhpUsage extends AbstractGenericUsage
return $name; return $name;
} }
/**
* @param array $config
* @return string
*/
abstract protected function getOldUsage(array $config); abstract protected function getOldUsage(array $config);
} }

View file

@ -26,8 +26,17 @@ use Typo3Update\AbstractYamlRemovedUsage as BaseAbstractYamlRemovedUsage;
abstract class AbstractGenericUsage extends BaseAbstractYamlRemovedUsage implements PhpCsSniff abstract class AbstractGenericUsage extends BaseAbstractYamlRemovedUsage implements PhpCsSniff
{ {
/**
* @param PhpCsFile $phpcsFile
* @param int $stackPtr
* @return array
*/
abstract protected function findRemoved(PhpCsFile $phpcsFile, $stackPtr); abstract protected function findRemoved(PhpCsFile $phpcsFile, $stackPtr);
/**
* @param PhpCsFile $phpcsFile
* @param int $stackPtr
*/
public function process(PhpCsFile $phpcsFile, $stackPtr) public function process(PhpCsFile $phpcsFile, $stackPtr)
{ {
foreach ($this->findRemoved($phpcsFile, $stackPtr) as $removed) { foreach ($this->findRemoved($phpcsFile, $stackPtr) as $removed) {

View file

@ -24,9 +24,6 @@ use Typo3Update\Options;
use Typo3Update\Sniffs\ExtendedPhpCsSupportTrait; use Typo3Update\Sniffs\ExtendedPhpCsSupportTrait;
use Typo3Update\Sniffs\Removed\AbstractGenericPhpUsage; use Typo3Update\Sniffs\Removed\AbstractGenericPhpUsage;
/**
* Sniff that handles all calls to removed functions.
*/
class Typo3Update_Sniffs_Removed_GenericFunctionCallSniff extends AbstractGenericPhpUsage class Typo3Update_Sniffs_Removed_GenericFunctionCallSniff extends AbstractGenericPhpUsage
{ {
use ExtendedPhpCsSupportTrait; use ExtendedPhpCsSupportTrait;

View file

@ -24,9 +24,6 @@ use PHP_CodeSniffer_File as PhpCsFile;
use Typo3Update\Options; use Typo3Update\Options;
use Typo3Update\Sniffs\Removed\AbstractGenericUsage; use Typo3Update\Sniffs\Removed\AbstractGenericUsage;
/**
* Check usage of removed or breaking changed TypoScript.
*/
class Typo3Update_Sniffs_Removed_TypoScriptSniff extends AbstractGenericUsage class Typo3Update_Sniffs_Removed_TypoScriptSniff extends AbstractGenericUsage
{ {
/** /**
@ -37,11 +34,6 @@ class Typo3Update_Sniffs_Removed_TypoScriptSniff extends AbstractGenericUsage
'TYPOSCRIPT', 'TYPOSCRIPT',
]; ];
/**
* Returns the token types that this sniff is interested in.
*
* @return array<int>
*/
public function register() public function register()
{ {
return [ 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) protected function prepareStructure(array $typo3Versions)
{ {
$newStructure = []; $newStructure = [];
@ -80,13 +66,6 @@ class Typo3Update_Sniffs_Removed_TypoScriptSniff extends AbstractGenericUsage
return $newStructure; return $newStructure;
} }
/**
* Check whether the current token is removed.
*
* @param PhpCsFile $phpcsFile
* @param int $stackPtr
* @return bool
*/
protected function findRemoved(PhpCsFile $phpcsFile, $stackPtr) protected function findRemoved(PhpCsFile $phpcsFile, $stackPtr)
{ {
$tokens = $phpcsFile->getTokens(); $tokens = $phpcsFile->getTokens();
@ -105,11 +84,6 @@ class Typo3Update_Sniffs_Removed_TypoScriptSniff extends AbstractGenericUsage
return []; return [];
} }
/**
* Return file names containing removed configurations.
*
* @return array<string>
*/
protected function getRemovedConfigFiles() protected function getRemovedConfigFiles()
{ {
return Options::getRemovedTypoScriptConfigFiles(); return Options::getRemovedTypoScriptConfigFiles();