diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 88d1918..af289ad 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -27,7 +27,7 @@ sync:github: - git push --mirror ${MIRROR_GIT_URL} lint:coding-guideline: &PHP-LINTING - image: php:7.0-alpine + image: php:7.1-alpine stage: test script: - ./vendor/bin/phpcs -s -n --report-full=result/phpcs-full.txt --report-diff=result/phpcs-diff.txt --report-summary=result/phpcs-summary.txt @@ -51,6 +51,10 @@ test:7.0: <<: *PHP-UNITTESTING image: php:7.0-alpine +test:7.1: + <<: *PHP-UNITTESTING + image: php:7.1-alpine + test:latest: <<: *PHP-UNITTESTING image: php:7-alpine diff --git a/Documentation/source/configuration.rst b/Documentation/source/configuration.rst index effb38b..72cae65 100644 --- a/Documentation/source/configuration.rst +++ b/Documentation/source/configuration.rst @@ -165,6 +165,28 @@ Using ``runtime-set``: --runtime-set removedConstantConfigFiles "/Some/Absolute/Path/*.yaml" +.. _configuration-removedClassConfigFiles: + +removedClassConfigFiles +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Configure where to look for configuration files defining the removed classes. Default is +``Configuration/Removed/Classes/*.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 + + + +Using ``runtime-set``: + +.. code:: bash + + --runtime-set removedClassConfigFiles "/Some/Absolute/Path/*.yaml" + .. _configuration-removedTypoScriptConfigFiles: removedTypoScriptConfigFiles @@ -187,6 +209,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 + + + +Using ``runtime-set``: + +.. code:: bash + + --runtime-set removedTypoScriptConstantConfigFiles "/Some/Absolute/Path/*.yaml" + .. _configuration-features: features diff --git a/Documentation/source/features.rst b/Documentation/source/features.rst index 51c8910..7576335 100644 --- a/Documentation/source/features.rst +++ b/Documentation/source/features.rst @@ -96,13 +96,16 @@ Check for removed calls Also we check for the following deprecated calls: -Check for usage of *removed functions* in general. The functions are configured via yaml files. The -location of them is configurable, default is inside the standard itself, and we try to deliver all -information. For configuration options see :ref:`configuration-removedFunctionConfigFiles`. +Check for usage of *removed PHP functions* in general. The functions are configured via yaml files. +The location of them is configurable, default is inside the standard itself, and we try to deliver +all information. For configuration options see :ref:`configuration-removedFunctionConfigFiles`. -Check for usage of *removed constants*. The constants are configured in same way as removed +Check for usage of *removed PHP constants*. The constants are configured in same way as removed functions. For configuration options see :ref:`configuration-removedConstantConfigFiles`. +Check for usage of *removed PHP classes*. The classes are configured in same way as removed +functions. For configuration options see :ref:`configuration-removedClassConfigFiles`. + Check for usage of *removed TypoScript*. The TypoScript objects are configured in same way as removed functions. For configuration options see :ref:`configuration-removedTypoScriptConfigFiles`. This will check whether you are using already removed TypoScript parts, supported are: @@ -111,6 +114,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 diff --git a/Documentation/source/index.rst b/Documentation/source/index.rst index 93ec3be..1dd04c3 100644 --- a/Documentation/source/index.rst +++ b/Documentation/source/index.rst @@ -19,6 +19,9 @@ Requirements To install the project you need ``composer`` to be installed and inside your ``$PATH``. Otherwise run ``make install-composer`` to install composer. +We recommend to use at least PHP 5.6, we do not test with lower versions as 5.6 is latest maintained +version. + Installation ============ diff --git a/composer.json b/composer.json index 6f9a5df..623bfde 100644 --- a/composer.json +++ b/composer.json @@ -23,6 +23,7 @@ ] }, "require": { + "php": ">=5.6", "helmich/typo3-typoscript-parser": "1.1.*", "squizlabs/php_codesniffer": "2.8.*", "symfony/yaml": "3.2.*", diff --git a/src/Standards/Typo3Update/AbstractYamlRemovedUsage.php b/src/Standards/Typo3Update/AbstractYamlRemovedUsage.php new file mode 100644 index 0000000..e753605 --- /dev/null +++ b/src/Standards/Typo3Update/AbstractYamlRemovedUsage.php @@ -0,0 +1,97 @@ + + * + * 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\RemovedByYamlConfiguration; + +/** + * Base class for all classes working with removed configuration through yaml files. + */ +abstract class AbstractYamlRemovedUsage +{ + /** + * @var RemovedByYamlConfiguration + */ + protected $configured; + + public function __construct() + { + $this->configured = new RemovedByYamlConfiguration( + $this->getRemovedConfigFiles(), + $this->getPrepareStructureCallback() + ); + } + + /** + * @return \Callable + */ + protected function getPrepareStructureCallback() + { + return function (array $typo3Versions) { + return call_user_func_array([$this, 'prepareStructure'], [$typo3Versions]); + }; + } + + /** + * @param array $typo3Versions + * @return array + */ + abstract protected function prepareStructure(array $typo3Versions); + + /** + * @return array + */ + abstract protected function getRemovedConfigFiles(); + + /** + * @param PhpCsFile $phpcsFile + * @param int $stackPtr + * @param array $config + */ + protected function addWarning(PhpCsFile $phpcsFile, $stackPtr, array $config) + { + $phpcsFile->addWarning( + 'Calls to removed code are not allowed; found %s. Removed in %s. %s. See: %s', + $stackPtr, + $config['identifier'], + [ + $config['oldUsage'], + $config['versionRemoved'], + $this->getReplacement($config), + $config['docsUrl'], + ] + ); + } + + /** + * @param array $config + * @return string + */ + protected function getReplacement(array $config) + { + $newCall = $config['replacement']; + if ($newCall !== null) { + return $newCall; + } + return 'There is no replacement, just remove call'; + } +} diff --git a/src/Standards/Typo3Update/Configuration/Features/RemovedClass.yaml b/src/Standards/Typo3Update/Configuration/Features/RemovedClass.yaml new file mode 100644 index 0000000..1b7974f --- /dev/null +++ b/src/Standards/Typo3Update/Configuration/Features/RemovedClass.yaml @@ -0,0 +1,14 @@ +Typo3Update\Feature\RemovedClassFeature: + - 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 diff --git a/src/Standards/Typo3Update/Configuration/Removed/Classes/7.0.yaml b/src/Standards/Typo3Update/Configuration/Removed/Classes/7.0.yaml new file mode 100644 index 0000000..c50d9c9 --- /dev/null +++ b/src/Standards/Typo3Update/Configuration/Removed/Classes/7.0.yaml @@ -0,0 +1,56 @@ +# Breaking changes in 7.0: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Index.html#breaking-changes +'7.0': + \TYPO3\CMS\Backend\Template\MediumDocumentTemplate: + replacement: 'Use \TYPO3\CMS\Backend\Template\DocumentTemplate instead' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-61782-DeprecatedDocumentTemplateClassesRemoved.html' + \TYPO3\CMS\Backend\Template\SmallDocumentTemplate: + replacement: 'Use \TYPO3\CMS\Backend\Template\DocumentTemplate instead' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-61782-DeprecatedDocumentTemplateClassesRemoved.html' + \TYPO3\CMS\Backend\Template\StandardDocumentTemplate: + replacement: 'Use \TYPO3\CMS\Backend\Template\DocumentTemplate instead' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-61782-DeprecatedDocumentTemplateClassesRemoved.html' + \TYPO3\CMS\Extbase\Mvc\Controller\ArgumentError: + replacement: 'Migrate to rewritten property mapper' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-57396-ExtbaseDeprecatedPropertyMapperRemoved.html' + \TYPO3\CMS\Extbase\Mvc\Controller\ArgumentsValidator: + replacement: 'Migrate to rewritten property mapper' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-57396-ExtbaseDeprecatedPropertyMapperRemoved.html' + \TYPO3\CMS\Extbase\Property\Mapper: + replacement: 'Migrate to rewritten property mapper' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-57396-ExtbaseDeprecatedPropertyMapperRemoved.html' + \TYPO3\CMS\Extbase\Property\MappingResults: + replacement: 'Migrate to rewritten property mapper' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-57396-ExtbaseDeprecatedPropertyMapperRemoved.html' + \TYPO3\CMS\Extbase\Security\Channel\RequestHashService: + replacement: 'Migrate to rewritten property mapper' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-57396-ExtbaseDeprecatedPropertyMapperRemoved.html' + \TYPO3\CMS\Extbase\Validation\PropertyError: + replacement: 'Migrate to rewritten property mapper' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-57396-ExtbaseDeprecatedPropertyMapperRemoved.html' + \TYPO3\CMS\Extbase\Validation\Validator\AbstractObjectValidator: + replacement: 'Migrate to rewritten property mapper' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-57396-ExtbaseDeprecatedPropertyMapperRemoved.html' + \TYPO3\CMS\Fluid\ViewHelpers\Form\ErrorsViewHelper: + replacement: 'Migrate to rewritten property mapper' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-57396-ExtbaseDeprecatedPropertyMapperRemoved.html' + \TYPO3\CMS\Extbase\Mvc\Controller\FlashMessageContainer: + replacement: 'Change the API calls to not be of static kind anymore. Extbase extensions have to use getFlashMessageQueue() of the controllerContext' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-57382-FlashMessageApi.html' + \TYPO3\CMS\Extbase\Service\TypeHandlingService: + replacement: 'Replace all calls to \TYPO3\CMS\Extbase\Service\TypeHandlingService functions to their new static functions in \TYPO3\CMS\Extbase\Utility\TypeHandlingUtility' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-61786-ExtbaseDeprecatedTypeHandlingServiceRemoved.html' + \TYPO3\CMS\Extbase\Persistence\Generic\Qom\QueryObjectModelConstantsInterface: + replacement: 'Use \TYPO3\CMS\Extbase\Persistence\QueryInterface::*' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-62673-ExtbaseDeprecatedCodeRemoved.html#removed-php-classes' + \TYPO3\CMS\Extbase\Persistence\Generic\Qom\QueryObjectModelFactoryInterface: + replacement: null + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-62673-ExtbaseDeprecatedCodeRemoved.html#removed-php-classes' + \TYPO3\CMS\Scheduler\Task\FileIndexingTask: + replacement: null + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-62670-DeprecatedCodeRemovalInMultipleSysexts.html#removed-php-classes' + \TYPO3\CMS\Core\Compatibility\GlobalObjectDeprecationDecorator: + replacement: null + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-62416-DeprecatedCodeRemovalInCoreSysext.html#removed-php-classes' + \TYPO3\CMS\Core\Resource\Service\IndexerService: + replacement: null + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-62416-DeprecatedCodeRemovalInCoreSysext.html#removed-php-classes' diff --git a/src/Standards/Typo3Update/Configuration/Removed/Classes/7.3.yaml b/src/Standards/Typo3Update/Configuration/Removed/Classes/7.3.yaml new file mode 100644 index 0000000..d9fa51d --- /dev/null +++ b/src/Standards/Typo3Update/Configuration/Removed/Classes/7.3.yaml @@ -0,0 +1,14 @@ +# Breaking changes in 7.3: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.3/Index.html#breaking-changes +'7.3': + \TYPO3\CMS\T3editor\FormWizard: + replacement: 'Use the newly introduced API' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.3/Breaking-67229-FormEngineRelatedClasses.html' + \TYPO3\CMS\Rtehtmlarea\Controller\FrontendRteController: + replacement: 'Use the newly introduced API' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.3/Breaking-67229-FormEngineRelatedClasses.html' + \TYPO3\CMS\Rsaauth\Hook\LoginFormHook: + replacement: 'Use the new backend login form API' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.3/Breaking-66669-BackendLoginControllerRefactored.html' + \TYPO3\CMS\Extbase\Persistence\Generic\IdentityMap: + replacement: 'Existing code can be migrated to the persistence Session class which provides a drop-in replacement for the IdentityMap' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.3/Breaking-66429-RemoveIdentityMapFromPersistence.html' diff --git a/src/Standards/Typo3Update/Configuration/Removed/Classes/7.4.yaml b/src/Standards/Typo3Update/Configuration/Removed/Classes/7.4.yaml new file mode 100644 index 0000000..23c4838 --- /dev/null +++ b/src/Standards/Typo3Update/Configuration/Removed/Classes/7.4.yaml @@ -0,0 +1,14 @@ +# Breaking changes in 7.4: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.4/Index.html#breaking-changes +'7.4': + \TYPO3\CMS\Backend\Rte\AbstractRte: + replacement: 'Take a look at the docs' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.4/Breaking-67811-RteApi.html' + \TYPO3\CMS\Rtehtmlarea\RteHtmlAreaBase: + replacement: 'Take a look at the docs' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.4/Breaking-67811-RteApi.html' + \TYPO3\CMS\Rtehtmlarea\RteHtmlAreaApi: + replacement: 'Not removed but refactored, see docs' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.4/Breaking-67811-RteApi.html' + \TYPO3\CMS\Backend\Template\FrontendDocumentTemplate: + replacement: null + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.4/Breaking-68243-MoveNotUsedFrontendDocumentTemplate.html' diff --git a/src/Standards/Typo3Update/Configuration/Removed/Classes/7.5.yaml b/src/Standards/Typo3Update/Configuration/Removed/Classes/7.5.yaml new file mode 100644 index 0000000..8fdb755 --- /dev/null +++ b/src/Standards/Typo3Update/Configuration/Removed/Classes/7.5.yaml @@ -0,0 +1,17 @@ +# Breaking changes in 7.5: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.5/Index.html#breaking-changes +'7.5': + \TYPO3\CMS\Backend\Form\DataPreprocessor: + replacement: 'Take a look at the docs' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.5/Breaking-69568-FormEngine.html' + \TYPO3\CMS\Backend\Form\FormEngine: + replacement: 'Take a look at the docs' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.5/Breaking-69568-FormEngine.html' + \TYPO3\CMS\Backend\Form\FlexFormsHelper: + replacement: 'Take a look at the docs' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.5/Breaking-69568-FormEngine.html' + \TYPO3\CMS\Core\Database\SqlParser: + replacement: 'Use \TYPO3\CMS\Dbal\Database\SqlParser instead' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.5/Breaking-68401-SqlParserMovedIntoEXTdbal.html' + \TYPO3\CMS\Cshmanual\Controller\HelpModuleController: + replacement: 'Use the Extbase controller or Repository class' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.5/Breaking-63000-MigrateCshmanualToExtbase.html' diff --git a/src/Standards/Typo3Update/Configuration/Removed/Classes/7.6.yaml b/src/Standards/Typo3Update/Configuration/Removed/Classes/7.6.yaml new file mode 100644 index 0000000..4a497e3 --- /dev/null +++ b/src/Standards/Typo3Update/Configuration/Removed/Classes/7.6.yaml @@ -0,0 +1,23 @@ +# Breaking changes in 7.6: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.6/Index.html#breaking-changes +'7.6': + \TYPO3\CMS\Recordlist\Browser\ElementBrowser: + replacement: 'Use the new API for adding element browsers or link handlers' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.6/Breaking-66369-RemovedElementBrowserRelatedClasses.html' + \TYPO3\CMS\Rtehtmlarea\BrowseLinks: + replacement: 'Use the new API for adding element browsers or link handlers' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.6/Breaking-66369-RemovedElementBrowserRelatedClasses.html' + \TYPO3\CMS\Rtehtmlarea\FolderTree: + replacement: 'Use the new API for adding element browsers or link handlers' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.6/Breaking-66369-RemovedElementBrowserRelatedClasses.html' + \TYPO3\CMS\Rtehtmlarea\LinkHandler\RemoveLinkHandler: + replacement: 'Use the new API for adding element browsers or link handlers' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.6/Breaking-66369-RemovedElementBrowserRelatedClasses.html' + \TYPO3\CMS\Rtehtmlarea\PageTree: + replacement: 'Use the new API for adding element browsers or link handlers' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.6/Breaking-66369-RemovedElementBrowserRelatedClasses.html' + \TYPO3\CMS\Core\ElementBrowser\ElementBrowserHookInterface: + replacement: 'Use the new API for adding element browsers or link handlers' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.6/Breaking-66369-RemovedElementBrowserRelatedClasses.html' + \TYPO3\CMS\Impexp\ImportExport: + replacement: 'Use or extend one or both of the new classes (TYPO3CMSImpexpImport and TYPO3CMSImpexpExport).' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.6/Breaking-45899-SplitClassImportExportIntoClassesImportAndExport.html' diff --git a/src/Standards/Typo3Update/Configuration/Removed/TypoScriptConstant/7.0.yaml b/src/Standards/Typo3Update/Configuration/Removed/TypoScriptConstant/7.0.yaml new file mode 100644 index 0000000..80d7e28 --- /dev/null +++ b/src/Standards/Typo3Update/Configuration/Removed/TypoScriptConstant/7.0.yaml @@ -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' diff --git a/src/Standards/Typo3Update/Feature/AbstractYamlRemovedUsage.php b/src/Standards/Typo3Update/Feature/AbstractYamlRemovedUsage.php new file mode 100644 index 0000000..2a1fb9f --- /dev/null +++ b/src/Standards/Typo3Update/Feature/AbstractYamlRemovedUsage.php @@ -0,0 +1,32 @@ + + * + * 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_Sniff as PhpCsSniff; +use Typo3Update\AbstractYamlRemovedUsage as BaseAbstractYamlRemovedUsage; + +abstract class AbstractYamlRemovedUsage extends BaseAbstractYamlRemovedUsage implements FeatureInterface +{ + public function __construct(PhpCsSniff $sniff) + { + parent::__construct(); + } +} diff --git a/src/Standards/Typo3Update/Feature/FeatureInterface.php b/src/Standards/Typo3Update/Feature/FeatureInterface.php index 39de10c..8ab83a7 100644 --- a/src/Standards/Typo3Update/Feature/FeatureInterface.php +++ b/src/Standards/Typo3Update/Feature/FeatureInterface.php @@ -21,6 +21,7 @@ namespace Typo3Update\Feature; */ use PHP_CodeSniffer_File as PhpCsFile; +use PHP_CodeSniffer_Sniff as PhpCsSniff; /** * See "Features" in documentation. diff --git a/src/Standards/Typo3Update/Feature/RemovedClassFeature.php b/src/Standards/Typo3Update/Feature/RemovedClassFeature.php new file mode 100644 index 0000000..5584dfc --- /dev/null +++ b/src/Standards/Typo3Update/Feature/RemovedClassFeature.php @@ -0,0 +1,61 @@ + + * + * 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 RemovedClassFeature extends AbstractYamlRemovedUsage +{ + public function process(PhpCsFile $phpcsFile, $classnamePosition, $classname) + { + if ($this->configured->isRemoved($classname) === false) { + return; + } + $this->addWarning( + $phpcsFile, + $classnamePosition, + $this->configured->getRemoved($classname) + ); + } + + 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::getRemovedClassConfigFiles(); + } +} diff --git a/src/Standards/Typo3Update/Options.php b/src/Standards/Typo3Update/Options.php index 1ce768c..f5a4777 100644 --- a/src/Standards/Typo3Update/Options.php +++ b/src/Standards/Typo3Update/Options.php @@ -95,6 +95,32 @@ class Options ); } + /** + * Returns an array of absolute file names containing removed typoscript constants. + * + * @return array + */ + public static function getRemovedTypoScriptConstantConfigFiles() + { + return static::getOptionFileNames( + 'removedTypoScriptConstant', + __DIR__ . '/Configuration/Removed/TypoScriptConstant/*.yaml' + ); + } + + /** + * Returns an array of absolute file names containing removed class configurations. + * + * @return array + */ + public static function getRemovedClassConfigFiles() + { + return static::getOptionFileNames( + 'removedClassConfigFiles', + __DIR__ . '/Configuration/Removed/Classes/*.yaml' + ); + } + /** * Get the option by optionName, if not defined, use default. * @@ -127,10 +153,11 @@ class Options ); foreach ($fileNames as $file) { - $option = array_merge( - $option, - Yaml::parse(file_get_contents((string) $file)) - ); + $content = Yaml::parse(file_get_contents((string) $file)); + if ($content === null) { + $content = []; + } + $option = array_merge($option, $content); } return $option; diff --git a/src/Standards/Typo3Update/RemovedByYamlConfiguration.php b/src/Standards/Typo3Update/RemovedByYamlConfiguration.php new file mode 100644 index 0000000..046c180 --- /dev/null +++ b/src/Standards/Typo3Update/RemovedByYamlConfiguration.php @@ -0,0 +1,79 @@ + + * + * 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 Symfony\Component\Yaml\Yaml; + +class RemovedByYamlConfiguration +{ + /** + * Configuration to define removed code. + * + * @var array + */ + protected $configured = []; + + /** + * @param array $configFiles + * @param \Callable $prepareStructure + */ + public function __construct(array $configFiles, $prepareStructure) + { + foreach ($configFiles as $file) { + $this->configured = array_merge( + $this->configured, + $prepareStructure(Yaml::parse(file_get_contents((string) $file))) + ); + } + } + + /** + * @param string $identifier + * @return bool + */ + public function isRemoved($identifier) + { + return isset($this->configured[$identifier]); + } + + /** + * @return array + */ + public function getAllRemoved() + { + return $this->configured; + } + + /** + * @return array + */ + public function getRemoved($identifier) + { + if (!$this->isRemoved($identifier)) { + throw new \Exception( + sprintf('Identifier "%s" is not configured to be removed.', $identifier), + 1493289133 + ); + } + + return $this->configured[$identifier]; + } +} diff --git a/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericPhpUsage.php b/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericPhpUsage.php new file mode 100644 index 0000000..99c81d1 --- /dev/null +++ b/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericPhpUsage.php @@ -0,0 +1,156 @@ + + * + * 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; + +abstract class AbstractGenericPhpUsage extends AbstractGenericUsage +{ + /** + * @return int[] + */ + public function register() + { + return [T_STRING]; + } + + /** + * @param array $typo3Versions + * @return array + */ + protected function prepareStructure(array $typo3Versions) + { + $newStructure = []; + + foreach ($typo3Versions as $typo3Version => $removals) { + foreach ($removals as $removed => $config) { + $newStructure[$removed] = $config; + + $newStructure[$removed]['fqcn'] = null; + $newStructure[$removed]['class'] = null; + $newStructure[$removed]['versionRemoved'] = $typo3Version; + + $this->handleStatic($removed, $newStructure[$removed]); + + $newStructure[$removed]['oldUsage'] = $this->getOldUsage($newStructure[$removed]); + $newStructure[$removed]['identifier'] = $this->getIdentifier($newStructure[$removed]); + }; + } + + return $newStructure; + } + + /** + * @param PhpCsFile $phpcsFile + * @param int $stackPtr + * @return array + */ + protected function findRemoved(PhpCsFile $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + $staticPosition = $phpcsFile->findPrevious(T_WHITESPACE, $stackPtr - 1, null, true, null, true); + + $name = $tokens[$stackPtr]['content']; + $isStatic = false; + $class = false; + + if ($staticPosition !== false) { + $isStatic = $tokens[$staticPosition]['code'] === T_DOUBLE_COLON; + } + + if ($isStatic) { + $class = $phpcsFile->findPrevious(T_STRING, $staticPosition, null, false, null, true); + if ($class !== false) { + $class = $tokens[$class]['content']; + } + } + + return $this->getMatchingRemoved($name, $class, $isStatic); + } + + /** + * Returns all matching removed functions for given arguments. + * + * @param string $name + * @param string $className The last part of the class name, splitted by namespaces. + * @param bool $isStatic + * + * @return array + */ + protected function getMatchingRemoved($name, $className, $isStatic) + { + // We will not match any static calls, without the class name, at least for now. + if ($isStatic === true && $className === false) { + return []; + } + + return array_filter( + $this->configured->getAllRemoved(), + function ($config) use ($name, $isStatic, $className) { + return $name === $config['name'] + && $isStatic === $config['static'] + && ( + $className === $config['class'] + || $className === false + ) + ; + } + ); + } + + /** + * @param string $identifier + * @param array &$config + */ + protected function handleStatic($identifier, array &$config) + { + $split = preg_split('/::|->/', $identifier); + + $config['name'] = $split[0]; + $config['static'] = strpos($identifier, '::') !== false; + + if (isset($split[1])) { + $config['fqcn'] = $split[0]; + $config['class'] = array_slice(explode('\\', $config['fqcn']), -1)[0]; + $config['name'] = $split[1]; + } + } + + /** + * @param array $config + * @return string + */ + protected function getIdentifier(array $config) + { + $name = $config['name']; + if ($config['class']) { + $name = $config['class'] . '.' . $name; + } + + return $name; + } + + /** + * @param array $config + * @return string + */ + abstract protected function getOldUsage(array $config); +} diff --git a/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericUsage.php b/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericUsage.php index 3cda85a..557dcb5 100644 --- a/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericUsage.php +++ b/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericUsage.php @@ -22,273 +22,25 @@ namespace Typo3Update\Sniffs\Removed; use PHP_CodeSniffer_File as PhpCsFile; use PHP_CodeSniffer_Sniff as PhpCsSniff; -use PHP_CodeSniffer_Tokens as Tokens; -use Symfony\Component\Yaml\Yaml; -use Typo3Update\Options; +use Typo3Update\AbstractYamlRemovedUsage as BaseAbstractYamlRemovedUsage; -/** - * Contains common functionality for removed code like constants or functions. - * - * Removed parts are configured using YAML-Files, for examples see - * src/Standards/Typo3Update/Configuration/Removed/Constants/7.0.yaml Also - * check out the configuration options in Readme.rst. - */ -abstract class AbstractGenericUsage implements PhpCsSniff +abstract class AbstractGenericUsage extends BaseAbstractYamlRemovedUsage implements PhpCsSniff { - use \Typo3Update\Sniffs\ExtendedPhpCsSupportTrait; - /** - * Configuration to define removed code. - * - * @var array - */ - protected $configured = []; - - /** - * Entries removed in current sniff. - * @var array - */ - protected $removed = []; - - public function __construct() - { - if ($this->configured === []) { - foreach ($this->getRemovedConfigFiles() as $file) { - $this->configured = array_merge( - $this->configured, - $this->prepareStructure(Yaml::parse(file_get_contents((string) $file))) - ); - } - } - } - - /** - * Return file names containing removed configurations. - * - * @return array - */ - abstract protected function getRemovedConfigFiles(); - - /** - * Prepares structure from config for later usage. - * - * @param array $typo3Versions + * @param PhpCsFile $phpcsFile + * @param int $stackPtr * @return array */ - protected function prepareStructure(array $typo3Versions) - { - $newStructure = []; - - foreach ($typo3Versions as $typo3Version => $removals) { - foreach ($removals as $removed => $config) { - // Split static methods and methods. - $split = preg_split('/::|->/', $removed); - - $newStructure[$removed] = $config; - - $newStructure[$removed]['static'] = strpos($removed, '::') !== false; - $newStructure[$removed]['fqcn'] = null; - $newStructure[$removed]['class'] = null; - $newStructure[$removed]['name'] = $split[0]; - $newStructure[$removed]['version_removed'] = $typo3Version; - - // If split contains two parts, it's a class - if (isset($split[1])) { - $newStructure[$removed]['fqcn'] = $split[0]; - $newStructure[$removed]['class'] = array_slice( - explode('\\', $newStructure[$removed]['fqcn']), - -1 - )[0]; - $newStructure[$removed]['name'] = $split[1]; - } - } - } - - return $newStructure; - } + abstract protected function findRemoved(PhpCsFile $phpcsFile, $stackPtr); /** - * Processes the tokens that this sniff is interested in. - * - * This is the default implementation, as most of the time next T_STRING is - * the class name. This way only the register method has to be registered - * in default cases. - * - * @param PhpCsFile $phpcsFile The file where the token was found. - * @param int $stackPtr The position in the stack where - * the token was found. - * - * @return void + * @param PhpCsFile $phpcsFile + * @param int $stackPtr */ public function process(PhpCsFile $phpcsFile, $stackPtr) { - if (!$this->isRemoved($phpcsFile, $stackPtr)) { - return; + foreach ($this->findRemoved($phpcsFile, $stackPtr) as $removed) { + $this->addWarning($phpcsFile, $stackPtr, $removed); } - - $this->addMessage($phpcsFile, $stackPtr); - } - - /** - * Check whether the current token is removed. - * - * @param PhpCsFile $phpcsFile - * @param int $stackPtr - * @return bool - */ - protected function isRemoved(PhpCsFile $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - $staticPosition = $phpcsFile->findPrevious(T_WHITESPACE, $stackPtr - 1, null, true, null, true); - - $name = $tokens[$stackPtr]['content']; - $isStatic = false; - $class = false; - - if ($staticPosition !== false) { - $isStatic = $tokens[$staticPosition]['code'] === T_DOUBLE_COLON; - } - - if ($isStatic) { - $class = $phpcsFile->findPrevious(T_STRING, $staticPosition, null, false, null, true); - if ($class !== false) { - $class = $tokens[$class]['content']; - } - } - - $this->removed = $this->getMatchingRemoved($name, $class, $isStatic); - return $this->removed !== []; - } - - /** - * Returns all matching removed functions for given arguments. - * - * @param string $name - * @param string $className The last part of the class name, splitted by namespaces. - * @param bool $isStatic - * - * @return array - */ - protected function getMatchingRemoved($name, $className, $isStatic) - { - // We will not match any static calls, without the class name, at least for now. - if ($isStatic === true && $className === false) { - return []; - } - - return array_filter( - $this->configured, - function ($config) use ($name, $isStatic, $className) { - return $name === $config['name'] - && $isStatic === $config['static'] - && ( - $className === $config['class'] - || $className === false - ) - ; - } - ); - } - - /** - * Add message for the given token position. - * - * Default is a warning, non fixable. Just overwrite in concrete sniff, if - * something different suites better. - * - * @param PhpCsFile $phpcsFile - * @param int $tokenPosition - * - * @return void - */ - protected function addMessage(PhpCsFile $phpcsFile, $tokenPosition) - { - foreach ($this->removed as $removed) { - $phpcsFile->addWarning( - 'Legacy calls are not allowed; found %s. Removed in %s. %s. See: %s', - $tokenPosition, - $this->getIdentifier($removed), - [ - $this->getOldUsage($removed), - $this->getRemovedVersion($removed), - $this->getReplacement($removed), - $this->getDocsUrl($removed), - ] - ); - } - } - - /** - * Identifier for configuring this specific error / warning through PHPCS. - * - * @param array $config - * - * @return string - */ - protected function getIdentifier(array $config) - { - $name = $config['name']; - if ($config['class']) { - $name = $config['class'] . '.' . $name; - } - - return $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 - */ - abstract protected function getOldUsage(array $config); - - /** - * Returns TYPO3 version when the breaking change happened. - * - * To let user decide whether this is important for him. - * - * @param array $config - * - * @return string - */ - protected function getRemovedVersion(array $config) - { - return $config['version_removed']; - } - - /** - * The new call, or information how to migrate. - * - * To provide feedback for user to ease migration. - * - * @param array $config - * - * @return string - */ - protected function getReplacement(array $config) - { - $newCall = $config['replacement']; - if ($newCall !== null) { - return $newCall; - } - return 'There is no replacement, just remove call'; - } - - /** - * Allow user to lookup the official docs related to this deprecation / breaking change. - * - * @param array $config - * - * @return string - */ - protected function getDocsUrl(array $config) - { - return $config['docsUrl']; } } diff --git a/src/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff.php b/src/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff.php index 1ee46b1..e42a07d 100644 --- a/src/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff.php +++ b/src/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff.php @@ -19,42 +19,11 @@ * 02110-1301, USA. */ -use PHP_CodeSniffer_File as PhpCsFile; -use Typo3Update\Sniffs\Removed\AbstractGenericUsage; +use Typo3Update\Sniffs\Removed\AbstractGenericPhpUsage; use Typo3Update\Options; -/** - * Sniff that handles all calls to removed constants. - */ -class Typo3Update_Sniffs_Removed_GenericConstantUsageSniff extends AbstractGenericUsage +class Typo3Update_Sniffs_Removed_GenericConstantUsageSniff extends AbstractGenericPhpUsage { - /** - * Return file names containing removed configurations. - * - * @return array - */ - protected function getRemovedConfigFiles() - { - return Options::getRemovedConstantConfigFiles(); - } - - /** - * Returns the token types that this sniff is interested in. - * - * @return array - */ - public function register() - { - return [T_STRING]; - } - - /** - * The original constant call, to allow user to check matches. - * - * @param array $config - * - * @return string - */ protected function getOldUsage(array $config) { $old = $config['name']; @@ -64,4 +33,9 @@ class Typo3Update_Sniffs_Removed_GenericConstantUsageSniff extends AbstractGener return 'constant ' . $old; } + + protected function getRemovedConfigFiles() + { + return Options::getRemovedConstantConfigFiles(); + } } diff --git a/src/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff.php b/src/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff.php index 4124eb2..2915a87 100644 --- a/src/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff.php +++ b/src/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff.php @@ -20,60 +20,28 @@ */ use PHP_CodeSniffer_File as PhpCsFile; -use PHP_CodeSniffer_Tokens as Tokens; -use Typo3Update\Sniffs\Removed\AbstractGenericUsage; use Typo3Update\Options; +use Typo3Update\Sniffs\ExtendedPhpCsSupportTrait; +use Typo3Update\Sniffs\Removed\AbstractGenericPhpUsage; -/** - * Sniff that handles all calls to removed functions. - */ -class Typo3Update_Sniffs_Removed_GenericFunctionCallSniff extends AbstractGenericUsage +class Typo3Update_Sniffs_Removed_GenericFunctionCallSniff extends AbstractGenericPhpUsage { - /** - * Return file names containing removed configurations. - * - * @return array - */ + use ExtendedPhpCsSupportTrait; + protected function getRemovedConfigFiles() { return Options::getRemovedFunctionConfigFiles(); } - /** - * Returns the token types that this sniff is interested in. - * - * @return array - */ - public function register() - { - return Tokens::$functionNameTokens; - } - - /** - * Check whether function at given point is removed. - * - * @return bool - */ - protected function isRemoved(PhpCsFile $phpcsFile, $stackPtr) + protected function findRemoved(PhpCsFile $phpcsFile, $stackPtr) { if (!$this->isFunctionCall($phpcsFile, $stackPtr)) { - return false; + return []; } - return parent::isRemoved($phpcsFile, $stackPtr); + return parent::findRemoved($phpcsFile, $stackPtr); } - /** - * The original function call, to allow user to check matches. - * - * As we match the function 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 The converted structure for a single function. - * - * @return string - */ protected function getOldUsage(array $config) { $concat = '->'; diff --git a/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptConstantSniff.php b/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptConstantSniff.php new file mode 100644 index 0000000..c396d32 --- /dev/null +++ b/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptConstantSniff.php @@ -0,0 +1,86 @@ + + * + * 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 + */ + 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(); + } +} diff --git a/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff.php b/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff.php index 98c0cca..6638b34 100644 --- a/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff.php +++ b/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff.php @@ -24,9 +24,6 @@ use PHP_CodeSniffer_File as PhpCsFile; use Typo3Update\Options; use Typo3Update\Sniffs\Removed\AbstractGenericUsage; -/** - * Check usage of removed or breaking changed TypoScript. - */ class Typo3Update_Sniffs_Removed_TypoScriptSniff extends AbstractGenericUsage { /** @@ -37,11 +34,6 @@ class Typo3Update_Sniffs_Removed_TypoScriptSniff extends AbstractGenericUsage 'TYPOSCRIPT', ]; - /** - * Returns the token types that this sniff is interested in. - * - * @return array - */ public function register() { return [ @@ -50,16 +42,9 @@ class Typo3Update_Sniffs_Removed_TypoScriptSniff extends AbstractGenericUsage ]; } - /** - * Prepares structure from config for later usage. - * - * @param array $typo3Versions - * @return array - */ protected function prepareStructure(array $typo3Versions) { $newStructure = []; - foreach ($typo3Versions as $typo3Version => $removals) { foreach ($removals as $removed => $config) { $config['type'] = TokenInterface::TYPE_OBJECT_IDENTIFIER; @@ -70,7 +55,9 @@ class Typo3Update_Sniffs_Removed_TypoScriptSniff extends AbstractGenericUsage } $config['name'] = $removed; - $config['version_removed'] = $typo3Version; + $config['identifier'] = str_replace('.', '-', $removed); + $config['versionRemoved'] = $typo3Version; + $config['oldUsage'] = $removed; $newStructure[$removed] = $config; } @@ -79,62 +66,24 @@ class Typo3Update_Sniffs_Removed_TypoScriptSniff extends AbstractGenericUsage return $newStructure; } - /** - * Check whether the current token is removed. - * - * @param PhpCsFile $phpcsFile - * @param int $stackPtr - * @return bool - */ - protected function isRemoved(PhpCsFile $phpcsFile, $stackPtr) + protected function findRemoved(PhpCsFile $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); $token = $tokens[$stackPtr]; $objectIdentifier = $token['content']; - if (isset($this->configured[$objectIdentifier]) && $token['type'] === $this->configured[$objectIdentifier]['type']) { - $this->removed = [ - $this->configured[$objectIdentifier] - ]; - return true; + if (!$this->configured->isRemoved($objectIdentifier)) { + return []; } - return false; + $removed = $this->configured->getRemoved($objectIdentifier); + if ($token['type'] === $removed['type']) { + return [$removed]; + } + + return []; } - /** - * 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 - */ protected function getRemovedConfigFiles() { return Options::getRemovedTypoScriptConfigFiles(); diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithMakeInstanceSniff/Expected.diff b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithMakeInstanceSniff/Expected.diff index 41f28ef..80accd3 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithMakeInstanceSniff/Expected.diff +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithMakeInstanceSniff/Expected.diff @@ -1,10 +1,11 @@ --- tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithMakeInstanceSniff/InputFileForIssues.php +++ PHP_CodeSniffer -@@ -19,6 +19,6 @@ +@@ -19,7 +19,7 @@ * 02110-1301, USA. */ -t3lib_div::makeInstance('Tx_Extbase_Command_HelpCommandController'); +t3lib_div::makeInstance('\TYPO3\CMS\Extbase\Command\HelpCommandController'); + t3lib_div::makeInstance(\TYPO3\CMS\Core\Resource\Service\IndexerService::class); // Not handled by this sniff, but StaticCallSniff, as this uses double colon. t3lib_div::makeInstance(Tx_Extbase_Command_HelpCommandController::class); diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithMakeInstanceSniff/InputFileForIssues.php b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithMakeInstanceSniff/InputFileForIssues.php index 12550c5..ccc9a0c 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithMakeInstanceSniff/InputFileForIssues.php +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithMakeInstanceSniff/InputFileForIssues.php @@ -20,5 +20,6 @@ */ t3lib_div::makeInstance('Tx_Extbase_Command_HelpCommandController'); +t3lib_div::makeInstance(\TYPO3\CMS\Core\Resource\Service\IndexerService::class); // Not handled by this sniff, but StaticCallSniff, as this uses double colon. t3lib_div::makeInstance(Tx_Extbase_Command_HelpCommandController::class); diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/PhpDocCommentSniff/Expected.diff b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/PhpDocCommentSniff/Expected.diff index 807e03e..36a8cf7 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/PhpDocCommentSniff/Expected.diff +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/PhpDocCommentSniff/Expected.diff @@ -1,6 +1,6 @@ --- tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/PhpDocCommentSniff/InputFileForIssues.php +++ PHP_CodeSniffer -@@ -22,19 +22,19 @@ +@@ -22,20 +22,20 @@ class InputFileForIssues { /** @@ -13,6 +13,7 @@ /** - * @param t3lib_div + * @param \TYPO3\CMS\Core\Utility\GeneralUtility + * @param \TYPO3\CMS\Backend\Template\MediumDocumentTemplate * - * @return Tx_Extbase_Configuration_Configurationmanager + * @return \TYPO3\CMS\Extbase\Configuration\ConfigurationManager diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/PhpDocCommentSniff/Expected.json b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/PhpDocCommentSniff/Expected.json index dc72038..89158c7 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/PhpDocCommentSniff/Expected.json +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/PhpDocCommentSniff/Expected.json @@ -21,10 +21,19 @@ "source": "Typo3Update.Classname.PhpDocComment.legacyClassname", "type": "ERROR" }, + { + "column": 15, + "fixable": false, + "line": 32, + "message": "Calls to removed code are not allowed; found \\TYPO3\\CMS\\Backend\\Template\\MediumDocumentTemplate. Removed in 7.0. Use \\TYPO3\\CMS\\Backend\\Template\\DocumentTemplate instead. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-61782-DeprecatedDocumentTemplateClassesRemoved.html", + "severity": 5, + "source": "Typo3Update.Classname.PhpDocComment.RemovedClass.TYPO3_CMS_Backend_Template_MediumDocumentTemplate", + "type": "WARNING" + }, { "column": 16, "fixable": true, - "line": 33, + "line": 34, "message": "Legacy classes are not allowed; found \"Tx_Extbase_Configuration_Configurationmanager\", use \"TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager\" instead", "severity": 5, "source": "Typo3Update.Classname.PhpDocComment.legacyClassname", @@ -33,19 +42,19 @@ { "column": 18, "fixable": true, - "line": 37, + "line": 38, "message": "Legacy classes are not allowed; found \"t3lib_div\", use \"TYPO3\\CMS\\Core\\Utility\\GeneralUtility\" instead", "severity": 5, "source": "Typo3Update.Classname.PhpDocComment.legacyClassname", "type": "ERROR" } ], - "warnings": 0 + "warnings": 1 } }, "totals": { "errors": 4, "fixable": 4, - "warnings": 0 + "warnings": 1 } } diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/PhpDocCommentSniff/InputFileForIssues.php b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/PhpDocCommentSniff/InputFileForIssues.php index 92acefb..7a2de67 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/PhpDocCommentSniff/InputFileForIssues.php +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/PhpDocCommentSniff/InputFileForIssues.php @@ -29,6 +29,7 @@ class InputFileForIssues /** * @param t3lib_div + * @param \TYPO3\CMS\Backend\Template\MediumDocumentTemplate * * @return Tx_Extbase_Configuration_Configurationmanager */ diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff/Expected.json b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff/Expected.json index e3072f3..6d0f5d6 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff/Expected.json +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff/Expected.json @@ -7,7 +7,7 @@ "column": 9, "fixable": false, "line": 22, - "message": "Legacy calls are not allowed; found constant PATH_tslib. Removed in 7.0. The folder and constant no longer exist. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-61459-RemovalTslib.html", + "message": "Calls to removed code are not allowed; found constant PATH_tslib. Removed in 7.0. The folder and constant no longer exist. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-61459-RemovalTslib.html", "severity": 5, "source": "Typo3Update.Removed.GenericConstantUsage.PATH_tslib", "type": "WARNING" @@ -16,7 +16,7 @@ "column": 11, "fixable": false, "line": 23, - "message": "Legacy calls are not allowed; found constant TYPO3_MOD_PATH. Removed in 7.4. It is required to route modules through typo3/mod.php from now on in case the module relies on the definition of those constants. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.4/Breaking-67987-RemovedEntryScriptHandling.html", + "message": "Calls to removed code are not allowed; found constant TYPO3_MOD_PATH. Removed in 7.4. It is required to route modules through typo3/mod.php from now on in case the module relies on the definition of those constants. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.4/Breaking-67987-RemovedEntryScriptHandling.html", "severity": 5, "source": "Typo3Update.Removed.GenericConstantUsage.TYPO3_MOD_PATH", "type": "WARNING" @@ -25,7 +25,7 @@ "column": 75, "fixable": false, "line": 24, - "message": "Legacy calls are not allowed; found constant \\TYPO3\\CMS\\IndexedSearch\\Controller\\SearchFormController::WILDCARD_LEFT. Removed in 7.6. Use \\TYPO3\\CMS\\IndexedSearch\\Utility\\LikeWildcard::LEFT instead. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.6/Breaking-69227-StringsForLikeAreNotProperlyEscaped.html", + "message": "Calls to removed code are not allowed; found constant \\TYPO3\\CMS\\IndexedSearch\\Controller\\SearchFormController::WILDCARD_LEFT. Removed in 7.6. Use \\TYPO3\\CMS\\IndexedSearch\\Utility\\LikeWildcard::LEFT instead. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.6/Breaking-69227-StringsForLikeAreNotProperlyEscaped.html", "severity": 5, "source": "Typo3Update.Removed.GenericConstantUsage.SearchFormController.WILDCARD_LEFT", "type": "WARNING" @@ -34,7 +34,7 @@ "column": 39, "fixable": false, "line": 27, - "message": "Legacy calls are not allowed; found constant \\TYPO3\\CMS\\IndexedSearch\\Controller\\SearchFormController::WILDCARD_LEFT. Removed in 7.6. Use \\TYPO3\\CMS\\IndexedSearch\\Utility\\LikeWildcard::LEFT instead. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.6/Breaking-69227-StringsForLikeAreNotProperlyEscaped.html", + "message": "Calls to removed code are not allowed; found constant \\TYPO3\\CMS\\IndexedSearch\\Controller\\SearchFormController::WILDCARD_LEFT. Removed in 7.6. Use \\TYPO3\\CMS\\IndexedSearch\\Utility\\LikeWildcard::LEFT instead. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.6/Breaking-69227-StringsForLikeAreNotProperlyEscaped.html", "severity": 5, "source": "Typo3Update.Removed.GenericConstantUsage.SearchFormController.WILDCARD_LEFT", "type": "WARNING" @@ -43,7 +43,7 @@ "column": 66, "fixable": false, "line": 29, - "message": "Legacy calls are not allowed; found constant \\TYPO3\\CMS\\IndexedSearch\\Controller\\SearchFormController::WILDCARD_LEFT. Removed in 7.6. Use \\TYPO3\\CMS\\IndexedSearch\\Utility\\LikeWildcard::LEFT instead. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.6/Breaking-69227-StringsForLikeAreNotProperlyEscaped.html", + "message": "Calls to removed code are not allowed; found constant \\TYPO3\\CMS\\IndexedSearch\\Controller\\SearchFormController::WILDCARD_LEFT. Removed in 7.6. Use \\TYPO3\\CMS\\IndexedSearch\\Utility\\LikeWildcard::LEFT instead. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.6/Breaking-69227-StringsForLikeAreNotProperlyEscaped.html", "severity": 5, "source": "Typo3Update.Removed.GenericConstantUsage.SearchFormController.WILDCARD_LEFT", "type": "WARNING" diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff/Expected.json b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff/Expected.json index f2e61ab..a818be1 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff/Expected.json +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff/Expected.json @@ -7,7 +7,7 @@ "column": 41, "fixable": false, "line": 24, - "message": "Legacy calls are not allowed; found \\TYPO3\\CMS\\Core\\Utility\\GeneralUtility::loadTCA. Removed in 7.0. There is no replacement, just remove call. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-61785-LoadTcaFunctionRemoved.html", + "message": "Calls to removed code are not allowed; found \\TYPO3\\CMS\\Core\\Utility\\GeneralUtility::loadTCA. Removed in 7.0. There is no replacement, just remove call. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-61785-LoadTcaFunctionRemoved.html", "severity": 5, "source": "Typo3Update.Removed.GenericFunctionCall.GeneralUtility.loadTCA", "type": "WARNING" @@ -16,7 +16,7 @@ "column": 17, "fixable": false, "line": 26, - "message": "Legacy calls are not allowed; found \\TYPO3\\CMS\\Core\\Utility\\GeneralUtility::loadTCA. Removed in 7.0. There is no replacement, just remove call. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-61785-LoadTcaFunctionRemoved.html", + "message": "Calls to removed code are not allowed; found \\TYPO3\\CMS\\Core\\Utility\\GeneralUtility::loadTCA. Removed in 7.0. There is no replacement, just remove call. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-61785-LoadTcaFunctionRemoved.html", "severity": 5, "source": "Typo3Update.Removed.GenericFunctionCall.GeneralUtility.loadTCA", "type": "WARNING" @@ -25,7 +25,7 @@ "column": 44, "fixable": false, "line": 28, - "message": "Legacy calls are not allowed; found \\TYPO3\\CMS\\Core\\Utility\\GeneralUtility::loadTCA. Removed in 7.0. There is no replacement, just remove call. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-61785-LoadTcaFunctionRemoved.html", + "message": "Calls to removed code are not allowed; found \\TYPO3\\CMS\\Core\\Utility\\GeneralUtility::loadTCA. Removed in 7.0. There is no replacement, just remove call. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-61785-LoadTcaFunctionRemoved.html", "severity": 5, "source": "Typo3Update.Removed.GenericFunctionCall.GeneralUtility.loadTCA", "type": "WARNING" @@ -34,7 +34,7 @@ "column": 8, "fixable": false, "line": 31, - "message": "Legacy calls are not allowed; found \\TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController->includeTCA. Removed in 7.0. Full TCA is always loaded during bootstrap in FE, the method is obsolete. If an eid script calls this method to load TCA, use \\TYPO3\\CMS\\Frontend\\Utility\\EidUtility::initTCA() instead. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-61785-FrontendTcaFunctionsRemoved.html", + "message": "Calls to removed code are not allowed; found \\TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController->includeTCA. Removed in 7.0. Full TCA is always loaded during bootstrap in FE, the method is obsolete. If an eid script calls this method to load TCA, use \\TYPO3\\CMS\\Frontend\\Utility\\EidUtility::initTCA() instead. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-61785-FrontendTcaFunctionsRemoved.html", "severity": 5, "source": "Typo3Update.Removed.GenericFunctionCall.TypoScriptFrontendController.includeTCA", "type": "WARNING" @@ -43,7 +43,7 @@ "column": 17, "fixable": false, "line": 35, - "message": "Legacy calls are not allowed; found \\TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController->includeTCA. Removed in 7.0. Full TCA is always loaded during bootstrap in FE, the method is obsolete. If an eid script calls this method to load TCA, use \\TYPO3\\CMS\\Frontend\\Utility\\EidUtility::initTCA() instead. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-61785-FrontendTcaFunctionsRemoved.html", + "message": "Calls to removed code are not allowed; found \\TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController->includeTCA. Removed in 7.0. Full TCA is always loaded during bootstrap in FE, the method is obsolete. If an eid script calls this method to load TCA, use \\TYPO3\\CMS\\Frontend\\Utility\\EidUtility::initTCA() instead. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-61785-FrontendTcaFunctionsRemoved.html", "severity": 5, "source": "Typo3Update.Removed.GenericFunctionCall.TypoScriptFrontendController.includeTCA", "type": "WARNING" diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptConstantSniff/Expected.json b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptConstantSniff/Expected.json new file mode 100644 index 0000000..e353a62 --- /dev/null +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptConstantSniff/Expected.json @@ -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 + } +} diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptConstantSniff/InputFileForIssues.ts b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptConstantSniff/InputFileForIssues.ts new file mode 100644 index 0000000..e8cc475 --- /dev/null +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptConstantSniff/InputFileForIssues.ts @@ -0,0 +1,8 @@ +test = TEXT +test { + value = Some stuff {$_clear} and some more. + value ( + Some values {$_tableWrap_DEBUG} + {$_tableWrap} + ) +} diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff/Expected.json b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff/Expected.json index ff6e6bd..e66a962 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff/Expected.json +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff/Expected.json @@ -7,7 +7,7 @@ "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", + "message": "Calls to removed code 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.TypoScript.styles-insertContent", "type": "WARNING" @@ -16,7 +16,7 @@ "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", + "message": "Calls to removed code 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.TypoScript.styles-insertContent", "type": "WARNING" @@ -25,7 +25,7 @@ "column": 1, "fixable": false, "line": 6, - "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", + "message": "Calls to removed code 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.TypoScript.styles-insertContent", "type": "WARNING" @@ -34,7 +34,7 @@ "column": 1, "fixable": false, "line": 13, - "message": "Legacy calls 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", + "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" @@ -43,7 +43,7 @@ "column": 10, "fixable": false, "line": 26, - "message": "Legacy calls 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", + "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", "type": "WARNING" @@ -52,7 +52,7 @@ "column": 10, "fixable": false, "line": 27, - "message": "Legacy calls 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", + "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", "type": "WARNING" @@ -61,7 +61,7 @@ "column": 10, "fixable": false, "line": 28, - "message": "Legacy calls 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", + "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", "type": "WARNING" @@ -70,7 +70,7 @@ "column": 10, "fixable": false, "line": 29, - "message": "Legacy calls 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", + "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", "type": "WARNING" @@ -79,7 +79,7 @@ "column": 10, "fixable": false, "line": 30, - "message": "Legacy calls 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", + "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"