TASK: Update StaticCallSniff tests to reflect added removed extension
* Also update getBefore method of AbstractClassnameChecker to make lookups before, like in StaticCallSniff work. Relates: #44
This commit is contained in:
parent
b32fc01110
commit
af50ddfd99
4 changed files with 48 additions and 14 deletions
|
@ -85,19 +85,28 @@ abstract class AbstractClassnameChecker implements PhpCsSniff
|
||||||
*/
|
*/
|
||||||
protected function getBefore(PhpCsFile $phpcsFile, $stackPtr)
|
protected function getBefore(PhpCsFile $phpcsFile, $stackPtr)
|
||||||
{
|
{
|
||||||
$tokens = $phpcsFile->getTokens();
|
$possibleStart = $phpcsFile->findPrevious([
|
||||||
|
T_STRING, T_NS_SEPARATOR,
|
||||||
|
], $stackPtr - 1, null, true, null, true);
|
||||||
|
if ($possibleStart === false) {
|
||||||
|
throw new \UnexpectedValueException('Could not find start of classname.', 1494319966);
|
||||||
|
}
|
||||||
|
|
||||||
$classnamePosition = $phpcsFile->findPrevious(T_STRING, $stackPtr);
|
$classnamePosition = $phpcsFile->findNext(T_STRING, $possibleStart);
|
||||||
if ($classnamePosition === false) {
|
if ($classnamePosition === false) {
|
||||||
throw new \UnexpectedValueException('Could not find start of classname.', 1494319966);
|
throw new \UnexpectedValueException('Could not find start of classname.', 1494319966);
|
||||||
}
|
}
|
||||||
|
|
||||||
$classname = $tokens[$classnamePosition]['content'];
|
$end = $phpcsFile->findNext([
|
||||||
|
T_STRING, T_NS_SEPARATOR
|
||||||
|
], $classnamePosition + 1, $stackPtr + 1, true, null, true);
|
||||||
|
if ($end === false) {
|
||||||
|
throw new \UnexpectedValueException('Could not find end of classname.', 1494319651);
|
||||||
|
}
|
||||||
|
|
||||||
return [
|
$classname = $phpcsFile->getTokensAsString($classnamePosition, $end - $classnamePosition);
|
||||||
$classnamePosition,
|
|
||||||
$classname
|
return [$classnamePosition, $classname];
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -122,9 +131,6 @@ abstract class AbstractClassnameChecker implements PhpCsSniff
|
||||||
|
|
||||||
$classname = $phpcsFile->getTokensAsString($classnamePosition, $end - $classnamePosition);
|
$classname = $phpcsFile->getTokensAsString($classnamePosition, $end - $classnamePosition);
|
||||||
|
|
||||||
return [
|
return [$classnamePosition, $classname];
|
||||||
$classnamePosition,
|
|
||||||
$classname
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
--- tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/StaticCallSniff/InputFileForIssues.php
|
--- tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/StaticCallSniff/InputFileForIssues.php
|
||||||
+++ PHP_CodeSniffer
|
+++ PHP_CodeSniffer
|
||||||
@@ -19,13 +19,13 @@
|
@@ -19,16 +19,16 @@
|
||||||
* 02110-1301, USA.
|
* 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -19,3 +19,6 @@
|
||||||
-is_a($a, t3lib_Singleton::class);
|
-is_a($a, t3lib_Singleton::class);
|
||||||
+ ->get(\TYPO3\CMS\Extbase\Command\HelpCommandController::class);
|
+ ->get(\TYPO3\CMS\Extbase\Command\HelpCommandController::class);
|
||||||
+is_a($a, \TYPO3\CMS\Core\SingletonInterface::class);
|
+is_a($a, \TYPO3\CMS\Core\SingletonInterface::class);
|
||||||
|
|
||||||
|
\TYPO3\CMS\Perm\Controller\PermissionAjaxController::configurePlugin(
|
||||||
|
$_EXTKEY,
|
||||||
|
|
|
@ -56,14 +56,32 @@
|
||||||
"severity": 5,
|
"severity": 5,
|
||||||
"source": "Typo3Update.Classname.StaticCall.legacyClassname",
|
"source": "Typo3Update.Classname.StaticCall.legacyClassname",
|
||||||
"type": "ERROR"
|
"type": "ERROR"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"column": 2,
|
||||||
|
"fixable": false,
|
||||||
|
"line": 33,
|
||||||
|
"message": "Calls to removed code are not allowed; found perm. Removed in 7.0. The logic is moved into EXT:beuser. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-62339-MoveExtPermIntoExtBeuser.html",
|
||||||
|
"severity": 5,
|
||||||
|
"source": "Typo3Update.Classname.StaticCall.RemovedClass.perm",
|
||||||
|
"type": "WARNING"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"column": 28,
|
||||||
|
"fixable": false,
|
||||||
|
"line": 38,
|
||||||
|
"message": "Calls to removed code are not allowed; found perm. Removed in 7.0. The logic is moved into EXT:beuser. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-62339-MoveExtPermIntoExtBeuser.html",
|
||||||
|
"severity": 5,
|
||||||
|
"source": "Typo3Update.Classname.StaticCall.RemovedClass.perm",
|
||||||
|
"type": "WARNING"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"warnings": 0
|
"warnings": 2
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"totals": {
|
"totals": {
|
||||||
"errors": 6,
|
"errors": 6,
|
||||||
"fixable": 6,
|
"fixable": 6,
|
||||||
"warnings": 0
|
"warnings": 2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,3 +29,10 @@ $this->objectManager->get(\Tx_Extbase_Command_HelpCommandController::class);
|
||||||
\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager)
|
\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager)
|
||||||
->get(\Tx_Extbase_Command_HelpCommandController::class);
|
->get(\Tx_Extbase_Command_HelpCommandController::class);
|
||||||
is_a($a, t3lib_Singleton::class);
|
is_a($a, t3lib_Singleton::class);
|
||||||
|
|
||||||
|
\TYPO3\CMS\Perm\Controller\PermissionAjaxController::configurePlugin(
|
||||||
|
$_EXTKEY,
|
||||||
|
'name',
|
||||||
|
['Controller' => 'action']
|
||||||
|
);
|
||||||
|
$this->objectManager->get(\TYPO3\CMS\Perm\Controller\PermissionAjaxController::class);
|
||||||
|
|
Loading…
Reference in a new issue