TASK: Adjust flow
* Reduce indentation by introducing guards to code.
This commit is contained in:
parent
4fe1287247
commit
8d8a8cc330
1 changed files with 22 additions and 19 deletions
|
@ -72,13 +72,15 @@ class Typo3Update_Sniffs_Legacy_ClassnamesSniff implements PHP_CodeSniffer_Sniff
|
||||||
{
|
{
|
||||||
$tokens = $phpcsFile->getTokens();
|
$tokens = $phpcsFile->getTokens();
|
||||||
$classnamePosition = $phpcsFile->findNext(T_STRING, $stackPtr);
|
$classnamePosition = $phpcsFile->findNext(T_STRING, $stackPtr);
|
||||||
$classname = $tokens[$classnamePosition]['content'];
|
|
||||||
|
|
||||||
if ($classnamePosition === false) {
|
if ($classnamePosition === false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
$classname = $tokens[$classnamePosition]['content'];
|
||||||
|
|
||||||
|
if ($this->isLegacyClassname($classname) === false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->isLegacyClassname($classname)) {
|
|
||||||
$fix = $phpcsFile->addFixableError(
|
$fix = $phpcsFile->addFixableError(
|
||||||
'Legacy classes are not allowed; found %s',
|
'Legacy classes are not allowed; found %s',
|
||||||
$classnamePosition,
|
$classnamePosition,
|
||||||
|
@ -86,7 +88,10 @@ class Typo3Update_Sniffs_Legacy_ClassnamesSniff implements PHP_CodeSniffer_Sniff
|
||||||
[$classname]
|
[$classname]
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($fix === true) {
|
if ($fix === false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch ($tokens[$stackPtr]['code']) {
|
switch ($tokens[$stackPtr]['code']) {
|
||||||
case T_EXTENDS:
|
case T_EXTENDS:
|
||||||
case T_IMPLEMENTS:
|
case T_IMPLEMENTS:
|
||||||
|
@ -98,8 +103,6 @@ class Typo3Update_Sniffs_Legacy_ClassnamesSniff implements PHP_CodeSniffer_Sniff
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $classname
|
* @param string $classname
|
||||||
|
|
Loading…
Reference in a new issue