diff --git a/config/v7/typo3-70.php b/config/v7/typo3-70.php index 15a881d1a..25e591871 100644 --- a/config/v7/typo3-70.php +++ b/config/v7/typo3-70.php @@ -8,6 +8,7 @@ use function Rector\SymfonyPhpConfig\inline_value_objects; use Ssch\TYPO3Rector\Rector\v7\v0\RemoveMethodCallConnectDbRector; use Ssch\TYPO3Rector\Rector\v7\v0\RemoveMethodCallLoadTcaRector; +use Ssch\TYPO3Rector\Rector\v7\v0\TypeHandlingServiceToTypeHandlingUtilityRector; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use TYPO3\CMS\Backend\Template\BigDocumentTemplate; use TYPO3\CMS\Backend\Template\DocumentTemplate; @@ -45,4 +46,6 @@ ), ]), ]]); + + $services->set(TypeHandlingServiceToTypeHandlingUtilityRector::class); }; diff --git a/src/Rector/v7/v0/TypeHandlingServiceToTypeHandlingUtilityRector.php b/src/Rector/v7/v0/TypeHandlingServiceToTypeHandlingUtilityRector.php new file mode 100644 index 000000000..10ec4df77 --- /dev/null +++ b/src/Rector/v7/v0/TypeHandlingServiceToTypeHandlingUtilityRector.php @@ -0,0 +1,61 @@ +isMethodStaticCallOrClassMethodObjectType($node, TypeHandlingService::class)) { + return null; + } + + $methodCall = $this->getName($node->name); + + if (null === $methodCall) { + return null; + } + + return $this->createStaticCall(TypeHandlingUtility::class, $methodCall, $node->args); + } + + /** + * @codeCoverageIgnore + */ + public function getDefinition(): RectorDefinition + { + return new RectorDefinition('Use TypeHandlingUtility instead of TypeHandlingService', [ + new CodeSample(<<<'PHP' +use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Extbase\Service\TypeHandlingService; +GeneralUtility::makeInstance(TypeHandlingService::class)->isSimpleType('string'); +PHP + , <<<'PHP' +use TYPO3\CMS\Extbase\Utility\TypeHandlingUtility; +TypeHandlingUtility::isSimpleType('string'); +PHP + ), + ]); + } +} diff --git a/stubs/Extbase/Service/TypeHandlingService.php b/stubs/Extbase/Service/TypeHandlingService.php new file mode 100644 index 000000000..97d05c833 --- /dev/null +++ b/stubs/Extbase/Service/TypeHandlingService.php @@ -0,0 +1,28 @@ +parseType('string'); +$typeHandlingService->normalizeType('string'); +$typeHandlingService->isLiteral('string'); +$typeHandlingService->isSimpleType('string'); + + +?> +----- +doTestFileInfo($fileInfo); + } + + public function provideDataForTest(): Iterator + { + return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); + } + + protected function getRectorClass(): string + { + return TypeHandlingServiceToTypeHandlingUtilityRector::class; + } +}