From 53d727fa4bf50a32424f6ee1da25574a62853756 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 11 May 2017 08:59:37 +0200 Subject: [PATCH] FEATURE: Make sure namespaces are only applied for Tx_ class definitions * E.g. prevent migration for ux_ classes which do not follow the convention. * Add test to make sure it works as expected. --- .../LegacyClassname/MissingNamespaceSniff.php | 3 ++ .../alreadyMigrated/Expected.diff | 0 .../alreadyMigrated/Expected.json | 14 ++++++++++ .../alreadyMigrated/InputFileForIssues.php | 28 +++++++++++++++++++ .../nothingTodo/InputFileForIssues.php | 4 +-- 5 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingNamespaceSniff/alreadyMigrated/Expected.diff create mode 100644 tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingNamespaceSniff/alreadyMigrated/Expected.json create mode 100644 tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingNamespaceSniff/alreadyMigrated/InputFileForIssues.php diff --git a/src/Standards/Typo3Update/Sniffs/LegacyClassname/MissingNamespaceSniff.php b/src/Standards/Typo3Update/Sniffs/LegacyClassname/MissingNamespaceSniff.php index ccc1b96..28a5b89 100644 --- a/src/Standards/Typo3Update/Sniffs/LegacyClassname/MissingNamespaceSniff.php +++ b/src/Standards/Typo3Update/Sniffs/LegacyClassname/MissingNamespaceSniff.php @@ -67,6 +67,9 @@ class Typo3Update_Sniffs_LegacyClassname_MissingNamespaceSniff implements PhpCsS } $classname = $tokens[$classnamePosition]['content']; + if (substr($classname, 0, 3) !== 'Tx_') { + return; + } LegacyClassnameMapping::getInstance()->addLegacyClassname( $classname, diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingNamespaceSniff/alreadyMigrated/Expected.diff b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingNamespaceSniff/alreadyMigrated/Expected.diff new file mode 100644 index 0000000..e69de29 diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingNamespaceSniff/alreadyMigrated/Expected.json b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingNamespaceSniff/alreadyMigrated/Expected.json new file mode 100644 index 0000000..b703ca7 --- /dev/null +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingNamespaceSniff/alreadyMigrated/Expected.json @@ -0,0 +1,14 @@ +{ + "files": { + "InputFileForIssues.php": { + "errors": 0, + "messages": [], + "warnings": 0 + } + }, + "totals": { + "errors": 0, + "fixable": 0, + "warnings": 0 + } +} diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingNamespaceSniff/alreadyMigrated/InputFileForIssues.php b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingNamespaceSniff/alreadyMigrated/InputFileForIssues.php new file mode 100644 index 0000000..8f90a27 --- /dev/null +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingNamespaceSniff/alreadyMigrated/InputFileForIssues.php @@ -0,0 +1,28 @@ + + * + * 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 Tx_Extbase_Mvc_Controller_ActionController; + +class Frontendcontroller extends Tx_Extbase_Mvc_Controller_ActionController +{ +} diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingNamespaceSniff/nothingTodo/InputFileForIssues.php b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingNamespaceSniff/nothingTodo/InputFileForIssues.php index 8f90a27..4a74e18 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingNamespaceSniff/nothingTodo/InputFileForIssues.php +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingNamespaceSniff/nothingTodo/InputFileForIssues.php @@ -1,7 +1,5 @@ * @@ -23,6 +21,6 @@ namespace Vendor\ExtName\Controller; use Tx_Extbase_Mvc_Controller_ActionController; -class Frontendcontroller extends Tx_Extbase_Mvc_Controller_ActionController +class ux_t3lib_DB extends t3lib_DB { }