diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstanceofSniff/Expected.diff b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstanceofSniff/Expected.diff new file mode 100644 index 0000000..9a5a9e1 --- /dev/null +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstanceofSniff/Expected.diff @@ -0,0 +1,10 @@ +--- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstanceofSniff/InputFileForIssues.php ++++ PHP_CodeSniffer +@@ -19,6 +19,6 @@ + * 02110-1301, USA. + */ + +-if ($a instanceof t3lib_Singleton) { ++if ($a instanceof \TYPO3\CMS\Core\SingletonInterface) { + // do something + } diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstanceofSniff/Expected.json b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstanceofSniff/Expected.json new file mode 100644 index 0000000..33aca48 --- /dev/null +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstanceofSniff/Expected.json @@ -0,0 +1,24 @@ +{ + "files": { + "InputFileForIssues.php": { + "errors": 1, + "messages": [ + { + "column": 19, + "fixable": true, + "line": 22, + "message": "Legacy classes are not allowed; found \"t3lib_Singleton\", use \"TYPO3\\CMS\\Core\\SingletonInterface\" instead", + "severity": 5, + "source": "Typo3Update.LegacyClassnames.Instanceof.legacyClassname", + "type": "ERROR" + } + ], + "warnings": 0 + } + }, + "totals": { + "errors": 1, + "fixable": 1, + "warnings": 0 + } +} diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstanceofSniff/InputFileForIssues.php b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstanceofSniff/InputFileForIssues.php new file mode 100644 index 0000000..8fe907f --- /dev/null +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstanceofSniff/InputFileForIssues.php @@ -0,0 +1,24 @@ + + * + * 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. + */ + +if ($a instanceof t3lib_Singleton) { + // do something +} diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithMakeInstanceSniff/Expected.diff b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithMakeInstanceSniff/Expected.diff new file mode 100644 index 0000000..46b2b0c --- /dev/null +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithMakeInstanceSniff/Expected.diff @@ -0,0 +1,10 @@ +--- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithMakeInstanceSniff/InputFileForIssues.php ++++ PHP_CodeSniffer +@@ -19,6 +19,6 @@ + * 02110-1301, USA. + */ + +-t3lib_div::makeInstance('Tx_Extbase_Command_HelpCommandController'); ++t3lib_div::makeInstance('\TYPO3\CMS\Extbase\Command\HelpCommandController'); + // 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/LegacyClassnames/InstantiationWithMakeInstanceSniff/Expected.json b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithMakeInstanceSniff/Expected.json new file mode 100644 index 0000000..d7f166c --- /dev/null +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithMakeInstanceSniff/Expected.json @@ -0,0 +1,24 @@ +{ + "files": { + "InputFileForIssues.php": { + "errors": 1, + "messages": [ + { + "column": 25, + "fixable": true, + "line": 22, + "message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead", + "severity": 5, + "source": "Typo3Update.LegacyClassnames.InstantiationWithMakeInstance.legacyClassname", + "type": "ERROR" + } + ], + "warnings": 0 + } + }, + "totals": { + "errors": 1, + "fixable": 1, + "warnings": 0 + } +} diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithMakeInstanceSniff/InputFileForIssues.php b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithMakeInstanceSniff/InputFileForIssues.php new file mode 100644 index 0000000..12550c5 --- /dev/null +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithMakeInstanceSniff/InputFileForIssues.php @@ -0,0 +1,24 @@ + + * + * 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. + */ + +t3lib_div::makeInstance('Tx_Extbase_Command_HelpCommandController'); +// 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/LegacyClassnames/InstantiationWithNewSniff/Expected.diff b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithNewSniff/Expected.diff new file mode 100644 index 0000000..7fe1f38 --- /dev/null +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithNewSniff/Expected.diff @@ -0,0 +1,22 @@ +--- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithNewSniff/InputFileForIssues.php ++++ PHP_CodeSniffer +@@ -19,13 +19,13 @@ + * 02110-1301, USA. + */ + +-new \Tx_Extbase_Command_HelpCommandController(); +-new \Tx_Extbase_Command_HelpCommandController; +-(new \Tx_Extbase_Command_HelpCommandController) ++new \TYPO3\CMS\Extbase\Command\HelpCommandController(); ++new \TYPO3\CMS\Extbase\Command\HelpCommandController; ++(new \TYPO3\CMS\Extbase\Command\HelpCommandController) + ->doSomething() + ; +-new Tx_Extbase_Command_HelpCommandController(); +-new Tx_Extbase_Command_HelpCommandController; +-(new Tx_Extbase_Command_HelpCommandController) ++new \TYPO3\CMS\Extbase\Command\HelpCommandController(); ++new \TYPO3\CMS\Extbase\Command\HelpCommandController; ++(new \TYPO3\CMS\Extbase\Command\HelpCommandController) + ->doSomething() + ; diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithNewSniff/Expected.json b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithNewSniff/Expected.json new file mode 100644 index 0000000..0183bc5 --- /dev/null +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithNewSniff/Expected.json @@ -0,0 +1,69 @@ +{ + "files": { + "InputFileForIssues.php": { + "errors": 6, + "messages": [ + { + "column": 6, + "fixable": true, + "line": 22, + "message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead", + "severity": 5, + "source": "Typo3Update.LegacyClassnames.InstantiationWithNew.legacyClassname", + "type": "ERROR" + }, + { + "column": 6, + "fixable": true, + "line": 23, + "message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead", + "severity": 5, + "source": "Typo3Update.LegacyClassnames.InstantiationWithNew.legacyClassname", + "type": "ERROR" + }, + { + "column": 7, + "fixable": true, + "line": 24, + "message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead", + "severity": 5, + "source": "Typo3Update.LegacyClassnames.InstantiationWithNew.legacyClassname", + "type": "ERROR" + }, + { + "column": 5, + "fixable": true, + "line": 27, + "message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead", + "severity": 5, + "source": "Typo3Update.LegacyClassnames.InstantiationWithNew.legacyClassname", + "type": "ERROR" + }, + { + "column": 5, + "fixable": true, + "line": 28, + "message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead", + "severity": 5, + "source": "Typo3Update.LegacyClassnames.InstantiationWithNew.legacyClassname", + "type": "ERROR" + }, + { + "column": 6, + "fixable": true, + "line": 29, + "message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead", + "severity": 5, + "source": "Typo3Update.LegacyClassnames.InstantiationWithNew.legacyClassname", + "type": "ERROR" + } + ], + "warnings": 0 + } + }, + "totals": { + "errors": 6, + "fixable": 6, + "warnings": 0 + } +} diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithNewSniff/InputFileForIssues.php b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithNewSniff/InputFileForIssues.php new file mode 100644 index 0000000..1f58640 --- /dev/null +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithNewSniff/InputFileForIssues.php @@ -0,0 +1,31 @@ + + * + * 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. + */ + +new \Tx_Extbase_Command_HelpCommandController(); +new \Tx_Extbase_Command_HelpCommandController; +(new \Tx_Extbase_Command_HelpCommandController) + ->doSomething() + ; +new Tx_Extbase_Command_HelpCommandController(); +new Tx_Extbase_Command_HelpCommandController; +(new Tx_Extbase_Command_HelpCommandController) + ->doSomething() + ; diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithObjectManagerSniff/Expected.diff b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithObjectManagerSniff/Expected.diff new file mode 100644 index 0000000..03ae814 --- /dev/null +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithObjectManagerSniff/Expected.diff @@ -0,0 +1,20 @@ +--- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithObjectManagerSniff/InputFileForIssues.php ++++ PHP_CodeSniffer +@@ -21,13 +21,13 @@ + + // Not handled by this sniff, but StaticCallSniff, as this uses double colon. + $this->objectManager->get(\Tx_Extbase_Command_HelpCommandController::class); +-$this->objectManager->get('\Tx_Extbase_Command_HelpCommandController'); +-$this->objectManager->get('Tx_Extbase_Command_HelpCommandController'); ++$this->objectManager->get('\TYPO3\CMS\Extbase\Command\HelpCommandController'); ++$this->objectManager->get('\TYPO3\CMS\Extbase\Command\HelpCommandController'); + + \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager) + // Not handled by this sniff, but StaticCallSniff, as this uses double colon. + ->get(\Tx_Extbase_Command_HelpCommandController::class); + \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager) +- ->get('\Tx_Extbase_Command_HelpCommandController'); ++ ->get('\TYPO3\CMS\Extbase\Command\HelpCommandController'); + \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager) +- ->get('Tx_Extbase_Command_HelpCommandController'); ++ ->get('\TYPO3\CMS\Extbase\Command\HelpCommandController'); diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithObjectManagerSniff/Expected.json b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithObjectManagerSniff/Expected.json new file mode 100644 index 0000000..d2a52d1 --- /dev/null +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithObjectManagerSniff/Expected.json @@ -0,0 +1,69 @@ +{ + "files": { + "InputFileForIssues.php": { + "errors": 6, + "messages": [ + { + "column": 27, + "fixable": true, + "line": 24, + "message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead", + "severity": 5, + "source": "Typo3Update.LegacyClassnames.InstantiationWithObjectManager.legacyClassname", + "type": "ERROR" + }, + { + "column": 27, + "fixable": true, + "line": 24, + "message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead", + "severity": 5, + "source": "Typo3Update.LegacyClassnames.InstantiationWithObjectManager.legacyClassname", + "type": "ERROR" + }, + { + "column": 27, + "fixable": true, + "line": 25, + "message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead", + "severity": 5, + "source": "Typo3Update.LegacyClassnames.InstantiationWithObjectManager.legacyClassname", + "type": "ERROR" + }, + { + "column": 11, + "fixable": true, + "line": 31, + "message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead", + "severity": 5, + "source": "Typo3Update.LegacyClassnames.InstantiationWithObjectManager.legacyClassname", + "type": "ERROR" + }, + { + "column": 11, + "fixable": true, + "line": 31, + "message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead", + "severity": 5, + "source": "Typo3Update.LegacyClassnames.InstantiationWithObjectManager.legacyClassname", + "type": "ERROR" + }, + { + "column": 11, + "fixable": true, + "line": 33, + "message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead", + "severity": 5, + "source": "Typo3Update.LegacyClassnames.InstantiationWithObjectManager.legacyClassname", + "type": "ERROR" + } + ], + "warnings": 0 + } + }, + "totals": { + "errors": 6, + "fixable": 6, + "warnings": 0 + } +} diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithObjectManagerSniff/InputFileForIssues.php b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithObjectManagerSniff/InputFileForIssues.php new file mode 100644 index 0000000..75d9d58 --- /dev/null +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithObjectManagerSniff/InputFileForIssues.php @@ -0,0 +1,33 @@ + + * + * 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. + */ + +// Not handled by this sniff, but StaticCallSniff, as this uses double colon. +$this->objectManager->get(\Tx_Extbase_Command_HelpCommandController::class); +$this->objectManager->get('\Tx_Extbase_Command_HelpCommandController'); +$this->objectManager->get('Tx_Extbase_Command_HelpCommandController'); + +\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager) + // Not handled by this sniff, but StaticCallSniff, as this uses double colon. + ->get(\Tx_Extbase_Command_HelpCommandController::class); +\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager) + ->get('\Tx_Extbase_Command_HelpCommandController'); +\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager) + ->get('Tx_Extbase_Command_HelpCommandController');