FEATURE: Implement removed extension into use sniff.
* Detect removed extensions in use statements. Relates: #44
This commit is contained in:
parent
c7ddbc4aef
commit
633a714043
6 changed files with 141 additions and 6 deletions
|
@ -0,0 +1,14 @@
|
||||||
|
Typo3Update\Feature\RemovedExtensionFeature:
|
||||||
|
- Typo3Update_Sniffs_Classname_InheritanceSniff
|
||||||
|
- Typo3Update_Sniffs_Classname_InlineCommentSniff
|
||||||
|
- Typo3Update_Sniffs_Classname_InstanceofSniff
|
||||||
|
- Typo3Update_Sniffs_Classname_InstantiationWithMakeInstanceSniff
|
||||||
|
- Typo3Update_Sniffs_Classname_InstantiationWithNewSniff
|
||||||
|
- Typo3Update_Sniffs_Classname_InstantiationWithObjectManagerSniff
|
||||||
|
- Typo3Update_Sniffs_Classname_IsACallSniff
|
||||||
|
- Typo3Update_Sniffs_Classname_MissingVendorForPluginsAndModulesSniff
|
||||||
|
- Typo3Update_Sniffs_Classname_PhpDocCommentSniff
|
||||||
|
- Typo3Update_Sniffs_Classname_StaticCallSniff
|
||||||
|
- Typo3Update_Sniffs_Classname_TypeHintCatchExceptionSniff
|
||||||
|
- Typo3Update_Sniffs_Classname_TypeHintSniff
|
||||||
|
- Typo3Update_Sniffs_Classname_UseSniff
|
|
@ -0,0 +1,73 @@
|
||||||
|
<?php
|
||||||
|
namespace Typo3Update\Feature;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||||
|
* 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
use PHP_CodeSniffer_File as PhpCsFile;
|
||||||
|
use Typo3Update\Options;
|
||||||
|
|
||||||
|
class RemovedExtensionFeature extends AbstractYamlRemovedUsage
|
||||||
|
{
|
||||||
|
public function process(PhpCsFile $phpcsFile, $classnamePosition, $classname)
|
||||||
|
{
|
||||||
|
$classnameParts = array_filter(preg_split('/\\\\|_/', $classname));
|
||||||
|
$extname = '';
|
||||||
|
|
||||||
|
foreach ($classnameParts as $classnamePart) {
|
||||||
|
$classnamePart = strtolower($classnamePart);
|
||||||
|
if ($this->configured->isRemoved($classnamePart) === true) {
|
||||||
|
$extname = $classnamePart;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($extname === '') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->addWarning(
|
||||||
|
$phpcsFile,
|
||||||
|
$classnamePosition,
|
||||||
|
$this->configured->getRemoved($extname)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function prepareStructure(array $typo3Versions)
|
||||||
|
{
|
||||||
|
$newStructure = [];
|
||||||
|
foreach ($typo3Versions as $typo3Version => $removals) {
|
||||||
|
foreach ($removals as $removed => $config) {
|
||||||
|
$config['name'] = $removed;
|
||||||
|
$config['identifier'] = 'RemovedClass.' . str_replace('\\', '_', ltrim($removed, '\\'));
|
||||||
|
$config['versionRemoved'] = $typo3Version;
|
||||||
|
$config['oldUsage'] = $removed;
|
||||||
|
|
||||||
|
$newStructure[$removed] = $config;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $newStructure;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getRemovedConfigFiles()
|
||||||
|
{
|
||||||
|
return Options::getRemovedExtensionConfigFiles();
|
||||||
|
}
|
||||||
|
}
|
|
@ -20,10 +20,13 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use PHP_CodeSniffer_File as PhpCsFile;
|
use PHP_CodeSniffer_File as PhpCsFile;
|
||||||
use Typo3Update\Sniffs\Classname\AbstractClassnameChecker;
|
use PHP_CodeSniffer_Sniff as PhpCsSniff;
|
||||||
|
use Typo3Update\Feature\FeaturesSupport;
|
||||||
|
|
||||||
class Typo3Update_Sniffs_Classname_UseSniff extends AbstractClassnameChecker
|
class Typo3Update_Sniffs_Classname_UseSniff implements PhpCsSniff
|
||||||
{
|
{
|
||||||
|
use FeaturesSupport;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the token types that this sniff is interested in.
|
* Returns the token types that this sniff is interested in.
|
||||||
*
|
*
|
||||||
|
@ -33,4 +36,20 @@ class Typo3Update_Sniffs_Classname_UseSniff extends AbstractClassnameChecker
|
||||||
{
|
{
|
||||||
return [T_USE];
|
return [T_USE];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function process(PhpCsFile $phpcsFile, $stackPtr)
|
||||||
|
{
|
||||||
|
$start = $phpcsFile->findNext(T_STRING, $stackPtr);
|
||||||
|
if ($start === false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$end = $phpcsFile->findNext([T_STRING, T_NS_SEPARATOR], $start, null, true, null, true);
|
||||||
|
if ($end === false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$classname = $phpcsFile->getTokensAsString($start, $end - $start);
|
||||||
|
$this->processFeatures($phpcsFile, $start, $classname);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,4 +10,4 @@
|
||||||
+use TYPO3\CMS\Extbase\Domain\Model\BackendUser;
|
+use TYPO3\CMS\Extbase\Domain\Model\BackendUser;
|
||||||
use TYPO3\CMS\Extbase\Mvc\Cli\Command;
|
use TYPO3\CMS\Extbase\Mvc\Cli\Command;
|
||||||
use \TYPO3\CMS\Extbase\Mvc\Cli\Command;
|
use \TYPO3\CMS\Extbase\Mvc\Cli\Command;
|
||||||
|
use TYPO3\CMS\Perm\Controller\PermissionAjaxController;
|
||||||
|
|
|
@ -20,14 +20,41 @@
|
||||||
"severity": 5,
|
"severity": 5,
|
||||||
"source": "Typo3Update.Classname.Use.legacyClassname",
|
"source": "Typo3Update.Classname.Use.legacyClassname",
|
||||||
"type": "ERROR"
|
"type": "ERROR"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"column": 5,
|
||||||
|
"fixable": false,
|
||||||
|
"line": 26,
|
||||||
|
"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.Use.RemovedClass.perm",
|
||||||
|
"type": "WARNING"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"column": 6,
|
||||||
|
"fixable": false,
|
||||||
|
"line": 27,
|
||||||
|
"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.Use.RemovedClass.perm",
|
||||||
|
"type": "WARNING"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"column": 5,
|
||||||
|
"fixable": false,
|
||||||
|
"line": 28,
|
||||||
|
"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.Use.RemovedClass.perm",
|
||||||
|
"type": "WARNING"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"warnings": 0
|
"warnings": 3
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"totals": {
|
"totals": {
|
||||||
"errors": 2,
|
"errors": 2,
|
||||||
"fixable": 2,
|
"fixable": 2,
|
||||||
"warnings": 0
|
"warnings": 3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,4 +23,6 @@ use \Tx_Extbase_Domain_Model_Backenduser;
|
||||||
use Tx_Extbase_Domain_Model_Backenduser;
|
use Tx_Extbase_Domain_Model_Backenduser;
|
||||||
use TYPO3\CMS\Extbase\Mvc\Cli\Command;
|
use TYPO3\CMS\Extbase\Mvc\Cli\Command;
|
||||||
use \TYPO3\CMS\Extbase\Mvc\Cli\Command;
|
use \TYPO3\CMS\Extbase\Mvc\Cli\Command;
|
||||||
|
use TYPO3\CMS\Perm\Controller\PermissionAjaxController;
|
||||||
|
use \Tx_Perm_Controller_PermissionAjaxController;
|
||||||
|
use Tx_Perm_Controller_PermissionAjaxController;
|
||||||
|
|
Loading…
Reference in a new issue