TASK: Refactor existing sniffs to work again
* As we migrated trait to class, all sniffs have to extend instead to use the new class. * Also make PhpCsFile import and type hints the same across all sniffs. Relates: #36
This commit is contained in:
parent
f91d3240e5
commit
eaa99973b1
12 changed files with 48 additions and 49 deletions
|
@ -19,15 +19,16 @@
|
|||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
use PHP_CodeSniffer_File as PhpCsFile;
|
||||
use Typo3Update\Sniffs\LegacyClassnames\AbstractClassnameChecker;
|
||||
|
||||
/**
|
||||
* Migrate PHP Doc comments.
|
||||
*
|
||||
* E.g. annotations like @param or @return, see $allowedTags.
|
||||
*/
|
||||
class Typo3Update_Sniffs_LegacyClassnames_DocCommentSniff implements PHP_CodeSniffer_Sniff
|
||||
class Typo3Update_Sniffs_LegacyClassnames_DocCommentSniff extends AbstractClassnameChecker
|
||||
{
|
||||
use \Typo3Update\Sniffs\LegacyClassnames\ClassnameCheckerTrait;
|
||||
|
||||
/**
|
||||
* The configured tags will be processed.
|
||||
* @var array<string>
|
||||
|
@ -55,13 +56,13 @@ class Typo3Update_Sniffs_LegacyClassnames_DocCommentSniff implements PHP_CodeSni
|
|||
/**
|
||||
* Processes the tokens that this sniff is interested in.
|
||||
*
|
||||
* @param PHP_CodeSniffer_File $phpcsFile The file where the token was found.
|
||||
* @param PhpCsFile $phpcsFile The file where the token was found.
|
||||
* @param int $stackPtr The position in the stack where
|
||||
* the token was found.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
||||
public function process(PhpCsFile $phpcsFile, $stackPtr)
|
||||
{
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
if (!in_array($tokens[$stackPtr]['content'], $this->allowedTags)) {
|
||||
|
|
|
@ -19,13 +19,13 @@
|
|||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
use Typo3Update\Sniffs\LegacyClassnames\AbstractClassnameChecker;
|
||||
|
||||
/**
|
||||
* Detect and migrate extend and implement of old legacy classnames.
|
||||
*/
|
||||
class Typo3Update_Sniffs_LegacyClassnames_InheritanceSniff implements PHP_CodeSniffer_Sniff
|
||||
class Typo3Update_Sniffs_LegacyClassnames_InheritanceSniff extends AbstractClassnameChecker
|
||||
{
|
||||
use \Typo3Update\Sniffs\LegacyClassnames\ClassnameCheckerTrait;
|
||||
|
||||
/**
|
||||
* Returns the token types that this sniff is interested in.
|
||||
*
|
||||
|
|
|
@ -19,13 +19,14 @@
|
|||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
use PHP_CodeSniffer_File as PhpCsFile;
|
||||
use Typo3Update\Sniffs\LegacyClassnames\AbstractClassnameChecker;
|
||||
|
||||
/**
|
||||
* Migrate PHP inline comments, e.g. for IDEs.
|
||||
*/
|
||||
class Typo3Update_Sniffs_LegacyClassnames_InlineCommentSniff implements PHP_CodeSniffer_Sniff
|
||||
class Typo3Update_Sniffs_LegacyClassnames_InlineCommentSniff extends AbstractClassnameChecker
|
||||
{
|
||||
use \Typo3Update\Sniffs\LegacyClassnames\ClassnameCheckerTrait;
|
||||
|
||||
/**
|
||||
* Original token content for reuse accross methods.
|
||||
* @var string
|
||||
|
@ -47,13 +48,13 @@ class Typo3Update_Sniffs_LegacyClassnames_InlineCommentSniff implements PHP_Code
|
|||
/**
|
||||
* Processes the tokens that this sniff is interested in.
|
||||
*
|
||||
* @param PHP_CodeSniffer_File $phpcsFile The file where the token was found.
|
||||
* @param PhpCsFile $phpcsFile The file where the token was found.
|
||||
* @param int $stackPtr The position in the stack where
|
||||
* the token was found.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
||||
public function process(PhpCsFile $phpcsFile, $stackPtr)
|
||||
{
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
$this->originalTokenContent = $tokens[$stackPtr]['content'];
|
||||
|
|
|
@ -19,13 +19,13 @@
|
|||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
use Typo3Update\Sniffs\LegacyClassnames\AbstractClassnameChecker;
|
||||
|
||||
/**
|
||||
* Detect and migrate instanceof checks of old legacy classnames.
|
||||
*/
|
||||
class Typo3Update_Sniffs_LegacyClassnames_InstanceofSniff implements PHP_CodeSniffer_Sniff
|
||||
class Typo3Update_Sniffs_LegacyClassnames_InstanceofSniff extends AbstractClassnameChecker
|
||||
{
|
||||
use \Typo3Update\Sniffs\LegacyClassnames\ClassnameCheckerTrait;
|
||||
|
||||
/**
|
||||
* Returns the token types that this sniff is interested in.
|
||||
*
|
||||
|
|
|
@ -19,14 +19,15 @@
|
|||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
use PHP_CodeSniffer_File as PhpCsFile;
|
||||
use PHP_CodeSniffer_Tokens as Tokens;
|
||||
use Typo3Update\Sniffs\LegacyClassnames\AbstractClassnameChecker;
|
||||
|
||||
/**
|
||||
* Detect and migrate instantiations of old legacy classnames using "makeInstance".
|
||||
*/
|
||||
class Typo3Update_Sniffs_LegacyClassnames_InstantiationWithMakeInstanceSniff implements PHP_CodeSniffer_Sniff
|
||||
class Typo3Update_Sniffs_LegacyClassnames_InstantiationWithMakeInstanceSniff extends AbstractClassnameChecker
|
||||
{
|
||||
use \Typo3Update\Sniffs\LegacyClassnames\ClassnameCheckerTrait;
|
||||
use \Typo3Update\Sniffs\ExtendedPhpCsSupportTrait;
|
||||
|
||||
/**
|
||||
|
@ -48,13 +49,13 @@ class Typo3Update_Sniffs_LegacyClassnames_InstantiationWithMakeInstanceSniff imp
|
|||
/**
|
||||
* Processes the tokens that this sniff is interested in.
|
||||
*
|
||||
* @param PHP_CodeSniffer_File $phpcsFile The file where the token was found.
|
||||
* @param PhpCsFile $phpcsFile The file where the token was found.
|
||||
* @param int $stackPtr The position in the stack where
|
||||
* the token was found.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
||||
public function process(PhpCsFile $phpcsFile, $stackPtr)
|
||||
{
|
||||
if (!$this->isFunctionCall($phpcsFile, $stackPtr)) {
|
||||
return;
|
||||
|
|
|
@ -19,13 +19,13 @@
|
|||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
use Typo3Update\Sniffs\LegacyClassnames\AbstractClassnameChecker;
|
||||
|
||||
/**
|
||||
* Detect and migrate old legacy classnames instantiations using phps "new".
|
||||
*/
|
||||
class Typo3Update_Sniffs_LegacyClassnames_InstantiationWithNewSniff implements PHP_CodeSniffer_Sniff
|
||||
class Typo3Update_Sniffs_LegacyClassnames_InstantiationWithNewSniff extends AbstractClassnameChecker
|
||||
{
|
||||
use \Typo3Update\Sniffs\LegacyClassnames\ClassnameCheckerTrait;
|
||||
|
||||
/**
|
||||
* Returns the token types that this sniff is interested in.
|
||||
*
|
||||
|
|
|
@ -19,14 +19,15 @@
|
|||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
use PHP_CodeSniffer_File as PhpCsFile;
|
||||
use PHP_CodeSniffer_Tokens as Tokens;
|
||||
use Typo3Update\Sniffs\LegacyClassnames\AbstractClassnameChecker;
|
||||
|
||||
/**
|
||||
* Detect and migrate old legacy classname instantiations using objectmanager create and get.
|
||||
*/
|
||||
class Typo3Update_Sniffs_LegacyClassnames_InstantiationWithObjectManagerSniff implements PHP_CodeSniffer_Sniff
|
||||
class Typo3Update_Sniffs_LegacyClassnames_InstantiationWithObjectManagerSniff extends AbstractClassnameChecker
|
||||
{
|
||||
use \Typo3Update\Sniffs\LegacyClassnames\ClassnameCheckerTrait;
|
||||
use \Typo3Update\Sniffs\ExtendedPhpCsSupportTrait;
|
||||
|
||||
/**
|
||||
|
@ -42,13 +43,13 @@ class Typo3Update_Sniffs_LegacyClassnames_InstantiationWithObjectManagerSniff im
|
|||
/**
|
||||
* Processes the tokens that this sniff is interested in.
|
||||
*
|
||||
* @param PHP_CodeSniffer_File $phpcsFile The file where the token was found.
|
||||
* @param PhpCsFile $phpcsFile The file where the token was found.
|
||||
* @param int $stackPtr The position in the stack where
|
||||
* the token was found.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
||||
public function process(PhpCsFile $phpcsFile, $stackPtr)
|
||||
{
|
||||
if (!$this->isFunctionCall($phpcsFile, $stackPtr)) {
|
||||
return;
|
||||
|
|
|
@ -19,14 +19,14 @@
|
|||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
use PHP_CodeSniffer_Tokens as Tokens;
|
||||
use PHP_CodeSniffer_File as PhpcsFile;
|
||||
use Typo3Update\Sniffs\LegacyClassnames\AbstractClassnameChecker;
|
||||
|
||||
/**
|
||||
* Detect and migrate instantiations of old legacy classnames using "makeInstance".
|
||||
*/
|
||||
class Typo3Update_Sniffs_LegacyClassnames_IsACallSniff implements PHP_CodeSniffer_Sniff
|
||||
class Typo3Update_Sniffs_LegacyClassnames_IsACallSniff extends AbstractClassnameChecker
|
||||
{
|
||||
use \Typo3Update\Sniffs\LegacyClassnames\ClassnameCheckerTrait;
|
||||
use \Typo3Update\Sniffs\ExtendedPhpCsSupportTrait;
|
||||
|
||||
/**
|
||||
|
@ -48,13 +48,13 @@ class Typo3Update_Sniffs_LegacyClassnames_IsACallSniff implements PHP_CodeSniffe
|
|||
/**
|
||||
* Processes the tokens that this sniff is interested in.
|
||||
*
|
||||
* @param PHP_CodeSniffer_File $phpcsFile The file where the token was found.
|
||||
* @param PhpCsFile $phpcsFile The file where the token was found.
|
||||
* @param int $stackPtr The position in the stack where
|
||||
* the token was found.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
||||
public function process(PhpCsFile $phpcsFile, $stackPtr)
|
||||
{
|
||||
if (!$this->isFunctionCall($phpcsFile, $stackPtr)) {
|
||||
return;
|
||||
|
|
|
@ -19,13 +19,13 @@
|
|||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
use Typo3Update\Sniffs\LegacyClassnames\AbstractClassnameChecker;
|
||||
|
||||
/**
|
||||
* Detect and migrate static calls to old legacy classnames.
|
||||
*/
|
||||
class Typo3Update_Sniffs_LegacyClassnames_StaticCallSniff implements PHP_CodeSniffer_Sniff
|
||||
class Typo3Update_Sniffs_LegacyClassnames_StaticCallSniff extends AbstractClassnameChecker
|
||||
{
|
||||
use \Typo3Update\Sniffs\LegacyClassnames\ClassnameCheckerTrait;
|
||||
|
||||
/**
|
||||
* Define whether the T_STRING default behaviour should be checked before
|
||||
* or after the $stackPtr.
|
||||
|
|
|
@ -19,15 +19,13 @@
|
|||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
use PHP_CodeSniffer_Tokens as Tokens;
|
||||
use Typo3Update\Sniffs\LegacyClassnames\AbstractClassnameChecker;
|
||||
|
||||
/**
|
||||
* Migrate Typehints in catch statements.
|
||||
*/
|
||||
class Typo3Update_Sniffs_LegacyClassnames_TypehintCatchExceptionSniff implements PHP_CodeSniffer_Sniff
|
||||
class Typo3Update_Sniffs_LegacyClassnames_TypehintCatchExceptionSniff extends AbstractClassnameChecker
|
||||
{
|
||||
use \Typo3Update\Sniffs\LegacyClassnames\ClassnameCheckerTrait;
|
||||
|
||||
/**
|
||||
* Returns the token types that this sniff is interested in.
|
||||
*
|
||||
|
|
|
@ -19,15 +19,14 @@
|
|||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
use PHP_CodeSniffer_Tokens as Tokens;
|
||||
use PHP_CodeSniffer_File as PhpCsFile;
|
||||
use Typo3Update\Sniffs\LegacyClassnames\AbstractClassnameChecker;
|
||||
|
||||
/**
|
||||
* Migrate Typehints in function / method definitions.
|
||||
*/
|
||||
class Typo3Update_Sniffs_LegacyClassnames_TypehintSniff implements PHP_CodeSniffer_Sniff
|
||||
class Typo3Update_Sniffs_LegacyClassnames_TypehintSniff extends AbstractClassnameChecker
|
||||
{
|
||||
use \Typo3Update\Sniffs\LegacyClassnames\ClassnameCheckerTrait;
|
||||
|
||||
/**
|
||||
* Returns the token types that this sniff is interested in.
|
||||
*
|
||||
|
@ -41,13 +40,13 @@ class Typo3Update_Sniffs_LegacyClassnames_TypehintSniff implements PHP_CodeSniff
|
|||
/**
|
||||
* Processes the tokens that this sniff is interested in.
|
||||
*
|
||||
* @param PHP_CodeSniffer_File $phpcsFile The file where the token was found.
|
||||
* @param PhpCsFile $phpcsFile The file where the token was found.
|
||||
* @param int $stackPtr The position in the stack where
|
||||
* the token was found.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
|
||||
public function process(PhpCsFile $phpcsFile, $stackPtr)
|
||||
{
|
||||
$params = $phpcsFile->getMethodParameters($stackPtr);
|
||||
foreach ($params as $parameter) {
|
||||
|
|
|
@ -19,15 +19,13 @@
|
|||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
use PHP_CodeSniffer_Tokens as Tokens;
|
||||
use Typo3Update\Sniffs\LegacyClassnames\AbstractClassnameChecker;
|
||||
|
||||
/**
|
||||
* Migrate old legacy class names in use statements.
|
||||
*/
|
||||
class Typo3Update_Sniffs_LegacyClassnames_UseSniff implements PHP_CodeSniffer_Sniff
|
||||
class Typo3Update_Sniffs_LegacyClassnames_UseSniff extends AbstractClassnameChecker
|
||||
{
|
||||
use \Typo3Update\Sniffs\LegacyClassnames\ClassnameCheckerTrait;
|
||||
|
||||
/**
|
||||
* Returns the token types that this sniff is interested in.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue