FEATURE: Add first TypoScript sniff
* Add configuration for removed object identifiers. * Add sniff for removed object identifiers. Relates: #54
This commit is contained in:
parent
e7dbac4d33
commit
7a999212e2
4 changed files with 128 additions and 0 deletions
|
@ -0,0 +1,5 @@
|
||||||
|
# Breaking changes in 7.0: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Index.html#breaking-changes
|
||||||
|
'7.0':
|
||||||
|
styles.insertContent:
|
||||||
|
replacement: 'Either remove usage of styles.insertContent 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-42543-DefaultTypoScriptRemoved.html'
|
|
@ -0,0 +1,86 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Helmich\TypoScriptParser\Tokenizer\TokenInterface;
|
||||||
|
use PHP_CodeSniffer_File as PhpCsFile;
|
||||||
|
use Typo3Update\Sniffs\Options;
|
||||||
|
use Typo3Update\Sniffs\Removed\AbstractGenericUsage;
|
||||||
|
|
||||||
|
class Typo3Update_Sniffs_Removed_TypoScriptObjectIdentifierSniff extends AbstractGenericUsage
|
||||||
|
{
|
||||||
|
public $supportedTokenizers = [
|
||||||
|
'TYPOSCRIPT',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the token types that this sniff is interested in.
|
||||||
|
*
|
||||||
|
* @return array<int>
|
||||||
|
*/
|
||||||
|
public function register()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
TokenInterface::TYPE_OBJECT_IDENTIFIER,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether the current token is removed.
|
||||||
|
*
|
||||||
|
* @param PhpCsFile $phpcsFile
|
||||||
|
* @param int $stackPtr
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function isRemoved(PhpCsFile $phpcsFile, $stackPtr)
|
||||||
|
{
|
||||||
|
$tokens = $phpcsFile->getTokens();
|
||||||
|
$token = $tokens[$stackPtr];
|
||||||
|
$objectIdentifier = $token['content'];
|
||||||
|
|
||||||
|
if (isset($this->configured[$objectIdentifier])) {
|
||||||
|
$this->removed = [
|
||||||
|
$this->configured[$objectIdentifier]
|
||||||
|
];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Identifier for configuring this specific error / warning through PHPCS.
|
||||||
|
*
|
||||||
|
* @param array $config
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function getIdentifier(array $config)
|
||||||
|
{
|
||||||
|
return str_replace('.', '-', $config['name']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The original call, to allow user to check matches.
|
||||||
|
*
|
||||||
|
* As we match the name, that can be provided by multiple classes, you
|
||||||
|
* should provide an example, so users can check that this is the legacy
|
||||||
|
* one.
|
||||||
|
*
|
||||||
|
* @param array $config
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function getOldUsage(array $config)
|
||||||
|
{
|
||||||
|
return $config['name'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return file names containing removed configurations.
|
||||||
|
*
|
||||||
|
* @return array<string>
|
||||||
|
*/
|
||||||
|
protected function getRemovedConfigFiles()
|
||||||
|
{
|
||||||
|
return Options::getRemovedTypoScriptObjectIdentifierConfigFiles();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
{
|
||||||
|
"files": {
|
||||||
|
"InputFileForIssues.ts": {
|
||||||
|
"errors": 0,
|
||||||
|
"messages": [
|
||||||
|
{
|
||||||
|
"column": 10,
|
||||||
|
"fixable": false,
|
||||||
|
"line": 2,
|
||||||
|
"message": "Legacy calls are not allowed; found styles.insertContent. Removed in 7.0. Either remove usage of styles.insertContent 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-42543-DefaultTypoScriptRemoved.html",
|
||||||
|
"severity": 5,
|
||||||
|
"source": "Typo3Update.Removed.TypoScriptObjectIdentifier.styles-insertContent",
|
||||||
|
"type": "WARNING"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"column": 11,
|
||||||
|
"fixable": false,
|
||||||
|
"line": 3,
|
||||||
|
"message": "Legacy calls are not allowed; found styles.insertContent. Removed in 7.0. Either remove usage of styles.insertContent 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-42543-DefaultTypoScriptRemoved.html",
|
||||||
|
"severity": 5,
|
||||||
|
"source": "Typo3Update.Removed.TypoScriptObjectIdentifier.styles-insertContent",
|
||||||
|
"type": "WARNING"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"warnings": 2
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"totals": {
|
||||||
|
"errors": 0,
|
||||||
|
"fixable": 0,
|
||||||
|
"warnings": 2
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
page {
|
||||||
|
10 < styles.insertContent
|
||||||
|
10 =< styles.insertContent
|
||||||
|
}
|
Loading…
Reference in a new issue