FEATURE: Add warning for removed TypoScript Constants
* Configure removed constants in TYPO3 7.x. * Add code / sniff. * Add test. * Update docs. Resolves: #74
This commit is contained in:
parent
582ede2513
commit
299c33a075
7 changed files with 195 additions and 0 deletions
|
@ -187,6 +187,28 @@ Using ``runtime-set``:
|
|||
|
||||
--runtime-set removedTypoScriptConfigFiles "/Some/Absolute/Path/*.yaml"
|
||||
|
||||
.. _configuration-removedTypoScriptConstantConfigFiles:
|
||||
|
||||
removedTypoScriptConstantsConfigFiles
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Configure where to look for configuration files defining the removed TypoScript constants.
|
||||
Default is ``Configuration/Removed/TypoScriptConstants/*.yaml`` inside the standard itself.
|
||||
We already try to deliver as much as possible. Globing is used, so placeholders like ``*`` are
|
||||
possible, see https://secure.php.net/manual/en/function.glob.php
|
||||
|
||||
Using :file:`ruleset.xml`:
|
||||
|
||||
.. code:: xml
|
||||
|
||||
<config name="removedTypoScriptConstantConfigFiles" value="/Some/Absolute/Path/*.yaml"/>
|
||||
|
||||
Using ``runtime-set``:
|
||||
|
||||
.. code:: bash
|
||||
|
||||
--runtime-set removedTypoScriptConstantConfigFiles "/Some/Absolute/Path/*.yaml"
|
||||
|
||||
.. _configuration-features:
|
||||
|
||||
features
|
||||
|
|
|
@ -111,6 +111,10 @@ This will check whether you are using already removed TypoScript parts, supporte
|
|||
|
||||
- Paths like ``styles.insertContent``
|
||||
|
||||
Check for usage of *removed TypoScript constants*. The TypoScript constants are configured in same
|
||||
way as removed functions. For configuration options see
|
||||
:ref:`configuration-removedTypoScriptConstantConfigFiles`.
|
||||
|
||||
For a complete list, take a look at the corresponding YAML-Files.
|
||||
|
||||
Further checks
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
# Breaking changes in 7.0: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Index.html#breaking-changes
|
||||
'7.0':
|
||||
_clear:
|
||||
replacement: 'Either remove usage of constant or add a snippet at an early point in TypoScript for backwards compatibility'
|
||||
docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-60561-DefaultTypoScriptConstantsRemoved.html'
|
||||
_blackBorderWrap:
|
||||
replacement: 'Either remove usage of constant or add a snippet at an early point in TypoScript for backwards compatibility'
|
||||
docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-60561-DefaultTypoScriptConstantsRemoved.html'
|
||||
_tableWrap:
|
||||
replacement: 'Either remove usage of constant or add a snippet at an early point in TypoScript for backwards compatibility'
|
||||
docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-60561-DefaultTypoScriptConstantsRemoved.html'
|
||||
_tableWrap_DEBUG:
|
||||
replacement: 'Either remove usage of constant or add a snippet at an early point in TypoScript for backwards compatibility'
|
||||
docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-60561-DefaultTypoScriptConstantsRemoved.html'
|
||||
_stdFrameParams:
|
||||
replacement: 'Either remove usage of constant or add a snippet at an early point in TypoScript for backwards compatibility'
|
||||
docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-60561-DefaultTypoScriptConstantsRemoved.html'
|
||||
_stdFramesetParams:
|
||||
replacement: 'Either remove usage of constant or add a snippet at an early point in TypoScript for backwards compatibility'
|
||||
docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-60561-DefaultTypoScriptConstantsRemoved.html'
|
|
@ -95,6 +95,19 @@ class Options
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of absolute file names containing removed typoscript constants.
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
public static function getRemovedTypoScriptConstantConfigFiles()
|
||||
{
|
||||
return static::getOptionFileNames(
|
||||
'removedTypoScriptConstant',
|
||||
__DIR__ . '/Configuration/Removed/TypoScriptConstant/*.yaml'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of absolute file names containing removed class configurations.
|
||||
*
|
||||
|
|
|
@ -0,0 +1,86 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* 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 Helmich\TypoScriptParser\Tokenizer\TokenInterface;
|
||||
use PHP_CodeSniffer_File as PhpCsFile;
|
||||
use Typo3Update\Options;
|
||||
use Typo3Update\Sniffs\Removed\AbstractGenericUsage;
|
||||
|
||||
class Typo3Update_Sniffs_Removed_TypoScriptConstantSniff extends AbstractGenericUsage
|
||||
{
|
||||
/**
|
||||
* Register sniff only for TypoScript.
|
||||
* @var array<string>
|
||||
*/
|
||||
public $supportedTokenizers = [
|
||||
'TYPOSCRIPT',
|
||||
];
|
||||
|
||||
public function register()
|
||||
{
|
||||
return [
|
||||
TokenInterface::TYPE_RIGHTVALUE_MULTILINE,
|
||||
TokenInterface::TYPE_RIGHTVALUE,
|
||||
];
|
||||
}
|
||||
|
||||
protected function prepareStructure(array $typo3Versions)
|
||||
{
|
||||
$newStructure = [];
|
||||
|
||||
foreach ($typo3Versions as $typo3Version => $removals) {
|
||||
foreach ($removals as $removed => $config) {
|
||||
$config['name'] = $removed;
|
||||
$config['identifier'] = $removed;
|
||||
$config['oldUsage'] = $removed;
|
||||
$config['versionRemoved'] = $typo3Version;
|
||||
$newStructure[$removed] = $config;
|
||||
}
|
||||
}
|
||||
|
||||
return $newStructure;
|
||||
}
|
||||
|
||||
protected function findRemoved(PhpCsFile $phpcsFile, $stackPtr)
|
||||
{
|
||||
$removed = [];
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
$token = $tokens[$stackPtr];
|
||||
$matches = [];
|
||||
preg_match_all('/\{\$.*\}/', $token['content'], $matches);
|
||||
|
||||
foreach ($matches as $constants) {
|
||||
foreach ($constants as $constant) {
|
||||
$constant = substr($constant, 2, -1);
|
||||
if ($this->configured->isRemoved($constant)) {
|
||||
$removed[] = $this->configured->getRemoved($constant);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $removed;
|
||||
}
|
||||
|
||||
protected function getRemovedConfigFiles()
|
||||
{
|
||||
return Options::getRemovedTypoScriptConstantConfigFiles();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
{
|
||||
"files": {
|
||||
"InputFileForIssues.ts": {
|
||||
"errors": 0,
|
||||
"messages": [
|
||||
{
|
||||
"column": 13,
|
||||
"fixable": false,
|
||||
"line": 3,
|
||||
"message": "Calls to removed code are not allowed; found _clear. Removed in 7.0. Either remove usage of constant or add a snippet at an early point in TypoScript for backwards compatibility. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-60561-DefaultTypoScriptConstantsRemoved.html",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.Removed.TypoScriptConstant._clear",
|
||||
"type": "WARNING"
|
||||
},
|
||||
{
|
||||
"column": 11,
|
||||
"fixable": false,
|
||||
"line": 4,
|
||||
"message": "Calls to removed code are not allowed; found _tableWrap_DEBUG. Removed in 7.0. Either remove usage of constant or add a snippet at an early point in TypoScript for backwards compatibility. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-60561-DefaultTypoScriptConstantsRemoved.html",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.Removed.TypoScriptConstant._tableWrap_DEBUG",
|
||||
"type": "WARNING"
|
||||
},
|
||||
{
|
||||
"column": 11,
|
||||
"fixable": false,
|
||||
"line": 4,
|
||||
"message": "Calls to removed code are not allowed; found _tableWrap. Removed in 7.0. Either remove usage of constant or add a snippet at an early point in TypoScript for backwards compatibility. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-60561-DefaultTypoScriptConstantsRemoved.html",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.Removed.TypoScriptConstant._tableWrap",
|
||||
"type": "WARNING"
|
||||
}
|
||||
],
|
||||
"warnings": 3
|
||||
}
|
||||
},
|
||||
"totals": {
|
||||
"errors": 0,
|
||||
"fixable": 0,
|
||||
"warnings": 3
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
test = TEXT
|
||||
test {
|
||||
value = Some stuff {$_clear} and some more.
|
||||
value (
|
||||
Some values {$_tableWrap_DEBUG}
|
||||
{$_tableWrap}
|
||||
)
|
||||
}
|
Loading…
Reference in a new issue