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,32 +72,35 @@ 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)) {
|
if ($this->isLegacyClassname($classname) === false) {
|
||||||
$fix = $phpcsFile->addFixableError(
|
return;
|
||||||
'Legacy classes are not allowed; found %s',
|
}
|
||||||
$classnamePosition,
|
|
||||||
'legacyClassname',
|
|
||||||
[$classname]
|
|
||||||
);
|
|
||||||
|
|
||||||
if ($fix === true) {
|
$fix = $phpcsFile->addFixableError(
|
||||||
switch ($tokens[$stackPtr]['code']) {
|
'Legacy classes are not allowed; found %s',
|
||||||
case T_EXTENDS:
|
$classnamePosition,
|
||||||
case T_IMPLEMENTS:
|
'legacyClassname',
|
||||||
$phpcsFile->fixer->replaceToken($classnamePosition, '\\' . $this->getNewClassname($classname));
|
[$classname]
|
||||||
break;
|
);
|
||||||
|
|
||||||
default:
|
if ($fix === false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
switch ($tokens[$stackPtr]['code']) {
|
||||||
}
|
case T_EXTENDS:
|
||||||
}
|
case T_IMPLEMENTS:
|
||||||
|
$phpcsFile->fixer->replaceToken($classnamePosition, '\\' . $this->getNewClassname($classname));
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue