diff --git a/composer.json b/composer.json index 623bfdefcfcb60dc2f06568fa3866617aad721ae..17a5eb1e823ce92c0f4e80436959e855224f164f 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,8 @@ }, "autoload": { "psr-4": { - "Typo3Update\\": "src/Standards/Typo3Update/" + "Typo3Update\\": "src/Standards/Typo3Update/", + "Typo3Update\\CodeSniffer\\": "src/CodeSniffer/" }, "files": [ "src/CodeSniffer/Tokenizers/TypoScript.php" diff --git a/src/CodeSniffer/Tokenizers/FQObjectIdentifier.php b/src/CodeSniffer/Tokenizers/FQObjectIdentifier.php new file mode 100644 index 0000000000000000000000000000000000000000..90a98338f2ac5dd011176e905c0baca411e625eb --- /dev/null +++ b/src/CodeSniffer/Tokenizers/FQObjectIdentifier.php @@ -0,0 +1,124 @@ +<?php +namespace Typo3Update\CodeSniffer\Tokenizers; + +/* + * 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. + */ + +/** + * Update tokens with fully qualified object identifier. + */ +class FQObjectIdentifier +{ + /** + * Key used to save identifier to token. + * @var string + */ + const IDENTIFIER = 'fqObjectIdentifier'; + + /** + * The fully qualified object identifier, dot separated. + * + * @var array + */ + protected $fqPath = []; + + /** + * Current "real" depth, count of opening braces. + * @var int + */ + protected $depth = 0; + + /** + * Add token as path segment. + * @param array $token + */ + public function addPathSegment(array &$token) + { + $this->syncPath(); + + $path = []; + foreach (explode('.', $token['content']) as $pathSegment) { + $path[] = [ + 'content' => $pathSegment, + 'depth' => $this->getDepth(), + ]; + } + $this->fqPath = array_merge($this->fqPath, $path); + + $this->addFqObjectIdentifier($token); + } + + /** + * Sync path with current depth. + */ + public function syncPath() + { + $this->fqPath = array_filter( + $this->fqPath, + function ($pathSegment) { + return $pathSegment['depth'] < $this->depth; + } + ); + } + + /** + * Respect opening brace internal. + */ + public function handleOpeningBrace() + { + ++$this->depth; + } + + /** + * Respect closing brace internal. + */ + public function handleClosingBrace() + { + --$this->depth; + } + + /** + * @return int + */ + public function getDepth() + { + return $this->depth; + } + + /** + * @return string + */ + public function getPath() + { + $path = ''; + foreach ($this->fqPath as $pathSegment) { + $path .= '.' . $pathSegment['content']; + } + + return substr($path, 1); + } + + /** + * @param array $token + */ + protected function addFqObjectIdentifier(array &$token) + { + $token[static::IDENTIFIER] = $this->getPath(); + } +} diff --git a/src/CodeSniffer/Tokenizers/TypoScript.php b/src/CodeSniffer/Tokenizers/TypoScript.php index 26136f68d5804e2d0a738f74568d33991581f3e6..0b66125eb3298ecf0f9fd7fce178ae3e40ac2c2e 100644 --- a/src/CodeSniffer/Tokenizers/TypoScript.php +++ b/src/CodeSniffer/Tokenizers/TypoScript.php @@ -19,7 +19,9 @@ * 02110-1301, USA. */ +use Helmich\TypoScriptParser\Tokenizer\TokenInterface; use Helmich\TypoScriptParser\Tokenizer\Tokenizer; +use Typo3Update\CodeSniffer\Tokenizers\FQObjectIdentifier; /** * Tokenizes a string of TypoScript. @@ -68,8 +70,33 @@ class PHP_CodeSniffer_Tokenizers_TYPOSCRIPT * * @SuppressWarnings(PHPMD.UnusedFormalParameter) We need to match the signature. */ - public function processAdditional(&$tokens, $eolChar) + public function processAdditional(array &$tokens, $eolChar) { - return; + $this->addFQObjectIdentifiers($tokens); + } + + /** + * Add fully qualified object identifier to all object identifiers. + * + * @param array $tokens + */ + protected function addFQObjectIdentifiers(array &$tokens) + { + $fqObjectIdentifier = new FQObjectIdentifier(); + + foreach ($tokens as &$token) { + if ($token['type'] === TokenInterface::TYPE_OBJECT_IDENTIFIER) { + $fqObjectIdentifier->addPathSegment($token); + continue; + } + if ($token['type'] === TokenInterface::TYPE_BRACE_OPEN) { + $fqObjectIdentifier->handleOpeningBrace(); + continue; + } + if ($token['type'] === TokenInterface::TYPE_BRACE_CLOSE) { + $fqObjectIdentifier->handleClosingBrace(); + continue; + } + } } } diff --git a/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff.php b/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff.php index 6638b34b3b9d8504f09ebc5fd436925d7e4035e9..a2c36869bc65ab5a2507449871aa9d0be2cbb9aa 100644 --- a/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff.php +++ b/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff.php @@ -21,6 +21,7 @@ use Helmich\TypoScriptParser\Tokenizer\TokenInterface; use PHP_CodeSniffer_File as PhpCsFile; +use Typo3Update\CodeSniffer\Tokenizers\FQObjectIdentifier; use Typo3Update\Options; use Typo3Update\Sniffs\Removed\AbstractGenericUsage; @@ -68,20 +69,27 @@ class Typo3Update_Sniffs_Removed_TypoScriptSniff extends AbstractGenericUsage protected function findRemoved(PhpCsFile $phpcsFile, $stackPtr) { + $removed = []; $tokens = $phpcsFile->getTokens(); $token = $tokens[$stackPtr]; - $objectIdentifier = $token['content']; + $identifiersToCheck = [$token['content']]; - if (!$this->configured->isRemoved($objectIdentifier)) { - return []; + if (isset($token[FQObjectIdentifier::IDENTIFIER]) && $token[FQObjectIdentifier::IDENTIFIER] !== $token['content']) { + $identifiersToCheck[] = $token[FQObjectIdentifier::IDENTIFIER]; } - $removed = $this->configured->getRemoved($objectIdentifier); - if ($token['type'] === $removed['type']) { - return [$removed]; + foreach ($identifiersToCheck as $objectIdentifier) { + if ($this->configured->isRemoved($objectIdentifier) === false) { + continue; + } + + $configured = $this->configured->getRemoved($objectIdentifier); + if ($token['type'] === $configured['type']) { + $removed[] = $configured; + } } - return []; + return $removed; } protected function getRemovedConfigFiles() diff --git a/tests/CodeSniffer/Tokenizers/FqObjectIdentifierTest.php b/tests/CodeSniffer/Tokenizers/FqObjectIdentifierTest.php new file mode 100644 index 0000000000000000000000000000000000000000..9115c7f5ca6218966fede9fe271b7968ed1e53e1 --- /dev/null +++ b/tests/CodeSniffer/Tokenizers/FqObjectIdentifierTest.php @@ -0,0 +1,158 @@ +<?php + +namespace Typo3Update\Tests\CodeSniffer\Tokenizers; + +/* + * 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 PHPUnit\Framework\TestCase; +use Typo3Update\CodeSniffer\Tokenizers\FQObjectIdentifier; + +class FqObjectIdentifierTest extends TestCase +{ + /** + * @test + */ + public function addingPathSegmentAddsFqToNewToken() + { + $initialToken = [ + 'type' => TokenInterface::TYPE_OBJECT_IDENTIFIER, + 'content' => 'plugin.tx_example', + ]; + $lastToken = [ + 'type' => TokenInterface::TYPE_OBJECT_IDENTIFIER, + 'content' => 'settings', + ]; + $expectedResult = $lastToken; + $expectedResult['fqObjectIdentifier'] = 'plugin.tx_example.settings'; + + $identifier = new FqObjectIdentifier(); + $identifier->addPathSegment($initialToken); + $identifier->handleOpeningBrace(); + $identifier->addPathSegment($lastToken); + + $this->assertEquals( + $expectedResult, + $lastToken, + 'Adding path segment does not add FQObjectIdentifier to token.' + ); + } + + /** + * @test + */ + public function addingPathSegment2ndTimeAddsFqToNewToken() + { + $initialToken = [ + 'type' => TokenInterface::TYPE_OBJECT_IDENTIFIER, + 'content' => 'plugin.tx_example', + ]; + $firstToken = [ + 'type' => TokenInterface::TYPE_OBJECT_IDENTIFIER, + 'content' => 'settings', + ]; + $lastToken = [ + 'type' => TokenInterface::TYPE_OBJECT_IDENTIFIER, + 'content' => 'someSetting', + ]; + $expectedResult = $lastToken; + $expectedResult['fqObjectIdentifier'] = 'plugin.tx_example.settings.someSetting'; + + $identifier = new FqObjectIdentifier(); + $identifier->addPathSegment($initialToken); + $identifier->handleOpeningBrace(); + $identifier->addPathSegment($firstToken); + $identifier->handleOpeningBrace(); + $identifier->addPathSegment($lastToken); + + $this->assertEquals( + $expectedResult, + $lastToken, + 'Adding path segment does not add FQObjectIdentifier to token on 2nd call.' + ); + } + + /** + * @test + */ + public function openingAndClosingBracesWillAdjustPath() + { + $initialToken = [ + 'type' => TokenInterface::TYPE_OBJECT_IDENTIFIER, + 'content' => 'plugin.tx_example', + ]; + $firstToken = [ + 'type' => TokenInterface::TYPE_OBJECT_IDENTIFIER, + 'content' => 'settings', + ]; + $secondToken = [ + 'type' => TokenInterface::TYPE_OBJECT_IDENTIFIER, + 'content' => 'someSetting', + ]; + $lastToken = [ + 'type' => TokenInterface::TYPE_OBJECT_IDENTIFIER, + 'content' => 'view', + ]; + $expectedResult = $lastToken; + $expectedResult['fqObjectIdentifier'] = 'plugin.tx_example.view'; + + $identifier = new FqObjectIdentifier(); + $identifier->addPathSegment($initialToken); + $identifier->handleOpeningBrace(); + $identifier->addPathSegment($firstToken); + $identifier->handleOpeningBrace(); + $identifier->addPathSegment($secondToken); + $identifier->handleClosingBrace(); + $identifier->addPathSegment($lastToken); + + $this->assertEquals( + $expectedResult, + $lastToken, + 'Curly braces do not modify path as expected.' + ); + } + + /** + * @test + */ + public function addingPathSegmentAfterAnotherResetsPath() + { + $initialToken = [ + 'type' => TokenInterface::TYPE_OBJECT_IDENTIFIER, + 'content' => 'plugin.tx_example.settings.someThing', + ]; + $lastToken = [ + 'type' => TokenInterface::TYPE_OBJECT_IDENTIFIER, + 'content' => 'plugin.tx_example.settings.anotherOne', + ]; + $expectedResult = $lastToken; + $expectedResult['fqObjectIdentifier'] = $expectedResult['content']; + + $identifier = new FqObjectIdentifier(); + $identifier->addPathSegment($initialToken); + $identifier->addPathSegment($lastToken); + + $this->assertEquals( + $expectedResult, + $lastToken, + 'Adding path segment without braces in between resets.' + ); + } +} diff --git a/tests/CodeSniffer/Tokenizers/TypoScriptTest.php b/tests/CodeSniffer/Tokenizers/TypoScriptTest.php index 51ec78842de9f7e48767e760d6b42ad7926c1053..15f0778c8fb82f5df259f87505b023a671509118 100644 --- a/tests/CodeSniffer/Tokenizers/TypoScriptTest.php +++ b/tests/CodeSniffer/Tokenizers/TypoScriptTest.php @@ -22,6 +22,8 @@ namespace Typo3Update\Tests\CodeSniffer\Tokenizers; */ use PHPUnit\Framework\TestCase; +use PHP_CodeSniffer_File as PhpCsFile; +use PHP_CodeSniffer as PhpCs; /** * Test TypoScript tokenizer. @@ -55,9 +57,12 @@ class TypoScriptTest extends TestCase 'example.ts', ]); + // Initialize constants, etc. + new PhpCs(); + $this->assertEquals( require $resultFile, - $subject->tokenizeString(file_get_contents($testFile), "\n"), + PhpCsFile::tokenizeString(file_get_contents($testFile), $subject, "\n"), 'Did not get expected tokens.' ); } diff --git a/tests/Fixtures/CodeSniffer/Tokenizers/TypoScript/example.ts b/tests/Fixtures/CodeSniffer/Tokenizers/TypoScript/example.ts index dee12f7880fd1288d5117802b212e77f64af3f1c..c47ce1b61505817eadb472435443b33e478334ef 100644 --- a/tests/Fixtures/CodeSniffer/Tokenizers/TypoScript/example.ts +++ b/tests/Fixtures/CodeSniffer/Tokenizers/TypoScript/example.ts @@ -3,4 +3,17 @@ plugin { tx_example { settings = TEST } + tx_example_2 { + settings = TEST + } +} +plugin.tx_example.view.something = 1 +plugin.tx_example { + view { + something = 1 + } + settings2 = TEST +} +config { + enable_realurl = 1 } diff --git a/tests/Fixtures/CodeSniffer/Tokenizers/TypoScript/expected.php b/tests/Fixtures/CodeSniffer/Tokenizers/TypoScript/expected.php index 196ca8e451bee1549509019da7fd1bfe0376464f..5ae8ea8ac2a85d44220ba09467f409bba3129f3a 100644 --- a/tests/Fixtures/CodeSniffer/Tokenizers/TypoScript/expected.php +++ b/tests/Fixtures/CodeSniffer/Tokenizers/TypoScript/expected.php @@ -1,148 +1,1140 @@ <?php return [ -0 => array ( + 0 => + array ( 'code' => 'COMMENT', 'type' => 'COMMENT', 'line' => 1, 'content' => '# Comment', -), -1 => array ( + 'column' => 1, + 'length' => 9, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 1 => + array ( 'code' => 'WS', 'type' => 'WS', 'line' => 1, 'content' => ' ', -), -2 => array ( + 'column' => 10, + 'length' => 0, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 2 => + array ( 'code' => 'OBJ_IDENT', 'type' => 'OBJ_IDENT', 'line' => 2, 'content' => 'plugin', -), -3 => array ( + 'column' => 1, + 'length' => 6, + 'level' => 0, + 'conditions' => + array ( + ), + 'fqObjectIdentifier' => 'plugin', + ), + 3 => + array ( 'code' => 'WS', 'type' => 'WS', 'line' => 2, 'content' => ' ', -), -4 => array ( + 'column' => 7, + 'length' => 1, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 4 => + array ( 'code' => 'BR_OPEN', 'type' => 'BR_OPEN', 'line' => 2, 'content' => '{', -), -5 => array ( + 'column' => 8, + 'length' => 1, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 5 => + array ( 'code' => 'WS', 'type' => 'WS', 'line' => 2, 'content' => ' ', -), -6 => array ( + 'column' => 9, + 'length' => 0, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 6 => + array ( 'code' => 'WS', 'type' => 'WS', 'line' => 3, 'content' => ' ', -), -7 => array ( + 'column' => 1, + 'length' => 4, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 7 => + array ( 'code' => 'OBJ_IDENT', 'type' => 'OBJ_IDENT', 'line' => 3, 'content' => 'tx_example', -), -8 => array ( + 'column' => 5, + 'length' => 10, + 'level' => 0, + 'conditions' => + array ( + ), + 'fqObjectIdentifier' => 'plugin.tx_example', + ), + 8 => + array ( 'code' => 'WS', 'type' => 'WS', 'line' => 3, 'content' => ' ', -), -9 => array ( + 'column' => 15, + 'length' => 1, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 9 => + array ( 'code' => 'BR_OPEN', 'type' => 'BR_OPEN', 'line' => 3, 'content' => '{', -), -10 => array ( + 'column' => 16, + 'length' => 1, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 10 => + array ( 'code' => 'WS', 'type' => 'WS', 'line' => 3, 'content' => ' ', -), -11 => array ( + 'column' => 17, + 'length' => 0, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 11 => + array ( 'code' => 'WS', 'type' => 'WS', 'line' => 4, 'content' => ' ', -), -12 => array ( + 'column' => 1, + 'length' => 8, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 12 => + array ( 'code' => 'OBJ_IDENT', 'type' => 'OBJ_IDENT', 'line' => 4, 'content' => 'settings', -), -13 => array ( + 'column' => 9, + 'length' => 8, + 'level' => 0, + 'conditions' => + array ( + ), + 'fqObjectIdentifier' => 'plugin.tx_example.settings', + ), + 13 => + array ( 'code' => 'WS', 'type' => 'WS', 'line' => 4, 'content' => ' ', -), -14 => array ( + 'column' => 17, + 'length' => 1, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 14 => + array ( 'code' => 'OP_ASSIGN', 'type' => 'OP_ASSIGN', 'line' => 4, 'content' => '=', -), -15 => array ( + 'column' => 18, + 'length' => 1, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 15 => + array ( 'code' => 'WS', 'type' => 'WS', 'line' => 4, 'content' => ' ', -), -16 => array ( + 'column' => 19, + 'length' => 1, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 16 => + array ( 'code' => 'RVALUE', 'type' => 'RVALUE', 'line' => 4, 'content' => 'TEST', -), -17 => array ( + 'column' => 20, + 'length' => 4, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 17 => + array ( 'code' => 'WS', 'type' => 'WS', 'line' => 4, 'content' => ' ', -), -18 => array ( + 'column' => 24, + 'length' => 0, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 18 => + array ( 'code' => 'WS', 'type' => 'WS', 'line' => 5, 'content' => ' ', -), -19 => array ( + 'column' => 1, + 'length' => 4, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 19 => + array ( 'code' => 'BR_CLOSE', 'type' => 'BR_CLOSE', 'line' => 5, 'content' => '}', -), -20 => array ( + 'column' => 5, + 'length' => 1, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 20 => + array ( 'code' => 'WS', 'type' => 'WS', 'line' => 5, 'content' => ' ', -), -21 => array ( + 'column' => 6, + 'length' => 0, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 21 => + array ( + 'code' => 'WS', + 'type' => 'WS', + 'line' => 6, + 'content' => ' ', + 'column' => 1, + 'length' => 4, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 22 => + array ( + 'code' => 'OBJ_IDENT', + 'type' => 'OBJ_IDENT', + 'line' => 6, + 'content' => 'tx_example_2', + 'column' => 5, + 'length' => 12, + 'level' => 0, + 'conditions' => + array ( + ), + 'fqObjectIdentifier' => 'plugin.tx_example_2', + ), + 23 => + array ( + 'code' => 'WS', + 'type' => 'WS', + 'line' => 6, + 'content' => ' ', + 'column' => 17, + 'length' => 1, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 24 => + array ( + 'code' => 'BR_OPEN', + 'type' => 'BR_OPEN', + 'line' => 6, + 'content' => '{', + 'column' => 18, + 'length' => 1, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 25 => + array ( + 'code' => 'WS', + 'type' => 'WS', + 'line' => 6, + 'content' => ' +', + 'column' => 19, + 'length' => 0, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 26 => + array ( + 'code' => 'WS', + 'type' => 'WS', + 'line' => 7, + 'content' => ' ', + 'column' => 1, + 'length' => 8, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 27 => + array ( + 'code' => 'OBJ_IDENT', + 'type' => 'OBJ_IDENT', + 'line' => 7, + 'content' => 'settings', + 'column' => 9, + 'length' => 8, + 'level' => 0, + 'conditions' => + array ( + ), + 'fqObjectIdentifier' => 'plugin.tx_example_2.settings', + ), + 28 => + array ( + 'code' => 'WS', + 'type' => 'WS', + 'line' => 7, + 'content' => ' ', + 'column' => 17, + 'length' => 1, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 29 => + array ( + 'code' => 'OP_ASSIGN', + 'type' => 'OP_ASSIGN', + 'line' => 7, + 'content' => '=', + 'column' => 18, + 'length' => 1, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 30 => + array ( + 'code' => 'WS', + 'type' => 'WS', + 'line' => 7, + 'content' => ' ', + 'column' => 19, + 'length' => 1, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 31 => + array ( + 'code' => 'RVALUE', + 'type' => 'RVALUE', + 'line' => 7, + 'content' => 'TEST', + 'column' => 20, + 'length' => 4, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 32 => + array ( + 'code' => 'WS', + 'type' => 'WS', + 'line' => 7, + 'content' => ' +', + 'column' => 24, + 'length' => 0, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 33 => + array ( + 'code' => 'WS', + 'type' => 'WS', + 'line' => 8, + 'content' => ' ', + 'column' => 1, + 'length' => 4, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 34 => + array ( 'code' => 'BR_CLOSE', 'type' => 'BR_CLOSE', - 'line' => 6, + 'line' => 8, 'content' => '}', -), -22 => array ( + 'column' => 5, + 'length' => 1, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 35 => + array ( 'code' => 'WS', 'type' => 'WS', - 'line' => 6, + 'line' => 8, + 'content' => ' +', + 'column' => 6, + 'length' => 0, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 36 => + array ( + 'code' => 'BR_CLOSE', + 'type' => 'BR_CLOSE', + 'line' => 9, + 'content' => '}', + 'column' => 1, + 'length' => 1, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 37 => + array ( + 'code' => 'WS', + 'type' => 'WS', + 'line' => 9, + 'content' => ' +', + 'column' => 2, + 'length' => 0, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 38 => + array ( + 'code' => 'OBJ_IDENT', + 'type' => 'OBJ_IDENT', + 'line' => 10, + 'content' => 'plugin.tx_example.view.something', + 'column' => 1, + 'length' => 32, + 'level' => 0, + 'conditions' => + array ( + ), + 'fqObjectIdentifier' => 'plugin.tx_example.view.something', + ), + 39 => + array ( + 'code' => 'WS', + 'type' => 'WS', + 'line' => 10, + 'content' => ' ', + 'column' => 33, + 'length' => 1, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 40 => + array ( + 'code' => 'OP_ASSIGN', + 'type' => 'OP_ASSIGN', + 'line' => 10, + 'content' => '=', + 'column' => 34, + 'length' => 1, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 41 => + array ( + 'code' => 'WS', + 'type' => 'WS', + 'line' => 10, + 'content' => ' ', + 'column' => 35, + 'length' => 1, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 42 => + array ( + 'code' => 'RVALUE', + 'type' => 'RVALUE', + 'line' => 10, + 'content' => '1', + 'column' => 36, + 'length' => 1, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 43 => + array ( + 'code' => 'WS', + 'type' => 'WS', + 'line' => 10, + 'content' => ' +', + 'column' => 37, + 'length' => 0, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 44 => + array ( + 'code' => 'OBJ_IDENT', + 'type' => 'OBJ_IDENT', + 'line' => 11, + 'content' => 'plugin.tx_example', + 'column' => 1, + 'length' => 17, + 'level' => 0, + 'conditions' => + array ( + ), + 'fqObjectIdentifier' => 'plugin.tx_example', + ), + 45 => + array ( + 'code' => 'WS', + 'type' => 'WS', + 'line' => 11, + 'content' => ' ', + 'column' => 18, + 'length' => 1, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 46 => + array ( + 'code' => 'BR_OPEN', + 'type' => 'BR_OPEN', + 'line' => 11, + 'content' => '{', + 'column' => 19, + 'length' => 1, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 47 => + array ( + 'code' => 'WS', + 'type' => 'WS', + 'line' => 11, + 'content' => ' +', + 'column' => 20, + 'length' => 0, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 48 => + array ( + 'code' => 'WS', + 'type' => 'WS', + 'line' => 12, + 'content' => ' ', + 'column' => 1, + 'length' => 4, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 49 => + array ( + 'code' => 'OBJ_IDENT', + 'type' => 'OBJ_IDENT', + 'line' => 12, + 'content' => 'view', + 'column' => 5, + 'length' => 4, + 'level' => 0, + 'conditions' => + array ( + ), + 'fqObjectIdentifier' => 'plugin.tx_example.view', + ), + 50 => + array ( + 'code' => 'WS', + 'type' => 'WS', + 'line' => 12, + 'content' => ' ', + 'column' => 9, + 'length' => 1, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 51 => + array ( + 'code' => 'BR_OPEN', + 'type' => 'BR_OPEN', + 'line' => 12, + 'content' => '{', + 'column' => 10, + 'length' => 1, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 52 => + array ( + 'code' => 'WS', + 'type' => 'WS', + 'line' => 12, + 'content' => ' +', + 'column' => 11, + 'length' => 0, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 53 => + array ( + 'code' => 'WS', + 'type' => 'WS', + 'line' => 13, + 'content' => ' ', + 'column' => 1, + 'length' => 8, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 54 => + array ( + 'code' => 'OBJ_IDENT', + 'type' => 'OBJ_IDENT', + 'line' => 13, + 'content' => 'something', + 'column' => 9, + 'length' => 9, + 'level' => 0, + 'conditions' => + array ( + ), + 'fqObjectIdentifier' => 'plugin.tx_example.view.something', + ), + 55 => + array ( + 'code' => 'WS', + 'type' => 'WS', + 'line' => 13, + 'content' => ' ', + 'column' => 18, + 'length' => 1, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 56 => + array ( + 'code' => 'OP_ASSIGN', + 'type' => 'OP_ASSIGN', + 'line' => 13, + 'content' => '=', + 'column' => 19, + 'length' => 1, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 57 => + array ( + 'code' => 'WS', + 'type' => 'WS', + 'line' => 13, + 'content' => ' ', + 'column' => 20, + 'length' => 1, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 58 => + array ( + 'code' => 'RVALUE', + 'type' => 'RVALUE', + 'line' => 13, + 'content' => '1', + 'column' => 21, + 'length' => 1, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 59 => + array ( + 'code' => 'WS', + 'type' => 'WS', + 'line' => 13, + 'content' => ' +', + 'column' => 22, + 'length' => 0, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 60 => + array ( + 'code' => 'WS', + 'type' => 'WS', + 'line' => 14, + 'content' => ' ', + 'column' => 1, + 'length' => 4, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 61 => + array ( + 'code' => 'BR_CLOSE', + 'type' => 'BR_CLOSE', + 'line' => 14, + 'content' => '}', + 'column' => 5, + 'length' => 1, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 62 => + array ( + 'code' => 'WS', + 'type' => 'WS', + 'line' => 14, + 'content' => ' +', + 'column' => 6, + 'length' => 0, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 63 => + array ( + 'code' => 'WS', + 'type' => 'WS', + 'line' => 15, + 'content' => ' ', + 'column' => 1, + 'length' => 4, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 64 => + array ( + 'code' => 'OBJ_IDENT', + 'type' => 'OBJ_IDENT', + 'line' => 15, + 'content' => 'settings2', + 'column' => 5, + 'length' => 9, + 'level' => 0, + 'conditions' => + array ( + ), + 'fqObjectIdentifier' => 'plugin.tx_example.settings2', + ), + 65 => + array ( + 'code' => 'WS', + 'type' => 'WS', + 'line' => 15, + 'content' => ' ', + 'column' => 14, + 'length' => 1, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 66 => + array ( + 'code' => 'OP_ASSIGN', + 'type' => 'OP_ASSIGN', + 'line' => 15, + 'content' => '=', + 'column' => 15, + 'length' => 1, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 67 => + array ( + 'code' => 'WS', + 'type' => 'WS', + 'line' => 15, + 'content' => ' ', + 'column' => 16, + 'length' => 1, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 68 => + array ( + 'code' => 'RVALUE', + 'type' => 'RVALUE', + 'line' => 15, + 'content' => 'TEST', + 'column' => 17, + 'length' => 4, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 69 => + array ( + 'code' => 'WS', + 'type' => 'WS', + 'line' => 15, + 'content' => ' +', + 'column' => 21, + 'length' => 0, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 70 => + array ( + 'code' => 'BR_CLOSE', + 'type' => 'BR_CLOSE', + 'line' => 16, + 'content' => '}', + 'column' => 1, + 'length' => 1, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 71 => + array ( + 'code' => 'WS', + 'type' => 'WS', + 'line' => 16, + 'content' => ' +', + 'column' => 2, + 'length' => 0, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 72 => + array ( + 'code' => 'OBJ_IDENT', + 'type' => 'OBJ_IDENT', + 'line' => 17, + 'content' => 'config', + 'column' => 1, + 'length' => 6, + 'level' => 0, + 'conditions' => + array ( + ), + 'fqObjectIdentifier' => 'config', + ), + 73 => + array ( + 'code' => 'WS', + 'type' => 'WS', + 'line' => 17, + 'content' => ' ', + 'column' => 7, + 'length' => 1, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 74 => + array ( + 'code' => 'BR_OPEN', + 'type' => 'BR_OPEN', + 'line' => 17, + 'content' => '{', + 'column' => 8, + 'length' => 1, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 75 => + array ( + 'code' => 'WS', + 'type' => 'WS', + 'line' => 17, + 'content' => ' +', + 'column' => 9, + 'length' => 0, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 76 => + array ( + 'code' => 'WS', + 'type' => 'WS', + 'line' => 18, + 'content' => ' ', + 'column' => 1, + 'length' => 4, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 77 => + array ( + 'code' => 'OBJ_IDENT', + 'type' => 'OBJ_IDENT', + 'line' => 18, + 'content' => 'enable_realurl', + 'column' => 5, + 'length' => 14, + 'level' => 0, + 'conditions' => + array ( + ), + 'fqObjectIdentifier' => 'config.enable_realurl', + ), + 78 => + array ( + 'code' => 'WS', + 'type' => 'WS', + 'line' => 18, + 'content' => ' ', + 'column' => 19, + 'length' => 1, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 79 => + array ( + 'code' => 'OP_ASSIGN', + 'type' => 'OP_ASSIGN', + 'line' => 18, + 'content' => '=', + 'column' => 20, + 'length' => 1, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 80 => + array ( + 'code' => 'WS', + 'type' => 'WS', + 'line' => 18, + 'content' => ' ', + 'column' => 21, + 'length' => 1, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 81 => + array ( + 'code' => 'RVALUE', + 'type' => 'RVALUE', + 'line' => 18, + 'content' => '1', + 'column' => 22, + 'length' => 1, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 82 => + array ( + 'code' => 'WS', + 'type' => 'WS', + 'line' => 18, + 'content' => ' +', + 'column' => 23, + 'length' => 0, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 83 => + array ( + 'code' => 'BR_CLOSE', + 'type' => 'BR_CLOSE', + 'line' => 19, + 'content' => '}', + 'column' => 1, + 'length' => 1, + 'level' => 0, + 'conditions' => + array ( + ), + ), + 84 => + array ( + 'code' => 'WS', + 'type' => 'WS', + 'line' => 19, 'content' => ' ', -), + 'column' => 2, + 'length' => 0, + 'level' => 0, + 'conditions' => + array ( + ), + ), ]; diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff/Expected.json b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff/Expected.json index e66a9628b7d785332a379d214dca3ebed026f719..3d8de527c86c4626b0b95a36f970513fb7c2e155 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff/Expected.json +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff/Expected.json @@ -30,10 +30,19 @@ "source": "Typo3Update.Removed.TypoScript.styles-insertContent", "type": "WARNING" }, + { + "column": 9, + "fixable": false, + "line": 14, + "message": "Calls to removed code are not allowed; found mod.web_list.alternateBgColors. Removed in 7.0. Removed without substitution. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-53658-RemoveAlternateBgColorsOption.html", + "severity": 5, + "source": "Typo3Update.Removed.TypoScript.mod-web_list-alternateBgColors", + "type": "WARNING" + }, { "column": 1, "fixable": false, - "line": 13, + "line": 17, "message": "Calls to removed code are not allowed; found mod.web_list.alternateBgColors. Removed in 7.0. Removed without substitution. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-53658-RemoveAlternateBgColorsOption.html", "severity": 5, "source": "Typo3Update.Removed.TypoScript.mod-web_list-alternateBgColors", @@ -42,7 +51,7 @@ { "column": 10, "fixable": false, - "line": 26, + "line": 24, "message": "Calls to removed code are not allowed; found CLEARGIF. Removed in 7.1. Any installation should migrate to alternatives such as FLUIDTEMPLATE to customize the output of the content. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.1/Breaking-64639-RemovedContentObjects.html", "severity": 5, "source": "Typo3Update.Removed.TypoScript.CLEARGIF", @@ -51,7 +60,7 @@ { "column": 10, "fixable": false, - "line": 27, + "line": 25, "message": "Calls to removed code are not allowed; found COLUMNS. Removed in 7.1. Any installation should migrate to alternatives such as FLUIDTEMPLATE to customize the output of the content. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.1/Breaking-64639-RemovedContentObjects.html", "severity": 5, "source": "Typo3Update.Removed.TypoScript.COLUMNS", @@ -60,7 +69,7 @@ { "column": 10, "fixable": false, - "line": 28, + "line": 26, "message": "Calls to removed code are not allowed; found CTABLE. Removed in 7.1. Any installation should migrate to alternatives such as FLUIDTEMPLATE to customize the output of the content. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.1/Breaking-64639-RemovedContentObjects.html", "severity": 5, "source": "Typo3Update.Removed.TypoScript.CTABLE", @@ -69,7 +78,7 @@ { "column": 10, "fixable": false, - "line": 29, + "line": 27, "message": "Calls to removed code are not allowed; found OTABLE. Removed in 7.1. Any installation should migrate to alternatives such as FLUIDTEMPLATE to customize the output of the content. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.1/Breaking-64639-RemovedContentObjects.html", "severity": 5, "source": "Typo3Update.Removed.TypoScript.OTABLE", @@ -78,19 +87,19 @@ { "column": 10, "fixable": false, - "line": 30, + "line": 28, "message": "Calls to removed code are not allowed; found HRULER. Removed in 7.1. Any installation should migrate to alternatives such as FLUIDTEMPLATE to customize the output of the content. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.1/Breaking-64639-RemovedContentObjects.html", "severity": 5, "source": "Typo3Update.Removed.TypoScript.HRULER", "type": "WARNING" } ], - "warnings": 9 + "warnings": 10 } }, "totals": { "errors": 0, "fixable": 0, - "warnings": 9 + "warnings": 10 } } diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff/InputFileForIssues.ts b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff/InputFileForIssues.ts index 3f9b94c96db0459534606315a7f61eb487f7cdee..657b4a58ab1a45f4d6f933108d36b12e2661c671 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff/InputFileForIssues.ts +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff/InputFileForIssues.ts @@ -9,14 +9,12 @@ styles.insertContent { } } -# already covered -mod.web_list.alternateBgColors = 1 -# Not covered yet mod { web_list { alternateBgColors = 1 } } +mod.web_list.alternateBgColors = 1 page { CLEARGIF {