From 34e616355f528679f1aae110c2ddfcd1dbe8c4ec Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 13 Apr 2017 11:49:53 +0200 Subject: [PATCH 1/3] TASK: Add missing test for GenericConstantUsageSniff Relates: #64 --- .../GenericConstantUsageSniff/Expected.json | 33 +++++++++++++++++++ .../InputFileForIssues.php | 23 +++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff/Expected.json create mode 100644 tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff/InputFileForIssues.php diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff/Expected.json b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff/Expected.json new file mode 100644 index 0000000..6e63f1d --- /dev/null +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff/Expected.json @@ -0,0 +1,33 @@ +{ + "files": { + "InputFileForIssues.php": { + "errors": 0, + "messages": [ + { + "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", + "severity": 5, + "source": "Typo3Update.Removed.GenericConstantUsage.PATH_tslib", + "type": "WARNING" + }, + { + "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", + "severity": 5, + "source": "Typo3Update.Removed.GenericConstantUsage.TYPO3_MOD_PATH", + "type": "WARNING" + } + ], + "warnings": 2 + } + }, + "totals": { + "errors": 0, + "fixable": 0, + "warnings": 2 + } +} diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff/InputFileForIssues.php b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff/InputFileForIssues.php new file mode 100644 index 0000000..944af55 --- /dev/null +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff/InputFileForIssues.php @@ -0,0 +1,23 @@ + + * + * 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. + */ + +$file = PATH_tslib . 'something.php'; +$module = TYPO3_MOD_PATH . '/folder'; From 9a905c492a3ef2c3ded055e96e274abd2728738f Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 13 Apr 2017 11:56:52 +0200 Subject: [PATCH 2/3] TASK: Add missing test for GenericFunctionCallSniff Resolves: #64 --- .../GenericFunctionCallSniff/Expected.json | 60 +++++++++++++++++++ .../InputFileForIssues.php | 35 +++++++++++ 2 files changed, 95 insertions(+) create mode 100644 tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff/Expected.json create mode 100644 tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff/InputFileForIssues.php diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff/Expected.json b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff/Expected.json new file mode 100644 index 0000000..f2e61ab --- /dev/null +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff/Expected.json @@ -0,0 +1,60 @@ +{ + "files": { + "InputFileForIssues.php": { + "errors": 0, + "messages": [ + { + "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", + "severity": 5, + "source": "Typo3Update.Removed.GenericFunctionCall.GeneralUtility.loadTCA", + "type": "WARNING" + }, + { + "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", + "severity": 5, + "source": "Typo3Update.Removed.GenericFunctionCall.GeneralUtility.loadTCA", + "type": "WARNING" + }, + { + "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", + "severity": 5, + "source": "Typo3Update.Removed.GenericFunctionCall.GeneralUtility.loadTCA", + "type": "WARNING" + }, + { + "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", + "severity": 5, + "source": "Typo3Update.Removed.GenericFunctionCall.TypoScriptFrontendController.includeTCA", + "type": "WARNING" + }, + { + "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", + "severity": 5, + "source": "Typo3Update.Removed.GenericFunctionCall.TypoScriptFrontendController.includeTCA", + "type": "WARNING" + } + ], + "warnings": 5 + } + }, + "totals": { + "errors": 0, + "fixable": 0, + "warnings": 5 + } +} diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff/InputFileForIssues.php b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff/InputFileForIssues.php new file mode 100644 index 0000000..5f65331 --- /dev/null +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff/InputFileForIssues.php @@ -0,0 +1,35 @@ + + * + * 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 TYPO3\CMS\Core\Utility\GeneralUtility; + +\TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA('some_tca_table'); +// Both works, as we check last part of class name only. +GeneralUtility::loadTCA('some_tca_table'); +// Also matches, as we don't check whole name for now, to enable the above check with imported name. +\OwnVendor\ExtName\Utility\GeneralUtility::loadTCA('some_tca_table'); + +$test = new \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController(); +$test->includeTCA(); + +$someThingElse = new \DateTime(); +// Is also detected, as we do not check type of variable. +$someThingElse->includeTCA(); From 6a3d18ecfc8379c51b6e6ea6c89aa76afcaa0ca5 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 13 Apr 2017 12:02:44 +0200 Subject: [PATCH 3/3] TASK: Add further test cases to GenericConstantUsageSniff * To show what's also working and what will potentially provide non helpful warnings. Relates: #64 --- .../GenericConstantUsageSniff/Expected.json | 31 +++++++++++++++++-- .../InputFileForIssues.php | 6 ++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff/Expected.json b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff/Expected.json index 6e63f1d..e3072f3 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff/Expected.json +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff/Expected.json @@ -20,14 +20,41 @@ "severity": 5, "source": "Typo3Update.Removed.GenericConstantUsage.TYPO3_MOD_PATH", "type": "WARNING" + }, + { + "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", + "severity": 5, + "source": "Typo3Update.Removed.GenericConstantUsage.SearchFormController.WILDCARD_LEFT", + "type": "WARNING" + }, + { + "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", + "severity": 5, + "source": "Typo3Update.Removed.GenericConstantUsage.SearchFormController.WILDCARD_LEFT", + "type": "WARNING" + }, + { + "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", + "severity": 5, + "source": "Typo3Update.Removed.GenericConstantUsage.SearchFormController.WILDCARD_LEFT", + "type": "WARNING" } ], - "warnings": 2 + "warnings": 5 } }, "totals": { "errors": 0, "fixable": 0, - "warnings": 2 + "warnings": 5 } } diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff/InputFileForIssues.php b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff/InputFileForIssues.php index 944af55..1a199ae 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff/InputFileForIssues.php +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff/InputFileForIssues.php @@ -21,3 +21,9 @@ $file = PATH_tslib . 'something.php'; $module = TYPO3_MOD_PATH . '/folder'; +$someVariable = \TYPO3\CMS\IndexedSearch\Controller\SearchFormController::WILDCARD_LEFT . '/folder'; +use \TYPO3\CMS\IndexedSearch\Controller\SearchFormController; +// Will work, as we only check last part of class name. +$someVariable = SearchFormController::WILDCARD_LEFT . '/folder'; +// Also matches, as we don't check whole name for now, to enable the above check with imported name. +$someVariable = \Vendor\ExtName\Controller\SearchFormController::WILDCARD_LEFT . '/folder';