From 11db09a3038861154bd4bad524deb0b083208d1c Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 27 Apr 2017 15:40:02 +0200 Subject: [PATCH] TASK: Update phpdocs * Remove unnecessary docs. * Add necessary docs. --- .../Typo3Update/AbstractYamlRemovedUsage.php | 25 ++++++++++++++++++ .../RemovedByYamlConfiguration.php | 14 ++++++++++ .../Removed/AbstractGenericPhpUsage.php | 24 +++++++++++++++++ .../Sniffs/Removed/AbstractGenericUsage.php | 9 +++++++ .../Removed/GenericFunctionCallSniff.php | 3 --- .../Sniffs/Removed/TypoScriptSniff.php | 26 ------------------- 6 files changed, 72 insertions(+), 29 deletions(-) diff --git a/src/Standards/Typo3Update/AbstractYamlRemovedUsage.php b/src/Standards/Typo3Update/AbstractYamlRemovedUsage.php index 84aee44..37d1c4e 100644 --- a/src/Standards/Typo3Update/AbstractYamlRemovedUsage.php +++ b/src/Standards/Typo3Update/AbstractYamlRemovedUsage.php @@ -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']; diff --git a/src/Standards/Typo3Update/RemovedByYamlConfiguration.php b/src/Standards/Typo3Update/RemovedByYamlConfiguration.php index a527e43..f1596a9 100644 --- a/src/Standards/Typo3Update/RemovedByYamlConfiguration.php +++ b/src/Standards/Typo3Update/RemovedByYamlConfiguration.php @@ -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)) { diff --git a/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericPhpUsage.php b/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericPhpUsage.php index c426721..99c81d1 100644 --- a/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericPhpUsage.php +++ b/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericPhpUsage.php @@ -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); } diff --git a/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericUsage.php b/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericUsage.php index b7ab259..557dcb5 100644 --- a/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericUsage.php +++ b/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericUsage.php @@ -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) { diff --git a/src/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff.php b/src/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff.php index 4d1784b..2915a87 100644 --- a/src/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff.php +++ b/src/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff.php @@ -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; diff --git a/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff.php b/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff.php index 419b55a..6638b34 100644 --- a/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff.php +++ b/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff.php @@ -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 - */ 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 - */ protected function getRemovedConfigFiles() { return Options::getRemovedTypoScriptConfigFiles();