diff --git a/composer.json b/composer.json index 91d65cdb7..c9b8b60c1 100644 --- a/composer.json +++ b/composer.json @@ -12,15 +12,15 @@ "require": { "php": "^7.3|^8.0", "phpstan/phpstan": "^0.12.69, <0.12.70", - "rector/rector": "0.9.18" + "rector/rector": "0.9.20" }, "require-dev": { "captainhook/captainhook": "^5.4", "captainhook/plugin-composer": "^5.2", - "phpunit/phpunit": "^8.0|^9.0", - "symplify/coding-standard": "^9.0.17", - "symplify/easy-coding-standard": "^9.0.17", - "symplify/phpstan-extensions": "^9.0.17" + "phpunit/phpunit": "^9.0", + "symplify/coding-standard": "^9.1", + "symplify/easy-coding-standard": "^9.1", + "symplify/phpstan-extensions": "^9.1" }, "autoload": { "psr-4": { @@ -56,7 +56,5 @@ "docs": "vendor/bin/rule-doc-generator generate src/Rector --output-file docs/all_rectors_overview.md --ansi", "rector": "vendor/bin/rector rectify --dry-run --ansi --match-git-diff", "fix-rector": "vendor/bin/rector rectify --ansi" - }, - "minimum-stability": "dev", - "prefer-stable": true + } } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon deleted file mode 100644 index 6802b694a..000000000 --- a/phpstan-baseline.neon +++ /dev/null @@ -1,11 +0,0 @@ -parameters: - ignoreErrors: - - - message: "#^Parameter \\#2 \\$stmt of method Rector\\\\Core\\\\PhpParser\\\\Node\\\\Manipulator\\\\ClassInsertManipulator\\:\\:addAsFirstMethod\\(\\) expects PhpParser\\\\Node\\\\Stmt\\\\ClassConst\\|PhpParser\\\\Node\\\\Stmt\\\\ClassMethod\\|PhpParser\\\\Node\\\\Stmt\\\\Property, PhpParser\\\\Node\\\\Stmt\\\\Nop given\\.$#" - count: 1 - path: src/Rector/v10/v2/InjectEnvironmentServiceIfNeededInResponseRector.php - - - - message: "#^Method Ssch\\\\TYPO3Rector\\\\Set\\\\Typo3RectorSetProvider\\:\\:hydrateSetsFromConstants\\(\\) has parameter \\$setListReflectionClass with generic class ReflectionClass but does not specify its types\\: T$#" - count: 1 - path: src/Set/Typo3RectorSetProvider.php diff --git a/phpstan.neon b/phpstan.neon index bc0539c77..e10dc073b 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -2,7 +2,6 @@ includes: # see https://github.com/symplify/phpstan-extensions - vendor/symplify/phpstan-extensions/config/config.neon - utils/phpstan/config/typo3-rector.neon - - phpstan-baseline.neon parameters: level: 8 @@ -17,8 +16,12 @@ parameters: inferPrivatePropertyTypeFromConstructor: true checkMissingIterableValueType: false + + checkGenericClassInNonGenericObjectType: false + ignoreErrors: - '#Function Symfony\\Component\\DependencyInjection\\Loader\\Configurator\\ref not found#' - '#Function Symfony\\Component\\DependencyInjection\\Loader\\Configurator\\service not found#' - '#Used function Symfony\\Component\\DependencyInjection\\Loader\\Configurator\\ref not found#' - '#Used function Symfony\\Component\\DependencyInjection\\Loader\\Configurator\\service not found#' + - '#Parameter \#2 \$stmt of method Rector\\Core\\NodeManipulator\\ClassInsertManipulator\:\:addAsFirstMethod\(\) expects PhpParser\\Node\\Stmt\\ClassConst\|PhpParser\\Node\\Stmt\\ClassMethod\|PhpParser\\Node\\Stmt\\Property, PhpParser\\Node\\Stmt\\Nop given#' diff --git a/src/Helper/Database/Refactorings/ConnectionCallTrait.php b/src/Helper/Database/Refactorings/ConnectionCallFactory.php similarity index 78% rename from src/Helper/Database/Refactorings/ConnectionCallTrait.php rename to src/Helper/Database/Refactorings/ConnectionCallFactory.php index 603aa009a..0845518e4 100644 --- a/src/Helper/Database/Refactorings/ConnectionCallTrait.php +++ b/src/Helper/Database/Refactorings/ConnectionCallFactory.php @@ -11,22 +11,19 @@ use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Utility\GeneralUtility; -trait ConnectionCallTrait +final class ConnectionCallFactory { /** * @var NodeFactory */ - protected $nodeFactory; + private $nodeFactory; - /** - * @required - */ - public function autowireNodeFactoryTrait(NodeFactory $nodeFactory): void + public function __construct(NodeFactory $nodeFactory) { $this->nodeFactory = $nodeFactory; } - private function createConnectionCall(Arg $firstArgument): Assign + public function createConnectionCall(Arg $firstArgument): Assign { $connection = $this->nodeFactory->createMethodCall( $this->nodeFactory->createStaticCall(GeneralUtility::class, 'makeInstance', [ diff --git a/src/Helper/Database/Refactorings/DatabaseConnectionExecInsertQueryRefactoring.php b/src/Helper/Database/Refactorings/DatabaseConnectionExecInsertQueryRefactoring.php index 332bb8aaa..f45202224 100644 --- a/src/Helper/Database/Refactorings/DatabaseConnectionExecInsertQueryRefactoring.php +++ b/src/Helper/Database/Refactorings/DatabaseConnectionExecInsertQueryRefactoring.php @@ -6,10 +6,25 @@ use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Expr\Variable; +use Rector\Core\PhpParser\Node\NodeFactory; final class DatabaseConnectionExecInsertQueryRefactoring implements DatabaseConnectionToDbalRefactoring { - use ConnectionCallTrait; + /** + * @var ConnectionCallFactory + */ + private $connectionCallFactory; + + /** + * @var NodeFactory + */ + private $nodeFactory; + + public function __construct(ConnectionCallFactory $connectionCallFactory, NodeFactory $nodeFactory) + { + $this->connectionCallFactory = $connectionCallFactory; + $this->nodeFactory = $nodeFactory; + } public function refactor(MethodCall $oldNode): array { @@ -20,7 +35,7 @@ public function refactor(MethodCall $oldNode): array return []; } - $connectionAssignment = $this->createConnectionCall($tableArgument); + $connectionAssignment = $this->connectionCallFactory->createConnectionCall($tableArgument); $connectionInsertCall = $this->nodeFactory->createMethodCall( new Variable('connection'), 'insert', [$tableArgument->value, $dataArgument->value] diff --git a/src/Helper/Database/Refactorings/DatabaseConnectionExecTruncateTableRefactoring.php b/src/Helper/Database/Refactorings/DatabaseConnectionExecTruncateTableRefactoring.php index 7e21e9f54..6462d7e73 100644 --- a/src/Helper/Database/Refactorings/DatabaseConnectionExecTruncateTableRefactoring.php +++ b/src/Helper/Database/Refactorings/DatabaseConnectionExecTruncateTableRefactoring.php @@ -6,10 +6,25 @@ use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Expr\Variable; +use Rector\Core\PhpParser\Node\NodeFactory; final class DatabaseConnectionExecTruncateTableRefactoring implements DatabaseConnectionToDbalRefactoring { - use ConnectionCallTrait; + /** + * @var ConnectionCallFactory + */ + private $connectionCallFactory; + + /** + * @var NodeFactory + */ + private $nodeFactory; + + public function __construct(ConnectionCallFactory $connectionCallFactory, NodeFactory $nodeFactory) + { + $this->connectionCallFactory = $connectionCallFactory; + $this->nodeFactory = $nodeFactory; + } public function refactor(MethodCall $oldNode): array { @@ -19,7 +34,7 @@ public function refactor(MethodCall $oldNode): array return []; } - $connectionAssignment = $this->createConnectionCall($tableArgument); + $connectionAssignment = $this->connectionCallFactory->createConnectionCall($tableArgument); $connectionInsertCall = $this->nodeFactory->createMethodCall( new Variable('connection'), 'truncate', [$tableArgument->value] diff --git a/src/Helper/Typo3NodeResolver.php b/src/Helper/Typo3NodeResolver.php index 4dd8674d1..eb6618dcb 100644 --- a/src/Helper/Typo3NodeResolver.php +++ b/src/Helper/Typo3NodeResolver.php @@ -11,14 +11,12 @@ use PhpParser\Node\Expr\PropertyFetch; use PHPStan\Type\ObjectType; use Rector\Core\PhpParser\Node\Value\ValueResolver; -use Rector\Core\Rector\AbstractRector\NameResolverTrait; -use Rector\Core\Rector\AbstractRector\NodeTypeResolverTrait; +use Rector\NodeNameResolver\NodeNameResolver; +use Rector\NodeTypeResolver\Node\AttributeKey; +use Rector\NodeTypeResolver\NodeTypeResolver; final class Typo3NodeResolver { - use NameResolverTrait; - use NodeTypeResolverTrait; - /** * @var string */ @@ -85,11 +83,23 @@ final class Typo3NodeResolver private $valueResolver; /** - * @required + * @var NodeNameResolver */ - public function autowireValueResolverTrait(ValueResolver $valueResolver): void - { + private $nodeNameResolver; + + /** + * @var NodeTypeResolver + */ + private $nodeTypeResolver; + + public function __construct( + ValueResolver $valueResolver, + NodeNameResolver $nodeNameResolver, + NodeTypeResolver $nodeTypeResolver + ) { $this->valueResolver = $valueResolver; + $this->nodeNameResolver = $nodeNameResolver; + $this->nodeTypeResolver = $nodeTypeResolver; } public function isMethodCallOnGlobals(Node $node, string $methodCall, string $global): bool @@ -102,11 +112,11 @@ public function isMethodCallOnGlobals(Node $node, string $methodCall, string $gl return false; } - if (! $this->isName($node->name, $methodCall)) { + if (! $this->nodeNameResolver->isName($node->name, $methodCall)) { return false; } - if (! $this->isName($node->var->var, self::GLOBALS)) { + if (! $this->nodeNameResolver->isName($node->var->var, self::GLOBALS)) { return false; } @@ -127,7 +137,7 @@ public function isAnyMethodCallOnGlobals(Node $node, string $global): bool return false; } - if (! $this->isName($node->var->var, self::GLOBALS)) { + if (! $this->nodeNameResolver->isName($node->var->var, self::GLOBALS)) { return false; } @@ -144,7 +154,7 @@ public function isTypo3Global(Node $node, string $global): bool return false; } - if (! $this->isName($node->var, self::GLOBALS)) { + if (! $this->nodeNameResolver->isName($node->var, self::GLOBALS)) { return false; } @@ -186,7 +196,7 @@ public function isPropertyFetchOnAnyPropertyOfGlobals(Node $node, string $global return false; } - if (! $this->isName($node->var->var, self::GLOBALS)) { + if (! $this->nodeNameResolver->isName($node->var->var, self::GLOBALS)) { return false; } @@ -216,11 +226,11 @@ public function isMethodCallOnPropertyOfGlobals(Node $node, string $global, stri return false; } - if (! $this->isName($node->var->var->var, self::GLOBALS)) { + if (! $this->nodeNameResolver->isName($node->var->var->var, self::GLOBALS)) { return false; } - if (! $this->isName($node->var->name, $property)) { + if (! $this->nodeNameResolver->isName($node->var->name, $property)) { return false; } @@ -238,7 +248,7 @@ public function isMethodCallOnBackendUser(Node $node): bool private function isPropertyFetchOnParentVariableOfType(Node $node, string $type): bool { - $parentNode = $node->getAttribute('parent'); + $parentNode = $node->getAttribute(AttributeKey::PARENT_NODE); if (! $parentNode instanceof Assign) { return false; @@ -248,7 +258,7 @@ private function isPropertyFetchOnParentVariableOfType(Node $node, string $type) return false; } - $objectType = $this->getObjectType($parentNode->expr->var); + $objectType = $this->nodeTypeResolver->getStaticType($parentNode->expr->var); if (! $objectType instanceof ObjectType) { return false; diff --git a/src/NodeAnalyzer/ClassConstAnalyzer.php b/src/NodeAnalyzer/ClassConstAnalyzer.php new file mode 100644 index 000000000..b5ec02ca3 --- /dev/null +++ b/src/NodeAnalyzer/ClassConstAnalyzer.php @@ -0,0 +1,38 @@ +nodeNameResolver = $nodeNameResolver; + } + + /** + * Detects "SomeClass::class" + */ + public function isClassConstReference(Expr $expr, string $className): bool + { + if (! $expr instanceof ClassConstFetch) { + return false; + } + + if (! $this->nodeNameResolver->isName($expr->name, 'class')) { + return false; + } + + return $this->nodeNameResolver->isName($expr->class, $className); + } +} diff --git a/src/NodeFactory/InitializeArgumentsClassMethodFactory.php b/src/NodeFactory/InitializeArgumentsClassMethodFactory.php index 704e317be..dc168e427 100644 --- a/src/NodeFactory/InitializeArgumentsClassMethodFactory.php +++ b/src/NodeFactory/InitializeArgumentsClassMethodFactory.php @@ -4,7 +4,6 @@ namespace Ssch\TYPO3Rector\NodeFactory; -use PhpParser\BuilderFactory; use PhpParser\Node; use PhpParser\Node\Expr; use PhpParser\Node\Expr\ConstFetch; @@ -27,7 +26,6 @@ use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo; use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory; use Rector\Core\PhpParser\Node\NodeFactory; -use Rector\Core\Rector\AbstractRector\NameResolverTrait; use Rector\NodeNameResolver\NodeNameResolver; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\PHPStanStaticTypeMapper\PHPStanStaticTypeMapper; @@ -35,11 +33,10 @@ use Rector\StaticTypeMapper\ValueObject\Type\ShortenedObjectType; use Rector\TypeDeclaration\TypeInferer\ParamTypeInferer; use ReflectionClass; +use Symplify\Astral\ValueObject\NodeBuilder\MethodBuilder; final class InitializeArgumentsClassMethodFactory { - use NameResolverTrait; - /** * @var string */ @@ -50,11 +47,6 @@ final class InitializeArgumentsClassMethodFactory */ private const MIXED = 'mixed'; - /** - * @var BuilderFactory - */ - private $builderFactory; - /** * @var NodeFactory */ @@ -75,15 +67,18 @@ final class InitializeArgumentsClassMethodFactory */ private $phpDocInfoFactory; + /** + * @var NodeNameResolver + */ + private $nodeNameResolver; + public function __construct( - BuilderFactory $builderFactory, NodeFactory $nodeFactory, NodeNameResolver $nodeNameResolver, StaticTypeMapper $staticTypeMapper, ParamTypeInferer $paramTypeInferer, PhpDocInfoFactory $phpDocInfoFactory ) { - $this->builderFactory = $builderFactory; $this->nodeFactory = $nodeFactory; $this->nodeNameResolver = $nodeNameResolver; $this->staticTypeMapper = $staticTypeMapper; @@ -132,7 +127,7 @@ private function findOrCreateInitializeArgumentsClassMethod(Class_ $class): Clas private function createNewClassMethod(): ClassMethod { - $methodBuilder = $this->builderFactory->method(self::METHOD_NAME); + $methodBuilder = new MethodBuilder(self::METHOD_NAME); $methodBuilder->makePublic(); $methodBuilder->setReturnType('void'); @@ -174,9 +169,8 @@ private function createStmts(ClassMethod $renderMethod): array */ private function getParamTagsByName(ClassMethod $classMethod): array { - /** @var PhpDocInfo|null $phpDocInfo */ $phpDocInfo = $this->phpDocInfoFactory->createFromNode($classMethod); - if (null === $phpDocInfo) { + if (! $phpDocInfo instanceof PhpDocInfo) { return []; } @@ -274,6 +268,6 @@ private function resolveParamType(Node $paramType): string return $paramType->toCodeString(); } - return $this->getName($paramType) ?? self::MIXED; + return $this->nodeNameResolver->getName($paramType) ?? self::MIXED; } } diff --git a/src/PostRector/NameImportingPostRector.php b/src/PostRector/NameImportingPostRector.php index d1434cccf..014ab813d 100644 --- a/src/PostRector/NameImportingPostRector.php +++ b/src/PostRector/NameImportingPostRector.php @@ -7,21 +7,22 @@ use Nette\Utils\Strings; use PhpParser\Node; use PhpParser\Node\Name; +use PhpParser\NodeVisitorAbstract; use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory; use Rector\CodingStyle\ClassNameImport\ClassNameImportSkipper; use Rector\CodingStyle\Node\NameImporter; use Rector\Core\Configuration\Option; +use Rector\NodeNameResolver\NodeNameResolver; use Rector\NodeTypeResolver\FileSystem\CurrentFileInfoProvider; use Rector\NodeTypeResolver\PhpDoc\NodeAnalyzer\DocBlockNameImporter; use Rector\PostRector\Contract\Rector\PostRectorInterface; -use Rector\PostRector\Rector\AbstractPostRector; use Ssch\TYPO3Rector\Configuration\Typo3Option; use Symplify\PackageBuilder\Parameter\ParameterProvider; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use Symplify\SmartFileSystem\SmartFileInfo; -final class NameImportingPostRector extends AbstractPostRector +final class NameImportingPostRector extends NodeVisitorAbstract implements PostRectorInterface { /** * @var string @@ -65,13 +66,19 @@ final class NameImportingPostRector extends AbstractPostRector */ private $phpDocInfoFactory; + /** + * @var NodeNameResolver + */ + private $nodeNameResolver; + public function __construct( ParameterProvider $parameterProvider, NameImporter $nameImporter, DocBlockNameImporter $docBlockNameImporter, ClassNameImportSkipper $classNameImportSkipper, CurrentFileInfoProvider $currentFileInfoProvider, - PhpDocInfoFactory $phpDocInfoFactory + PhpDocInfoFactory $phpDocInfoFactory, + NodeNameResolver $nodeNameResolver ) { $this->parameterProvider = $parameterProvider; $this->nameImporter = $nameImporter; @@ -79,6 +86,7 @@ public function __construct( $this->classNameImportSkipper = $classNameImportSkipper; $this->currentFileInfoProvider = $currentFileInfoProvider; $this->phpDocInfoFactory = $phpDocInfoFactory; + $this->nodeNameResolver = $nodeNameResolver; } public function enterNode(Node $node): ?Node @@ -175,7 +183,7 @@ private function shouldSkip(PostRectorInterface $postRector): bool private function processNodeName(Name $name): ?Node { - $importName = $this->getName($name); + $importName = $this->nodeNameResolver->getName($name); if (! is_callable($importName)) { return $this->nameImporter->importName($name); diff --git a/src/Rector/Extensions/solr/ApacheSolrDocumentToSolariumDocumentRector.php b/src/Rector/Extensions/solr/ApacheSolrDocumentToSolariumDocumentRector.php index 498d6b543..ad20bb674 100644 --- a/src/Rector/Extensions/solr/ApacheSolrDocumentToSolariumDocumentRector.php +++ b/src/Rector/Extensions/solr/ApacheSolrDocumentToSolariumDocumentRector.php @@ -30,7 +30,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, Apache_Solr_Document::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, Apache_Solr_Document::class)) { return null; } diff --git a/src/Rector/v10/v0/BackendUtilityGetViewDomainToPageRouterRector.php b/src/Rector/v10/v0/BackendUtilityGetViewDomainToPageRouterRector.php index 417636c43..3ca4473c6 100644 --- a/src/Rector/v10/v0/BackendUtilityGetViewDomainToPageRouterRector.php +++ b/src/Rector/v10/v0/BackendUtilityGetViewDomainToPageRouterRector.php @@ -30,7 +30,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, BackendUtility::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, BackendUtility::class)) { return null; } diff --git a/src/Rector/v10/v0/ChangeDefaultCachingFrameworkNamesRector.php b/src/Rector/v10/v0/ChangeDefaultCachingFrameworkNamesRector.php index 4f34f5fcf..39402c144 100644 --- a/src/Rector/v10/v0/ChangeDefaultCachingFrameworkNamesRector.php +++ b/src/Rector/v10/v0/ChangeDefaultCachingFrameworkNamesRector.php @@ -29,7 +29,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, CacheManager::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, CacheManager::class)) { return null; } diff --git a/src/Rector/v10/v0/ConfigurationManagerAddControllerConfigurationMethodRector.php b/src/Rector/v10/v0/ConfigurationManagerAddControllerConfigurationMethodRector.php index 019fcccb9..06b2af265 100644 --- a/src/Rector/v10/v0/ConfigurationManagerAddControllerConfigurationMethodRector.php +++ b/src/Rector/v10/v0/ConfigurationManagerAddControllerConfigurationMethodRector.php @@ -11,6 +11,8 @@ use PhpParser\Node\Stmt\Nop; use PhpParser\Node\Stmt\Return_; use Rector\Core\Rector\AbstractRector; +use Symplify\Astral\ValueObject\NodeBuilder\MethodBuilder; +use Symplify\Astral\ValueObject\NodeBuilder\ParamBuilder; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use TYPO3\CMS\Extbase\Configuration\AbstractConfigurationManager; @@ -88,13 +90,14 @@ protected function getControllerConfiguration($extensionName, $pluginName): arra private function addMethodGetControllerConfiguration(Class_ $node): void { - $methodBuilder = $this->builderFactory->method('getControllerConfiguration'); + $methodBuilder = new MethodBuilder('getControllerConfiguration'); $methodBuilder->makeProtected(); - $methodBuilder->addParams( - [$this->builderFactory->param('extensionName')->getNode(), $this->builderFactory->param( - 'pluginName' - )->getNode()] - ); + + $methodBuilder->addParams([ + (new ParamBuilder('extensionName'))->getNode(), + (new ParamBuilder('pluginName'))->getNode(), + ]); + $newMethod = $methodBuilder->getNode(); $newMethod->returnType = new Identifier('array'); $newMethod->stmts[] = new Return_($this->nodeFactory->createMethodCall( diff --git a/src/Rector/v10/v0/RefactorIdnaEncodeMethodToNativeFunctionRector.php b/src/Rector/v10/v0/RefactorIdnaEncodeMethodToNativeFunctionRector.php index 5597d13c6..acd79cebf 100644 --- a/src/Rector/v10/v0/RefactorIdnaEncodeMethodToNativeFunctionRector.php +++ b/src/Rector/v10/v0/RefactorIdnaEncodeMethodToNativeFunctionRector.php @@ -34,7 +34,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, GeneralUtility::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, GeneralUtility::class)) { return null; } if (! $this->isName($node->name, 'idnaEncode')) { diff --git a/src/Rector/v10/v0/RemoveFormatConstantsEmailFinisherRector.php b/src/Rector/v10/v0/RemoveFormatConstantsEmailFinisherRector.php index dcdd4e67e..aad97354f 100644 --- a/src/Rector/v10/v0/RemoveFormatConstantsEmailFinisherRector.php +++ b/src/Rector/v10/v0/RemoveFormatConstantsEmailFinisherRector.php @@ -14,6 +14,7 @@ use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Scalar\String_; use Rector\Core\Rector\AbstractRector; +use Rector\NodeTypeResolver\Node\AttributeKey; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use TYPO3\CMS\Form\Domain\Finishers\EmailFinisher; @@ -54,7 +55,7 @@ public function refactor(Node $node): ?Node if (! $this->isNames($node->name, [self::FORMAT_HTML, 'FORMAT_PLAINTEXT'])) { return null; } - $parent = $node->getAttribute('parent'); + $parent = $node->getAttribute(AttributeKey::PARENT_NODE); if ($parent instanceof Arg) { $this->refactorSetOptionMethodCall($parent, $node); } @@ -91,7 +92,7 @@ public function getRuleDefinition(): RuleDefinition private function refactorSetOptionMethodCall(Arg $parent, ClassConstFetch $node): void { - $parent = $parent->getAttribute('parent'); + $parent = $parent->getAttribute(AttributeKey::PARENT_NODE); if (! $parent instanceof MethodCall) { return; } diff --git a/src/Rector/v10/v0/SetSystemLocaleFromSiteLanguageRector.php b/src/Rector/v10/v0/SetSystemLocaleFromSiteLanguageRector.php index b7c2cba4d..9f9663343 100644 --- a/src/Rector/v10/v0/SetSystemLocaleFromSiteLanguageRector.php +++ b/src/Rector/v10/v0/SetSystemLocaleFromSiteLanguageRector.php @@ -38,7 +38,10 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, TypoScriptFrontendController::class) && + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType( + $node, + TypoScriptFrontendController::class + ) && ! $this->typo3NodeResolver->isAnyMethodCallOnGlobals( $node, Typo3NodeResolver::TYPO_SCRIPT_FRONTEND_CONTROLLER diff --git a/src/Rector/v10/v0/UseControllerClassesInExtbasePluginsAndModulesRector.php b/src/Rector/v10/v0/UseControllerClassesInExtbasePluginsAndModulesRector.php index e08dd9557..b3246a1c4 100644 --- a/src/Rector/v10/v0/UseControllerClassesInExtbasePluginsAndModulesRector.php +++ b/src/Rector/v10/v0/UseControllerClassesInExtbasePluginsAndModulesRector.php @@ -32,7 +32,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, ExtensionUtility::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, ExtensionUtility::class)) { return null; } diff --git a/src/Rector/v10/v0/UseMetaDataAspectRector.php b/src/Rector/v10/v0/UseMetaDataAspectRector.php index bb039e474..30ad9822c 100644 --- a/src/Rector/v10/v0/UseMetaDataAspectRector.php +++ b/src/Rector/v10/v0/UseMetaDataAspectRector.php @@ -29,7 +29,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, File::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, File::class)) { return null; } if (! $this->isName($node->name, '_getMetaData')) { diff --git a/src/Rector/v10/v0/UseNativePhpHex2binMethodRector.php b/src/Rector/v10/v0/UseNativePhpHex2binMethodRector.php index 373466ef9..f35817431 100644 --- a/src/Rector/v10/v0/UseNativePhpHex2binMethodRector.php +++ b/src/Rector/v10/v0/UseNativePhpHex2binMethodRector.php @@ -29,7 +29,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, TypeHandlingUtility::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, TypeHandlingUtility::class)) { return null; } if (! $this->isName($node->name, 'hex2bin')) { diff --git a/src/Rector/v10/v0/UseTwoLetterIsoCodeFromSiteLanguageRector.php b/src/Rector/v10/v0/UseTwoLetterIsoCodeFromSiteLanguageRector.php index df0a54c90..3416f3a65 100644 --- a/src/Rector/v10/v0/UseTwoLetterIsoCodeFromSiteLanguageRector.php +++ b/src/Rector/v10/v0/UseTwoLetterIsoCodeFromSiteLanguageRector.php @@ -8,6 +8,7 @@ use PhpParser\Node\Expr\Assign; use PhpParser\Node\Expr\PropertyFetch; use Rector\Core\Rector\AbstractRector; +use Rector\NodeTypeResolver\Node\AttributeKey; use Ssch\TYPO3Rector\Helper\Typo3NodeResolver; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; @@ -52,7 +53,7 @@ public function refactor(Node $node): ?Node return null; } - $parentNode = $node->getAttribute('parent'); + $parentNode = $node->getAttribute(AttributeKey::PARENT_NODE); // Check if we have an assigment to the property, if so do not change it if ($parentNode instanceof Assign && $parentNode->var instanceof PropertyFetch) { diff --git a/src/Rector/v10/v1/BackendUtilityEditOnClickRector.php b/src/Rector/v10/v1/BackendUtilityEditOnClickRector.php index e4dbdff8d..426500f53 100644 --- a/src/Rector/v10/v1/BackendUtilityEditOnClickRector.php +++ b/src/Rector/v10/v1/BackendUtilityEditOnClickRector.php @@ -36,7 +36,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, BackendUtility::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, BackendUtility::class)) { return null; } if (! $this->isName($node->name, 'editOnClick')) { diff --git a/src/Rector/v10/v1/RegisterPluginWithVendorNameRector.php b/src/Rector/v10/v1/RegisterPluginWithVendorNameRector.php index dc00f7355..128af4fb1 100644 --- a/src/Rector/v10/v1/RegisterPluginWithVendorNameRector.php +++ b/src/Rector/v10/v1/RegisterPluginWithVendorNameRector.php @@ -33,7 +33,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, ExtensionUtility::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, ExtensionUtility::class)) { return null; } diff --git a/src/Rector/v10/v1/SendNotifyEmailToMailApiRector.php b/src/Rector/v10/v1/SendNotifyEmailToMailApiRector.php index 85f6cd497..926802ecd 100644 --- a/src/Rector/v10/v1/SendNotifyEmailToMailApiRector.php +++ b/src/Rector/v10/v1/SendNotifyEmailToMailApiRector.php @@ -34,6 +34,7 @@ /** * @see https://docs.typo3.org/c/typo3/cms-core/master/en-us/Changelog/10.1/Deprecation-88850-ContentObjectRendererSendNotifyEmail.html + * @see \Ssch\TYPO3Rector\Tests\Rector\v10\v1\SendNotifyEmailToMailApi\SendNotifyEmailToMailApiRectorTest */ final class SendNotifyEmailToMailApiRector extends AbstractRector { @@ -92,7 +93,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if ($this->isMethodStaticCallOrClassMethodObjectType($node, ContentObjectRenderer::class)) { + if ($this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, ContentObjectRenderer::class)) { return null; } @@ -142,13 +143,16 @@ public function getRuleDefinition(): RuleDefinition use TYPO3\CMS\Core\Mail\MailMessage; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\MailUtility;$success = false; + $mail = GeneralUtility::makeInstance(MailMessage::class); $message = trim("Subject\nMessage"); $senderName = trim(null); $senderAddress = trim('max.mustermann@domain.com'); + if ($senderAddress !== '') { $mail->from(new Address($senderAddress, $senderName)); } + if ($message !== '') { $messageParts = explode(LF, $message, 2); $subject = trim($messageParts[0]); @@ -187,11 +191,11 @@ private function trimMessage(MethodCall $node): Node )); } - private function trimSenderName(MethodCall $node): Node + private function trimSenderName(MethodCall $methodCall): Node { return new Expression(new Assign(new Variable('senderName'), $this->nodeFactory->createFuncCall( self::TRIM, - [$node->args[4]] + [$methodCall->args[4] ?? new Expr\ConstFetch(new Name('null'))] ))); } diff --git a/src/Rector/v10/v2/ExcludeServiceKeysToArrayRector.php b/src/Rector/v10/v2/ExcludeServiceKeysToArrayRector.php index 5e45888ea..a24d2264c 100644 --- a/src/Rector/v10/v2/ExcludeServiceKeysToArrayRector.php +++ b/src/Rector/v10/v2/ExcludeServiceKeysToArrayRector.php @@ -9,6 +9,7 @@ use PhpParser\Node\Expr\StaticCall; use PhpParser\Node\Scalar\String_; use Rector\Core\Rector\AbstractRector; +use Rector\NodeTypeResolver\TypeAnalyzer\ArrayTypeAnalyzer; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; @@ -16,9 +17,20 @@ /** * @see https://docs.typo3.org/c/typo3/cms-core/master/en-us/Changelog/10.2/Deprecation-89579-ServiceChainsRequireAnArrayForExcludedServiceKeys.html + * @see \Ssch\TYPO3Rector\Tests\Rector\v10\v2\ExcludeServiceKeysToArray\ExcludeServiceKeysToArrayRectorTest */ final class ExcludeServiceKeysToArrayRector extends AbstractRector { + /** + * @var ArrayTypeAnalyzer + */ + private $arrayTypeAnalyzer; + + public function __construct(ArrayTypeAnalyzer $arrayTypeAnalyzer) + { + $this->arrayTypeAnalyzer = $arrayTypeAnalyzer; + } + /** * @return string[] */ @@ -43,9 +55,10 @@ public function refactor(Node $node): ?Node return null; } $excludeServiceKeys = $arguments[2]; - if ($this->isArrayType($excludeServiceKeys->value)) { + if ($this->arrayTypeAnalyzer->isArrayType($excludeServiceKeys->value)) { return null; } + $args = [new String_(','), $excludeServiceKeys, $this->nodeFactory->createTrue()]; $staticCall = $this->nodeFactory->createStaticCall(GeneralUtility::class, 'trimExplode', $args); $node->args[2] = new Arg($staticCall); @@ -72,9 +85,12 @@ public function getRuleDefinition(): RuleDefinition private function isExpectedObjectType(StaticCall $node): bool { - if ($this->isMethodStaticCallOrClassMethodObjectType($node, ExtensionManagementUtility::class)) { + if ($this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType( + $node, + ExtensionManagementUtility::class + )) { return true; } - return $this->isMethodStaticCallOrClassMethodObjectType($node, GeneralUtility::class); + return $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, GeneralUtility::class); } } diff --git a/src/Rector/v10/v2/InjectEnvironmentServiceIfNeededInResponseRector.php b/src/Rector/v10/v2/InjectEnvironmentServiceIfNeededInResponseRector.php index 901d519ff..3bf70d7e0 100644 --- a/src/Rector/v10/v2/InjectEnvironmentServiceIfNeededInResponseRector.php +++ b/src/Rector/v10/v2/InjectEnvironmentServiceIfNeededInResponseRector.php @@ -13,8 +13,11 @@ use PhpParser\Node\Stmt\Nop; use PhpParser\Node\Stmt\Property; use PHPStan\Type\ObjectType; -use Rector\Core\PhpParser\Node\Manipulator\ClassInsertManipulator; +use Rector\Core\NodeManipulator\ClassInsertManipulator; use Rector\Core\Rector\AbstractRector; +use Symplify\Astral\ValueObject\NodeBuilder\MethodBuilder; +use Symplify\Astral\ValueObject\NodeBuilder\ParamBuilder; +use Symplify\Astral\ValueObject\NodeBuilder\PropertyBuilder; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use TYPO3\CMS\Extbase\Mvc\Web\Response; @@ -22,6 +25,8 @@ /** * @see https://docs.typo3.org/c/typo3/cms-core/master/en-us/Changelog/10.2/Deprecation-89468-DeprecateInjectionOfEnvironmentServiceInWebRequest.html + * + * @see \Ssch\TYPO3Rector\Tests\Rector\v10\v2\InjectEnvironmentServiceIfNeededInResponse\InjectEnvironmentServiceIfNeededInResponseRectorTest */ final class InjectEnvironmentServiceIfNeededInResponseRector extends AbstractRector { @@ -59,9 +64,11 @@ public function refactor(Node $node): ?Node if (! $this->isPropertyEnvironmentServiceInUse($node)) { return null; } + $this->addInjectEnvironmentServiceMethod($node); $this->classInsertManipulator->addAsFirstMethod($node, $this->createEnvironmentServiceProperty()); $this->classInsertManipulator->addAsFirstMethod($node, new Nop()); + return $node; } @@ -125,7 +132,7 @@ public function myMethod() private function createEnvironmentServiceProperty(): Property { - $propertyBuilder = $this->builderFactory->property(self::ENVIRONMENT_SERVICE); + $propertyBuilder = new PropertyBuilder(self::ENVIRONMENT_SERVICE); $propertyBuilder->makeProtected(); $docString = $this->staticTypeMapper->mapPHPStanTypeToDocString(new ObjectType(EnvironmentService::class)); @@ -152,7 +159,7 @@ private function isPropertyEnvironmentServiceInUse(Class_ $node): bool private function addInjectEnvironmentServiceMethod(Class_ $node): void { - $paramBuilder = $this->builderFactory->param(self::ENVIRONMENT_SERVICE); + $paramBuilder = new ParamBuilder(self::ENVIRONMENT_SERVICE); $paramBuilder->setType(new FullyQualified(EnvironmentService::class)); $param = $paramBuilder->getNode(); @@ -160,7 +167,8 @@ private function addInjectEnvironmentServiceMethod(Class_ $node): void self::ENVIRONMENT_SERVICE, new Variable(self::ENVIRONMENT_SERVICE) ); - $classMethodBuilder = $this->builderFactory->method('injectEnvironmentService'); + + $classMethodBuilder = new MethodBuilder('injectEnvironmentService'); $classMethodBuilder->addParam($param); $classMethodBuilder->addStmt($propertyAssignNode); $classMethodBuilder->makePublic(); diff --git a/src/Rector/v10/v2/MoveApplicationContextToEnvironmentApiRector.php b/src/Rector/v10/v2/MoveApplicationContextToEnvironmentApiRector.php index 34b43cd57..9fb3bbdb2 100644 --- a/src/Rector/v10/v2/MoveApplicationContextToEnvironmentApiRector.php +++ b/src/Rector/v10/v2/MoveApplicationContextToEnvironmentApiRector.php @@ -30,7 +30,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, GeneralUtility::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, GeneralUtility::class)) { return null; } if (! $this->isName($node->name, 'getApplicationContext')) { diff --git a/src/Rector/v10/v2/UseTypo3InformationForCopyRightNoticeRector.php b/src/Rector/v10/v2/UseTypo3InformationForCopyRightNoticeRector.php index 2df4e52b9..de93cbf82 100644 --- a/src/Rector/v10/v2/UseTypo3InformationForCopyRightNoticeRector.php +++ b/src/Rector/v10/v2/UseTypo3InformationForCopyRightNoticeRector.php @@ -31,7 +31,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, BackendUtility::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, BackendUtility::class)) { return null; } if (! $this->isName($node->name, 'TYPO3_copyRightNotice')) { diff --git a/src/Rector/v10/v3/SubstituteResourceFactoryRector.php b/src/Rector/v10/v3/SubstituteResourceFactoryRector.php index bb4f992b4..189c09a49 100644 --- a/src/Rector/v10/v3/SubstituteResourceFactoryRector.php +++ b/src/Rector/v10/v3/SubstituteResourceFactoryRector.php @@ -27,7 +27,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, ResourceFactory::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, ResourceFactory::class)) { return null; } if (! $this->isName($node->name, 'getInstance')) { diff --git a/src/Rector/v10/v4/SubstituteGeneralUtilityMethodsWithNativePhpFunctionsRector.php b/src/Rector/v10/v4/SubstituteGeneralUtilityMethodsWithNativePhpFunctionsRector.php index 5257a4cc7..fb479db7b 100644 --- a/src/Rector/v10/v4/SubstituteGeneralUtilityMethodsWithNativePhpFunctionsRector.php +++ b/src/Rector/v10/v4/SubstituteGeneralUtilityMethodsWithNativePhpFunctionsRector.php @@ -33,7 +33,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, GeneralUtility::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, GeneralUtility::class)) { return null; } diff --git a/src/Rector/v10/v4/UnifiedFileNameValidatorRector.php b/src/Rector/v10/v4/UnifiedFileNameValidatorRector.php index 51dc28470..dea918179 100644 --- a/src/Rector/v10/v4/UnifiedFileNameValidatorRector.php +++ b/src/Rector/v10/v4/UnifiedFileNameValidatorRector.php @@ -92,7 +92,7 @@ public function getRuleDefinition(): RuleDefinition */ public function isMethodVerifyFilenameAgainstDenyPattern(Node $node): bool { - return $node instanceof StaticCall && $this->isMethodStaticCallOrClassMethodObjectType( + return $node instanceof StaticCall && $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType( $node, GeneralUtility::class ) && $this->isName($node->name, 'verifyFilenameAgainstDenyPattern'); diff --git a/src/Rector/v10/v4/UseFileGetContentsForGetUrlRector.php b/src/Rector/v10/v4/UseFileGetContentsForGetUrlRector.php index 3b4c0626b..546ad5581 100644 --- a/src/Rector/v10/v4/UseFileGetContentsForGetUrlRector.php +++ b/src/Rector/v10/v4/UseFileGetContentsForGetUrlRector.php @@ -28,7 +28,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, GeneralUtility::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, GeneralUtility::class)) { return null; } diff --git a/src/Rector/v11/v0/ExtbaseControllerActionsMustReturnResponseInterfaceRector.php b/src/Rector/v11/v0/ExtbaseControllerActionsMustReturnResponseInterfaceRector.php index b141297e7..4a272f9f5 100644 --- a/src/Rector/v11/v0/ExtbaseControllerActionsMustReturnResponseInterfaceRector.php +++ b/src/Rector/v11/v0/ExtbaseControllerActionsMustReturnResponseInterfaceRector.php @@ -12,6 +12,7 @@ use PhpParser\Node\Name\FullyQualified; use PhpParser\Node\Stmt\ClassMethod; use PhpParser\Node\Stmt\Return_; +use PHPStan\Type\TypeWithClassName; use Psr\Http\Message\ResponseInterface; use Rector\Core\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; @@ -20,6 +21,8 @@ /** * @see https://docs.typo3.org/c/typo3/cms-core/master/en-us/Changelog/11.0/Deprecation-92784-ExtbaseControllerActionsMustReturnResponseInterface.html + * + * @see \Ssch\TYPO3Rector\Tests\Rector\v11\v0\ExtbaseControllerActionsMustReturnResponseInterface\ExtbaseControllerActionsMustReturnResponseInterfaceRectorTest */ final class ExtbaseControllerActionsMustReturnResponseInterfaceRector extends AbstractRector { @@ -62,11 +65,14 @@ public function refactor(Node $node): ?Node [$returnCall->expr] ); } else { - $returnCall->expr = $this->nodeFactory->createMethodCall( - self::THIS, - 'htmlResponse', - [$returnCall->expr] - ); + // avoid duplication + if ($returnCall->expr instanceof MethodCall && $this->isName($returnCall->expr->name, 'htmlResponse')) { + $args = []; + } else { + $args = [$returnCall->expr]; + } + + $returnCall->expr = $this->nodeFactory->createMethodCall(self::THIS, 'htmlResponse', $args); } } @@ -120,7 +126,7 @@ public function someAction(): ResponseInterface private function shouldSkip(ClassMethod $node): bool { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, ActionController::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, ActionController::class)) { return true; } @@ -169,7 +175,7 @@ private function hasRedirectCall(ClassMethod $node): bool return false; } - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, ActionController::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, ActionController::class)) { return false; } @@ -191,10 +197,20 @@ private function alreadyResponseReturnType(ClassMethod $node): bool continue; } - if ($this->isReturnOfObjectType($returnCall, ResponseInterface::class)) { + if (null === $returnCall->expr) { + continue; + } + + $returnType = $this->nodeTypeResolver->getStaticType($returnCall->expr); + if (! $returnType instanceof TypeWithClassName) { + continue; + } + + if (is_a($returnType->getClassName(), ResponseInterface::class)) { return true; } } + return false; } } diff --git a/src/Rector/v11/v0/ForwardResponseInsteadOfForwardMethodRector.php b/src/Rector/v11/v0/ForwardResponseInsteadOfForwardMethodRector.php index fdb858027..d75dd33d9 100644 --- a/src/Rector/v11/v0/ForwardResponseInsteadOfForwardMethodRector.php +++ b/src/Rector/v11/v0/ForwardResponseInsteadOfForwardMethodRector.php @@ -6,6 +6,7 @@ use PhpParser\Node; use PhpParser\Node\Expr\MethodCall; +use PhpParser\Node\Expr\New_; use PhpParser\Node\Name\FullyQualified; use PhpParser\Node\Stmt\ClassMethod; use PhpParser\Node\Stmt\Return_; @@ -79,10 +80,8 @@ public function refactor(Node $node): ?Node return null; } - $forwardResponse = $this->builderFactory->new( - ForwardResponse::class, - $this->nodeFactory->createArgs([$action]) - ); + $args = $this->nodeFactory->createArgs([$action]); + $forwardResponse = new New_(new FullyQualified(ForwardResponse::class), $args); if (isset($forwardMethodCall->args[1]) && ! $this->valueResolver->isNull( $forwardMethodCall->args[1]->value @@ -133,7 +132,7 @@ private function extractForwardMethodCalls(ClassMethod $node): array return false; } - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, ActionController::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, ActionController::class)) { return false; } diff --git a/src/Rector/v11/v0/GetClickMenuOnIconTagParametersRector.php b/src/Rector/v11/v0/GetClickMenuOnIconTagParametersRector.php index 365a6c944..6332bb201 100644 --- a/src/Rector/v11/v0/GetClickMenuOnIconTagParametersRector.php +++ b/src/Rector/v11/v0/GetClickMenuOnIconTagParametersRector.php @@ -29,7 +29,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, BackendUtility::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, BackendUtility::class)) { return null; } diff --git a/src/Rector/v11/v0/RemoveAddQueryStringMethodRector.php b/src/Rector/v11/v0/RemoveAddQueryStringMethodRector.php index ae1edac86..dc16d9d88 100644 --- a/src/Rector/v11/v0/RemoveAddQueryStringMethodRector.php +++ b/src/Rector/v11/v0/RemoveAddQueryStringMethodRector.php @@ -77,7 +77,7 @@ private function shouldSkip(MethodCall $node): bool private function isMethodCallOnUriBuilder(MethodCall $node): bool { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, UriBuilder::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, UriBuilder::class)) { return false; } return $this->isName($node->name, 'setAddQueryStringMethod'); @@ -85,7 +85,7 @@ private function isMethodCallOnUriBuilder(MethodCall $node): bool private function isMethodCallOnContentObjectRenderer(MethodCall $node): bool { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, ContentObjectRenderer::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, ContentObjectRenderer::class)) { return false; } return $this->isName($node->name, 'getQueryArguments'); diff --git a/src/Rector/v11/v0/UniqueListFromStringUtilityRector.php b/src/Rector/v11/v0/UniqueListFromStringUtilityRector.php index b280790f2..ee8b52c79 100644 --- a/src/Rector/v11/v0/UniqueListFromStringUtilityRector.php +++ b/src/Rector/v11/v0/UniqueListFromStringUtilityRector.php @@ -30,7 +30,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, GeneralUtility::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, GeneralUtility::class)) { return null; } diff --git a/src/Rector/v7/v0/RemoveMethodCallConnectDbRector.php b/src/Rector/v7/v0/RemoveMethodCallConnectDbRector.php index 89c7c404d..f2fedccfe 100644 --- a/src/Rector/v7/v0/RemoveMethodCallConnectDbRector.php +++ b/src/Rector/v7/v0/RemoveMethodCallConnectDbRector.php @@ -26,7 +26,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, EidUtility::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, EidUtility::class)) { return null; } diff --git a/src/Rector/v7/v0/RemoveMethodCallLoadTcaRector.php b/src/Rector/v7/v0/RemoveMethodCallLoadTcaRector.php index c680e0dac..f427c2b98 100644 --- a/src/Rector/v7/v0/RemoveMethodCallLoadTcaRector.php +++ b/src/Rector/v7/v0/RemoveMethodCallLoadTcaRector.php @@ -26,7 +26,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, GeneralUtility::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, GeneralUtility::class)) { return null; } diff --git a/src/Rector/v7/v0/TypeHandlingServiceToTypeHandlingUtilityRector.php b/src/Rector/v7/v0/TypeHandlingServiceToTypeHandlingUtilityRector.php index cca432e7d..247a1353c 100644 --- a/src/Rector/v7/v0/TypeHandlingServiceToTypeHandlingUtilityRector.php +++ b/src/Rector/v7/v0/TypeHandlingServiceToTypeHandlingUtilityRector.php @@ -27,7 +27,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, TypeHandlingService::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, TypeHandlingService::class)) { return null; } diff --git a/src/Rector/v7/v1/GetTemporaryImageWithTextRector.php b/src/Rector/v7/v1/GetTemporaryImageWithTextRector.php index f4fcca0b9..b599aafcb 100644 --- a/src/Rector/v7/v1/GetTemporaryImageWithTextRector.php +++ b/src/Rector/v7/v1/GetTemporaryImageWithTextRector.php @@ -28,7 +28,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, LocalImageProcessor::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, LocalImageProcessor::class)) { return null; } diff --git a/src/Rector/v7/v4/InstantiatePageRendererExplicitlyRector.php b/src/Rector/v7/v4/InstantiatePageRendererExplicitlyRector.php index bcde8fd68..de3eed70f 100644 --- a/src/Rector/v7/v4/InstantiatePageRendererExplicitlyRector.php +++ b/src/Rector/v7/v4/InstantiatePageRendererExplicitlyRector.php @@ -68,15 +68,18 @@ public function getRuleDefinition(): RuleDefinition private function shouldSkip(MethodCall $node): bool { - if ($this->isMethodStaticCallOrClassMethodObjectType($node, BackendController::class)) { + if ($this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, BackendController::class)) { return false; } - if ($this->isMethodStaticCallOrClassMethodObjectType($node, DocumentTemplate::class)) { + if ($this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, DocumentTemplate::class)) { return false; } - if ($this->isMethodStaticCallOrClassMethodObjectType($node, TypoScriptFrontendController::class)) { + if ($this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType( + $node, + TypoScriptFrontendController::class + )) { return false; } diff --git a/src/Rector/v7/v4/MethodReadLLFileToLocalizationFactoryRector.php b/src/Rector/v7/v4/MethodReadLLFileToLocalizationFactoryRector.php index 3eabc86ac..9164f3b17 100644 --- a/src/Rector/v7/v4/MethodReadLLFileToLocalizationFactoryRector.php +++ b/src/Rector/v7/v4/MethodReadLLFileToLocalizationFactoryRector.php @@ -27,7 +27,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, GeneralUtility::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, GeneralUtility::class)) { return null; } diff --git a/src/Rector/v7/v5/UseExtPrefixForTcaIconFileRector.php b/src/Rector/v7/v5/UseExtPrefixForTcaIconFileRector.php index 1c5e76994..6cac77af9 100644 --- a/src/Rector/v7/v5/UseExtPrefixForTcaIconFileRector.php +++ b/src/Rector/v7/v5/UseExtPrefixForTcaIconFileRector.php @@ -111,7 +111,10 @@ private function refactorIconFile(ArrayItem $fieldValue): void return; } - if (! $this->isMethodStaticCallOrClassMethodObjectType($staticCall, ExtensionManagementUtility::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType( + $staticCall, + ExtensionManagementUtility::class + )) { return; } diff --git a/src/Rector/v7/v6/WrapClickMenuOnIconRector.php b/src/Rector/v7/v6/WrapClickMenuOnIconRector.php index cf57b3fa3..8cec425bd 100644 --- a/src/Rector/v7/v6/WrapClickMenuOnIconRector.php +++ b/src/Rector/v7/v6/WrapClickMenuOnIconRector.php @@ -27,7 +27,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, DocumentTemplate::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, DocumentTemplate::class)) { return null; } diff --git a/src/Rector/v8/v0/ChangeMethodCallsForStandaloneViewRector.php b/src/Rector/v8/v0/ChangeMethodCallsForStandaloneViewRector.php index fa6368fb3..a55da28f5 100644 --- a/src/Rector/v8/v0/ChangeMethodCallsForStandaloneViewRector.php +++ b/src/Rector/v8/v0/ChangeMethodCallsForStandaloneViewRector.php @@ -70,7 +70,7 @@ public function getNodeTypes(): array public function refactor(Node $node): ?Node { foreach (self::OLD_TO_NEW_METHODS_BY_CLASS as $type => $oldToNewMethods) { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, $type)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, $type)) { continue; } foreach ($oldToNewMethods as $oldMethod => $newMethod) { diff --git a/src/Rector/v8/v0/GetFileAbsFileNameRemoveDeprecatedArgumentsRector.php b/src/Rector/v8/v0/GetFileAbsFileNameRemoveDeprecatedArgumentsRector.php index 3212e37b4..b9587eab0 100644 --- a/src/Rector/v8/v0/GetFileAbsFileNameRemoveDeprecatedArgumentsRector.php +++ b/src/Rector/v8/v0/GetFileAbsFileNameRemoveDeprecatedArgumentsRector.php @@ -26,7 +26,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, GeneralUtility::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, GeneralUtility::class)) { return null; } if (! $this->isName($node->name, 'getFileAbsFileName')) { diff --git a/src/Rector/v8/v0/GetPreferredClientLanguageRector.php b/src/Rector/v8/v0/GetPreferredClientLanguageRector.php index 3f596a23f..f88baee82 100644 --- a/src/Rector/v8/v0/GetPreferredClientLanguageRector.php +++ b/src/Rector/v8/v0/GetPreferredClientLanguageRector.php @@ -75,7 +75,7 @@ public function getRuleDefinition(): RuleDefinition private function isCharsetConverterMethodCall(MethodCall $node): bool { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, CharsetConverter::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, CharsetConverter::class)) { return false; } return $this->isName($node->name, self::GET_PREFERRED_CLIENT_LANGUAGE); diff --git a/src/Rector/v8/v0/PrependAbsolutePathToGetFileAbsFileNameRector.php b/src/Rector/v8/v0/PrependAbsolutePathToGetFileAbsFileNameRector.php index 00330f18c..4de2f4b6e 100644 --- a/src/Rector/v8/v0/PrependAbsolutePathToGetFileAbsFileNameRector.php +++ b/src/Rector/v8/v0/PrependAbsolutePathToGetFileAbsFileNameRector.php @@ -27,7 +27,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, GraphicalFunctions::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, GraphicalFunctions::class)) { return null; } diff --git a/src/Rector/v8/v0/RandomMethodsToRandomClassRector.php b/src/Rector/v8/v0/RandomMethodsToRandomClassRector.php index 8f35062e4..f83c43d7b 100644 --- a/src/Rector/v8/v0/RandomMethodsToRandomClassRector.php +++ b/src/Rector/v8/v0/RandomMethodsToRandomClassRector.php @@ -32,7 +32,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, GeneralUtility::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, GeneralUtility::class)) { return null; } diff --git a/src/Rector/v8/v0/RefactorRemovedMarkerMethodsFromHtmlParserRector.php b/src/Rector/v8/v0/RefactorRemovedMarkerMethodsFromHtmlParserRector.php index 775149be7..de14a49a2 100644 --- a/src/Rector/v8/v0/RefactorRemovedMarkerMethodsFromHtmlParserRector.php +++ b/src/Rector/v8/v0/RefactorRemovedMarkerMethodsFromHtmlParserRector.php @@ -57,7 +57,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, HtmlParser::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, HtmlParser::class)) { return null; } diff --git a/src/Rector/v8/v0/RemoveCharsetConverterParametersRector.php b/src/Rector/v8/v0/RemoveCharsetConverterParametersRector.php index b2c1fb30e..7b6c63ad3 100644 --- a/src/Rector/v8/v0/RemoveCharsetConverterParametersRector.php +++ b/src/Rector/v8/v0/RemoveCharsetConverterParametersRector.php @@ -29,7 +29,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, CharsetConverter::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, CharsetConverter::class)) { return null; } diff --git a/src/Rector/v8/v0/RemoveRteHtmlParserEvalWriteFileRector.php b/src/Rector/v8/v0/RemoveRteHtmlParserEvalWriteFileRector.php index 472b702d4..5f7d050e0 100644 --- a/src/Rector/v8/v0/RemoveRteHtmlParserEvalWriteFileRector.php +++ b/src/Rector/v8/v0/RemoveRteHtmlParserEvalWriteFileRector.php @@ -32,7 +32,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, RteHtmlParser::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, RteHtmlParser::class)) { return null; } diff --git a/src/Rector/v8/v0/RemoveWakeupCallFromEntityRector.php b/src/Rector/v8/v0/RemoveWakeupCallFromEntityRector.php index ef933bea8..4309bc05c 100644 --- a/src/Rector/v8/v0/RemoveWakeupCallFromEntityRector.php +++ b/src/Rector/v8/v0/RemoveWakeupCallFromEntityRector.php @@ -27,7 +27,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, AbstractDomainObject::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, AbstractDomainObject::class)) { return null; } diff --git a/src/Rector/v8/v0/RequireMethodsToNativeFunctionsRector.php b/src/Rector/v8/v0/RequireMethodsToNativeFunctionsRector.php index 5dcae20cb..ca048bbdf 100644 --- a/src/Rector/v8/v0/RequireMethodsToNativeFunctionsRector.php +++ b/src/Rector/v8/v0/RequireMethodsToNativeFunctionsRector.php @@ -27,7 +27,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, GeneralUtility::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, GeneralUtility::class)) { return null; } diff --git a/src/Rector/v8/v0/RteHtmlParserRector.php b/src/Rector/v8/v0/RteHtmlParserRector.php index 667b34791..bcf5aac71 100644 --- a/src/Rector/v8/v0/RteHtmlParserRector.php +++ b/src/Rector/v8/v0/RteHtmlParserRector.php @@ -88,6 +88,6 @@ private function removeSecondArgumentFromMethod(MethodCall $node): Node private function shouldSkip(MethodCall $node): bool { - return ! $this->isMethodStaticCallOrClassMethodObjectType($node, RteHtmlParser::class); + return ! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, RteHtmlParser::class); } } diff --git a/src/Rector/v8/v0/TimeTrackerInsteadOfNullTimeTrackerRector.php b/src/Rector/v8/v0/TimeTrackerInsteadOfNullTimeTrackerRector.php index b6ad232d8..336a39a53 100644 --- a/src/Rector/v8/v0/TimeTrackerInsteadOfNullTimeTrackerRector.php +++ b/src/Rector/v8/v0/TimeTrackerInsteadOfNullTimeTrackerRector.php @@ -132,7 +132,7 @@ private function isMakeInstanceCall(Node $node): bool return false; } - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, GeneralUtility::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, GeneralUtility::class)) { return false; } @@ -145,7 +145,7 @@ private function isObjectManagerCall(Node $node): bool return false; } - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, ObjectManager::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, ObjectManager::class)) { return false; } diff --git a/src/Rector/v8/v1/Array2XmlCsToArray2XmlRector.php b/src/Rector/v8/v1/Array2XmlCsToArray2XmlRector.php index 911c54f57..5fc16d7fc 100644 --- a/src/Rector/v8/v1/Array2XmlCsToArray2XmlRector.php +++ b/src/Rector/v8/v1/Array2XmlCsToArray2XmlRector.php @@ -31,7 +31,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, GeneralUtility::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, GeneralUtility::class)) { return null; } diff --git a/src/Rector/v8/v1/GeneralUtilityToUpperAndLowerRector.php b/src/Rector/v8/v1/GeneralUtilityToUpperAndLowerRector.php index cfc9727ab..eda58a911 100644 --- a/src/Rector/v8/v1/GeneralUtilityToUpperAndLowerRector.php +++ b/src/Rector/v8/v1/GeneralUtilityToUpperAndLowerRector.php @@ -26,7 +26,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, GeneralUtility::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, GeneralUtility::class)) { return null; } diff --git a/src/Rector/v8/v1/RefactorVariousGeneralUtilityMethodsRector.php b/src/Rector/v8/v1/RefactorVariousGeneralUtilityMethodsRector.php index 57ce4462d..f0e90de69 100644 --- a/src/Rector/v8/v1/RefactorVariousGeneralUtilityMethodsRector.php +++ b/src/Rector/v8/v1/RefactorVariousGeneralUtilityMethodsRector.php @@ -73,7 +73,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, GeneralUtility::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, GeneralUtility::class)) { return null; } diff --git a/src/Rector/v8/v1/TypoScriptFrontendControllerCharsetConverterRector.php b/src/Rector/v8/v1/TypoScriptFrontendControllerCharsetConverterRector.php index 181883a66..b6ee55ced 100644 --- a/src/Rector/v8/v1/TypoScriptFrontendControllerCharsetConverterRector.php +++ b/src/Rector/v8/v1/TypoScriptFrontendControllerCharsetConverterRector.php @@ -96,7 +96,10 @@ private function shouldSkip(MethodCall $node): bool return false; } - if ($this->isMethodStaticCallOrClassMethodObjectType($node, TypoScriptFrontendController::class)) { + if ($this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType( + $node, + TypoScriptFrontendController::class + )) { return false; } diff --git a/src/Rector/v8/v2/UseHtmlSpecialCharsDirectlyForTranslationRector.php b/src/Rector/v8/v2/UseHtmlSpecialCharsDirectlyForTranslationRector.php index 20c52e67c..01c995313 100644 --- a/src/Rector/v8/v2/UseHtmlSpecialCharsDirectlyForTranslationRector.php +++ b/src/Rector/v8/v2/UseHtmlSpecialCharsDirectlyForTranslationRector.php @@ -96,12 +96,12 @@ private function shouldSkip(MethodCall $node): bool return false; } - return ! $this->isMethodStaticCallOrClassMethodObjectType($node, AbstractPlugin::class); + return ! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, AbstractPlugin::class); } private function isLanguageServiceCall(MethodCall $node): bool { - if ($this->isMethodStaticCallOrClassMethodObjectType($node, LanguageService::class)) { + if ($this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, LanguageService::class)) { return true; } return $this->typo3NodeResolver->isAnyMethodCallOnGlobals($node, Typo3NodeResolver::LANG); diff --git a/src/Rector/v8/v3/RefactorQueryViewTableWrapRector.php b/src/Rector/v8/v3/RefactorQueryViewTableWrapRector.php index 96ef8c99b..61c9ddc9a 100644 --- a/src/Rector/v8/v3/RefactorQueryViewTableWrapRector.php +++ b/src/Rector/v8/v3/RefactorQueryViewTableWrapRector.php @@ -32,7 +32,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, QueryView::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, QueryView::class)) { return null; } if (! $this->isName($node->name, 'tableWrap')) { diff --git a/src/Rector/v8/v5/CharsetConverterToMultiByteFunctionsRector.php b/src/Rector/v8/v5/CharsetConverterToMultiByteFunctionsRector.php index a285810cd..9594a9832 100644 --- a/src/Rector/v8/v5/CharsetConverterToMultiByteFunctionsRector.php +++ b/src/Rector/v8/v5/CharsetConverterToMultiByteFunctionsRector.php @@ -72,7 +72,7 @@ public function getRuleDefinition(): RuleDefinition private function shouldSkip(MethodCall $node): bool { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, CharsetConverter::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, CharsetConverter::class)) { return true; } return ! $this->isNames($node->name, [ diff --git a/src/Rector/v8/v5/ContentObjectRendererFileResourceRector.php b/src/Rector/v8/v5/ContentObjectRendererFileResourceRector.php index 7254256bf..1f0161aa7 100644 --- a/src/Rector/v8/v5/ContentObjectRendererFileResourceRector.php +++ b/src/Rector/v8/v5/ContentObjectRendererFileResourceRector.php @@ -109,7 +109,7 @@ private function shouldSkip(MethodCall $node): bool private function addInitializeVariableNode(MethodCall $node): void { - $parentNode = $node->getAttribute('parent'); + $parentNode = $node->getAttribute(AttributeKey::PARENT_NODE); if (! $parentNode->var instanceof PropertyFetch) { $initializeVariable = new Expression(new Assign($parentNode->var, new String_(''))); $this->addNodeBeforeNode($initializeVariable, $node); diff --git a/src/Rector/v8/v6/ArrayUtilityInArrayToFuncInArrayRector.php b/src/Rector/v8/v6/ArrayUtilityInArrayToFuncInArrayRector.php index 2995c585d..8d0b2c524 100644 --- a/src/Rector/v8/v6/ArrayUtilityInArrayToFuncInArrayRector.php +++ b/src/Rector/v8/v6/ArrayUtilityInArrayToFuncInArrayRector.php @@ -26,7 +26,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, ArrayUtility::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, ArrayUtility::class)) { return null; } if (! $this->isName($node->name, 'inArray')) { diff --git a/src/Rector/v8/v7/BackendUtilityGetRecordRawRector.php b/src/Rector/v8/v7/BackendUtilityGetRecordRawRector.php index b74f981e9..8b16117a2 100644 --- a/src/Rector/v8/v7/BackendUtilityGetRecordRawRector.php +++ b/src/Rector/v8/v7/BackendUtilityGetRecordRawRector.php @@ -43,7 +43,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, BackendUtility::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, BackendUtility::class)) { return null; } if (! $this->isName($node->name, 'getRecordRaw')) { diff --git a/src/Rector/v8/v7/BackendUtilityGetRecordsByFieldToQueryBuilderRector.php b/src/Rector/v8/v7/BackendUtilityGetRecordsByFieldToQueryBuilderRector.php index d8be9446c..5f8f317fe 100644 --- a/src/Rector/v8/v7/BackendUtilityGetRecordsByFieldToQueryBuilderRector.php +++ b/src/Rector/v8/v7/BackendUtilityGetRecordsByFieldToQueryBuilderRector.php @@ -55,7 +55,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, BackendUtility::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, BackendUtility::class)) { return null; } diff --git a/src/Rector/v8/v7/ChangeAttemptsParameterConsoleOutputRector.php b/src/Rector/v8/v7/ChangeAttemptsParameterConsoleOutputRector.php index eb735e73c..c843752de 100644 --- a/src/Rector/v8/v7/ChangeAttemptsParameterConsoleOutputRector.php +++ b/src/Rector/v8/v7/ChangeAttemptsParameterConsoleOutputRector.php @@ -39,7 +39,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, ConsoleOutput::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, ConsoleOutput::class)) { return null; } if (! $this->isName($node->name, self::SELECT) && ! $this->isName($node->name, self::ASK_AND_VALIDATE)) { diff --git a/src/Rector/v8/v7/DataHandlerRmCommaRector.php b/src/Rector/v8/v7/DataHandlerRmCommaRector.php index 6ebe877a7..231a7492a 100644 --- a/src/Rector/v8/v7/DataHandlerRmCommaRector.php +++ b/src/Rector/v8/v7/DataHandlerRmCommaRector.php @@ -30,7 +30,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, DataHandler::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, DataHandler::class)) { return null; } if (! $this->isName($node->name, 'rmComma')) { diff --git a/src/Rector/v8/v7/DataHandlerVariousMethodsAndMethodArgumentsRector.php b/src/Rector/v8/v7/DataHandlerVariousMethodsAndMethodArgumentsRector.php index 182dda11d..e0ad342d6 100644 --- a/src/Rector/v8/v7/DataHandlerVariousMethodsAndMethodArgumentsRector.php +++ b/src/Rector/v8/v7/DataHandlerVariousMethodsAndMethodArgumentsRector.php @@ -34,7 +34,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, DataHandler::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, DataHandler::class)) { return null; } diff --git a/src/Rector/v8/v7/MoveForeignTypesToOverrideChildTcaRector.php b/src/Rector/v8/v7/MoveForeignTypesToOverrideChildTcaRector.php index 60ec390b1..b469f14b8 100644 --- a/src/Rector/v8/v7/MoveForeignTypesToOverrideChildTcaRector.php +++ b/src/Rector/v8/v7/MoveForeignTypesToOverrideChildTcaRector.php @@ -217,7 +217,7 @@ public function refactor(Node $node): ?Node private function extractConfigFromGetFileFieldTcaConfig(Node $columnConfig): Node { if ($columnConfig instanceof StaticCall) { - if (! $this->isMethodStaticCallOrClassMethodObjectType( + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType( $columnConfig, ExtensionManagementUtility::class )) { diff --git a/src/Rector/v8/v7/RefactorArrayBrowserWrapValueRector.php b/src/Rector/v8/v7/RefactorArrayBrowserWrapValueRector.php index 1534f30a7..9f06ab735 100644 --- a/src/Rector/v8/v7/RefactorArrayBrowserWrapValueRector.php +++ b/src/Rector/v8/v7/RefactorArrayBrowserWrapValueRector.php @@ -30,7 +30,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, ArrayBrowser::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, ArrayBrowser::class)) { return null; } if (! $this->isName($node->name, 'wrapValue')) { diff --git a/src/Rector/v8/v7/RefactorGraphicalFunctionsTempPathAndCreateTemSubDirRector.php b/src/Rector/v8/v7/RefactorGraphicalFunctionsTempPathAndCreateTemSubDirRector.php index 0acf4a606..9df031242 100644 --- a/src/Rector/v8/v7/RefactorGraphicalFunctionsTempPathAndCreateTemSubDirRector.php +++ b/src/Rector/v8/v7/RefactorGraphicalFunctionsTempPathAndCreateTemSubDirRector.php @@ -90,7 +90,7 @@ public function getRuleDefinition(): RuleDefinition private function refactorMethodCall(MethodCall $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, GraphicalFunctions::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, GraphicalFunctions::class)) { return null; } @@ -175,7 +175,7 @@ private function refactorPropertyFetch(PropertyFetch $node): ?Node return null; } - $parentNode = $node->getAttribute('parent'); + $parentNode = $node->getAttribute(AttributeKey::PARENT_NODE); // Check if we have an assigment to the property, if so do not change it if ($parentNode instanceof Assign && $parentNode->var instanceof PropertyFetch) { diff --git a/src/Rector/v8/v7/RefactorPrintContentMethodsRector.php b/src/Rector/v8/v7/RefactorPrintContentMethodsRector.php index 686d81828..e65005db3 100644 --- a/src/Rector/v8/v7/RefactorPrintContentMethodsRector.php +++ b/src/Rector/v8/v7/RefactorPrintContentMethodsRector.php @@ -97,11 +97,11 @@ private function shouldSkip(MethodCall $node): bool if ($this->isPageLayoutControllerClass($node)) { return false; } - return ! $this->isMethodStaticCallOrClassMethodObjectType($node, TaskModuleController::class); + return ! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, TaskModuleController::class); } private function isPageLayoutControllerClass(MethodCall $node): bool { - return $this->isMethodStaticCallOrClassMethodObjectType($node, PageLayoutController::class); + return $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, PageLayoutController::class); } } diff --git a/src/Rector/v8/v7/RefactorRemovedMarkerMethodsFromContentObjectRendererRector.php b/src/Rector/v8/v7/RefactorRemovedMarkerMethodsFromContentObjectRendererRector.php index 5eadbf2b6..885f9b71c 100644 --- a/src/Rector/v8/v7/RefactorRemovedMarkerMethodsFromContentObjectRendererRector.php +++ b/src/Rector/v8/v7/RefactorRemovedMarkerMethodsFromContentObjectRendererRector.php @@ -40,7 +40,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, ContentObjectRenderer::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, ContentObjectRenderer::class)) { return null; } if (! $this->isNames( diff --git a/src/Rector/v8/v7/TemplateServiceSplitConfArrayRector.php b/src/Rector/v8/v7/TemplateServiceSplitConfArrayRector.php index 5d09f9e3a..d315fd618 100644 --- a/src/Rector/v8/v7/TemplateServiceSplitConfArrayRector.php +++ b/src/Rector/v8/v7/TemplateServiceSplitConfArrayRector.php @@ -31,7 +31,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, TemplateService::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, TemplateService::class)) { return null; } if (! $this->isName($node->name, 'splitConfArray')) { diff --git a/src/Rector/v8/v7/UseCachingFrameworkInsteadGetAndStoreHashRector.php b/src/Rector/v8/v7/UseCachingFrameworkInsteadGetAndStoreHashRector.php index 0b64490f5..a6278eef1 100644 --- a/src/Rector/v8/v7/UseCachingFrameworkInsteadGetAndStoreHashRector.php +++ b/src/Rector/v8/v7/UseCachingFrameworkInsteadGetAndStoreHashRector.php @@ -107,7 +107,7 @@ private function shouldSkip(Node $node): bool if ($this->typo3NodeResolver->isMethodCallOnSysPageOfTSFE($node)) { return false; } - return ! $this->isMethodStaticCallOrClassMethodObjectType($node, PageRepository::class); + return ! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, PageRepository::class); } private function createCacheManager(): MethodCall diff --git a/src/Rector/v9/v0/CheckForExtensionInfoRector.php b/src/Rector/v9/v0/CheckForExtensionInfoRector.php index 9dab5f74f..980662b86 100644 --- a/src/Rector/v9/v0/CheckForExtensionInfoRector.php +++ b/src/Rector/v9/v0/CheckForExtensionInfoRector.php @@ -79,7 +79,7 @@ public function getRuleDefinition(): RuleDefinition */ private function isExtensionManagementUtilityIsLoaded(Node $node): bool { - return $node instanceof StaticCall && $this->isMethodStaticCallOrClassMethodObjectType( + return $node instanceof StaticCall && $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType( $node, ExtensionManagementUtility::class ) && $this->isName($node->name, 'isLoaded'); @@ -90,9 +90,9 @@ private function isExtensionManagementUtilityIsLoaded(Node $node): bool */ private function isPackageManagerIsActivePackage(Node $node): bool { - return $this->isMethodStaticCallOrClassMethodObjectType($node, PackageManager::class) && $this->isName( - $node->name, - 'isPackageActive' - ); + return $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType( + $node, + PackageManager::class + ) && $this->isName($node->name, 'isPackageActive'); } } diff --git a/src/Rector/v9/v0/CheckForExtensionVersionRector.php b/src/Rector/v9/v0/CheckForExtensionVersionRector.php index 75f79701a..7c10ca003 100644 --- a/src/Rector/v9/v0/CheckForExtensionVersionRector.php +++ b/src/Rector/v9/v0/CheckForExtensionVersionRector.php @@ -74,7 +74,7 @@ public function getRuleDefinition(): RuleDefinition */ private function isExtensionManagementUtilityIsLoaded(Node $node): bool { - return $node instanceof StaticCall && $this->isMethodStaticCallOrClassMethodObjectType( + return $node instanceof StaticCall && $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType( $node, ExtensionManagementUtility::class ) && $this->isName($node->name, 'isLoaded'); @@ -85,9 +85,9 @@ private function isExtensionManagementUtilityIsLoaded(Node $node): bool */ private function isPackageManagerIsActivePackage(Node $node): bool { - return $this->isMethodStaticCallOrClassMethodObjectType($node, PackageManager::class) && $this->isName( - $node->name, - 'isPackageActive' - ); + return $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType( + $node, + PackageManager::class + ) && $this->isName($node->name, 'isPackageActive'); } } diff --git a/src/Rector/v9/v0/FindByPidsAndAuthorIdRector.php b/src/Rector/v9/v0/FindByPidsAndAuthorIdRector.php index db47a7845..c472be208 100644 --- a/src/Rector/v9/v0/FindByPidsAndAuthorIdRector.php +++ b/src/Rector/v9/v0/FindByPidsAndAuthorIdRector.php @@ -30,7 +30,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, SysNoteRepository::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, SysNoteRepository::class)) { return null; } if (! $this->isName($node->name, 'findByPidsAndAuthor')) { diff --git a/src/Rector/v9/v0/GeneratePageTitleRector.php b/src/Rector/v9/v0/GeneratePageTitleRector.php index d722f7708..a52851018 100644 --- a/src/Rector/v9/v0/GeneratePageTitleRector.php +++ b/src/Rector/v9/v0/GeneratePageTitleRector.php @@ -30,7 +30,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, PageGenerator::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, PageGenerator::class)) { return null; } diff --git a/src/Rector/v9/v0/InjectAnnotationRector.php b/src/Rector/v9/v0/InjectAnnotationRector.php index f993775bd..459e41ba9 100644 --- a/src/Rector/v9/v0/InjectAnnotationRector.php +++ b/src/Rector/v9/v0/InjectAnnotationRector.php @@ -20,6 +20,8 @@ use Rector\NodeTypeResolver\PhpDoc\NodeAnalyzer\DocBlockTagReplacer; use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType; use Rector\StaticTypeMapper\ValueObject\Type\ShortenedObjectType; +use Symplify\Astral\ValueObject\NodeBuilder\MethodBuilder; +use Symplify\Astral\ValueObject\NodeBuilder\ParamBuilder; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; @@ -90,7 +92,8 @@ public function refactor(Node $node): ?Node /** @var string $variableName */ $variableName = $this->getName($property); - $paramBuilder = $this->builderFactory->param($variableName); + + $paramBuilder = new ParamBuilder($variableName); $varType = $propertyPhpDocInfo->getVarType(); if (! $varType instanceof ObjectType) { continue; @@ -153,11 +156,13 @@ public function injectSomeService(SomeService $someService) private function createInjectClassMethod(string $variableName, Param $param, Assign $assign): ClassMethod { $injectMethodName = $this->createInjectMethodName($variableName); - $injectMethodBuilder = $this->builderFactory->method($injectMethodName); + + $injectMethodBuilder = new MethodBuilder($injectMethodName); $injectMethodBuilder->makePublic(); $injectMethodBuilder->addParam($param); $injectMethodBuilder->setReturnType('void'); $injectMethodBuilder->addStmt($assign); + return $injectMethodBuilder->getNode(); } diff --git a/src/Rector/v9/v0/MetaTagManagementRector.php b/src/Rector/v9/v0/MetaTagManagementRector.php index c393cba6b..85f25d2ea 100644 --- a/src/Rector/v9/v0/MetaTagManagementRector.php +++ b/src/Rector/v9/v0/MetaTagManagementRector.php @@ -103,7 +103,7 @@ private function shouldSkip(MethodCall $node): bool private function isMethodAddMetaTag(MethodCall $node): bool { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, PageRenderer::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, PageRenderer::class)) { return false; } return $this->isName($node->name, 'addMetaTag'); @@ -111,7 +111,7 @@ private function isMethodAddMetaTag(MethodCall $node): bool private function isMethodXUaCompatible(MethodCall $node): bool { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, DocumentTemplate::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, DocumentTemplate::class)) { return false; } return $this->isName($node->name, 'xUaCompatible'); diff --git a/src/Rector/v9/v0/RefactorBackendUtilityGetPagesTSconfigRector.php b/src/Rector/v9/v0/RefactorBackendUtilityGetPagesTSconfigRector.php index 4e23be867..50d55b8ae 100644 --- a/src/Rector/v9/v0/RefactorBackendUtilityGetPagesTSconfigRector.php +++ b/src/Rector/v9/v0/RefactorBackendUtilityGetPagesTSconfigRector.php @@ -28,7 +28,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, BackendUtility::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, BackendUtility::class)) { return null; } diff --git a/src/Rector/v9/v0/RefactorDeprecationLogRector.php b/src/Rector/v9/v0/RefactorDeprecationLogRector.php index 0af4f38ce..dfcca4b80 100644 --- a/src/Rector/v9/v0/RefactorDeprecationLogRector.php +++ b/src/Rector/v9/v0/RefactorDeprecationLogRector.php @@ -40,20 +40,21 @@ public function refactor(Node $node): ?Node if (GeneralUtility::class !== $className) { return null; } - $const = new ConstFetch(new Name([ - 'name' => 'E_USER_DEPRECATED', - ])); + + $constFetch = new ConstFetch(new Name('E_USER_DEPRECATED')); + $usefulMessage = new String_('A useful message'); $emptyFallbackString = new String_(''); $arguments = $node->args; + switch ($methodName) { case 'logDeprecatedFunction': case 'logDeprecatedViewHelperAttribute': - return $this->nodeFactory->createFuncCall('trigger_error', [$usefulMessage, $const]); + return $this->nodeFactory->createFuncCall('trigger_error', [$usefulMessage, $constFetch]); case 'deprecationLog': return $this->nodeFactory->createFuncCall( 'trigger_error', - [$arguments[0] ?? $emptyFallbackString, $const] + [$arguments[0] ?? $emptyFallbackString, $constFetch] ); case 'getDeprecationLogFileName': $this->removeNode($node); diff --git a/src/Rector/v9/v0/RemoveMethodInitTCARector.php b/src/Rector/v9/v0/RemoveMethodInitTCARector.php index a961cf7a7..d2a6037d8 100644 --- a/src/Rector/v9/v0/RemoveMethodInitTCARector.php +++ b/src/Rector/v9/v0/RemoveMethodInitTCARector.php @@ -26,7 +26,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, EidUtility::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, EidUtility::class)) { return null; } diff --git a/src/Rector/v9/v0/RemoveSecondArgumentGeneralUtilityMkdirDeepRector.php b/src/Rector/v9/v0/RemoveSecondArgumentGeneralUtilityMkdirDeepRector.php index 5fc6109ea..20570a7ac 100644 --- a/src/Rector/v9/v0/RemoveSecondArgumentGeneralUtilityMkdirDeepRector.php +++ b/src/Rector/v9/v0/RemoveSecondArgumentGeneralUtilityMkdirDeepRector.php @@ -30,7 +30,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, GeneralUtility::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, GeneralUtility::class)) { return null; } if (! $this->isName($node->name, 'mkdir_deep')) { diff --git a/src/Rector/v9/v0/ReplaceExtKeyWithExtensionKeyRector.php b/src/Rector/v9/v0/ReplaceExtKeyWithExtensionKeyRector.php index 484220f62..2acdd24ec 100644 --- a/src/Rector/v9/v0/ReplaceExtKeyWithExtensionKeyRector.php +++ b/src/Rector/v9/v0/ReplaceExtKeyWithExtensionKeyRector.php @@ -16,6 +16,7 @@ /** * @see https://docs.typo3.org/c/typo3/cms-core/master/en-us/Changelog/9.0/Important-82692-GuidelinesForExtensionFiles.html + * @see \Ssch\TYPO3Rector\Tests\Rector\v9\v0\ReplaceExtKeyWithExtensionKey\ReplaceExtKeyWithExtensionKeyRectorTest */ final class ReplaceExtKeyWithExtensionKeyRector extends AbstractRector { diff --git a/src/Rector/v9/v0/SubstituteCacheWrapperMethodsRector.php b/src/Rector/v9/v0/SubstituteCacheWrapperMethodsRector.php index 0d5087436..483fb8c31 100644 --- a/src/Rector/v9/v0/SubstituteCacheWrapperMethodsRector.php +++ b/src/Rector/v9/v0/SubstituteCacheWrapperMethodsRector.php @@ -53,7 +53,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, BackendUtility::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, BackendUtility::class)) { return null; } diff --git a/src/Rector/v9/v0/UseLogMethodInsteadOfNewLog2Rector.php b/src/Rector/v9/v0/UseLogMethodInsteadOfNewLog2Rector.php index 021ed67eb..ce06510ff 100644 --- a/src/Rector/v9/v0/UseLogMethodInsteadOfNewLog2Rector.php +++ b/src/Rector/v9/v0/UseLogMethodInsteadOfNewLog2Rector.php @@ -40,7 +40,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, DataHandler::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, DataHandler::class)) { return null; } diff --git a/src/Rector/v9/v0/UseNewComponentIdForPageTreeRector.php b/src/Rector/v9/v0/UseNewComponentIdForPageTreeRector.php index 5fdf52c0c..ebaee6cd5 100644 --- a/src/Rector/v9/v0/UseNewComponentIdForPageTreeRector.php +++ b/src/Rector/v9/v0/UseNewComponentIdForPageTreeRector.php @@ -29,7 +29,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, ExtensionUtility::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, ExtensionUtility::class)) { return null; } diff --git a/src/Rector/v9/v2/GeneralUtilityGetUrlRequestHeadersRector.php b/src/Rector/v9/v2/GeneralUtilityGetUrlRequestHeadersRector.php index cbdbb8078..12261287d 100644 --- a/src/Rector/v9/v2/GeneralUtilityGetUrlRequestHeadersRector.php +++ b/src/Rector/v9/v2/GeneralUtilityGetUrlRequestHeadersRector.php @@ -45,7 +45,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, GeneralUtility::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, GeneralUtility::class)) { return null; } if (! $this->isName($node->name, 'getUrl')) { diff --git a/src/Rector/v9/v3/BackendUserAuthenticationSimplelogRector.php b/src/Rector/v9/v3/BackendUserAuthenticationSimplelogRector.php index 2c43de7d4..20ec68b1f 100644 --- a/src/Rector/v9/v3/BackendUserAuthenticationSimplelogRector.php +++ b/src/Rector/v9/v3/BackendUserAuthenticationSimplelogRector.php @@ -22,7 +22,10 @@ final class BackendUserAuthenticationSimplelogRector extends AbstractRector */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, BackendUserAuthentication::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType( + $node, + BackendUserAuthentication::class + )) { return null; } if (! $this->isName($node->name, 'simplelog')) { diff --git a/src/Rector/v9/v3/BackendUtilityGetModuleUrlRector.php b/src/Rector/v9/v3/BackendUtilityGetModuleUrlRector.php index 90a4fcdbb..7134bd078 100644 --- a/src/Rector/v9/v3/BackendUtilityGetModuleUrlRector.php +++ b/src/Rector/v9/v3/BackendUtilityGetModuleUrlRector.php @@ -25,7 +25,7 @@ final class BackendUtilityGetModuleUrlRector extends AbstractRector */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, BackendUtility::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, BackendUtility::class)) { return null; } if (! $this->isName($node->name, 'getModuleUrl')) { diff --git a/src/Rector/v9/v3/CopyMethodGetPidForModTSconfigRector.php b/src/Rector/v9/v3/CopyMethodGetPidForModTSconfigRector.php index 0d2c28a61..abf8e5bd7 100644 --- a/src/Rector/v9/v3/CopyMethodGetPidForModTSconfigRector.php +++ b/src/Rector/v9/v3/CopyMethodGetPidForModTSconfigRector.php @@ -33,7 +33,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, BackendUtility::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, BackendUtility::class)) { return null; } diff --git a/src/Rector/v9/v3/PhpOptionsUtilityRector.php b/src/Rector/v9/v3/PhpOptionsUtilityRector.php index 8afe08b3e..032855e63 100644 --- a/src/Rector/v9/v3/PhpOptionsUtilityRector.php +++ b/src/Rector/v9/v3/PhpOptionsUtilityRector.php @@ -30,7 +30,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, PhpOptionsUtility::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, PhpOptionsUtility::class)) { return null; } diff --git a/src/Rector/v9/v3/RemoveColPosParameterRector.php b/src/Rector/v9/v3/RemoveColPosParameterRector.php index f04f6d071..3157ec9bf 100644 --- a/src/Rector/v9/v3/RemoveColPosParameterRector.php +++ b/src/Rector/v9/v3/RemoveColPosParameterRector.php @@ -29,7 +29,10 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, LocalizationRepository::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType( + $node, + LocalizationRepository::class + )) { return null; } if (! $this->isNames( diff --git a/src/Rector/v9/v3/UseMethodGetPageShortcutDirectlyFromSysPageRector.php b/src/Rector/v9/v3/UseMethodGetPageShortcutDirectlyFromSysPageRector.php index 3e1fc295f..bb65e50c7 100644 --- a/src/Rector/v9/v3/UseMethodGetPageShortcutDirectlyFromSysPageRector.php +++ b/src/Rector/v9/v3/UseMethodGetPageShortcutDirectlyFromSysPageRector.php @@ -72,7 +72,10 @@ public function getRuleDefinition(): RuleDefinition private function shouldSkip(MethodCall $node): bool { - if ($this->isMethodStaticCallOrClassMethodObjectType($node, TypoScriptFrontendController::class)) { + if ($this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType( + $node, + TypoScriptFrontendController::class + )) { return false; } return ! $this->typo3NodeResolver->isAnyMethodCallOnGlobals( diff --git a/src/Rector/v9/v4/BackendUtilityShortcutExistsRector.php b/src/Rector/v9/v4/BackendUtilityShortcutExistsRector.php index 3dcd77b6a..a16ad450f 100644 --- a/src/Rector/v9/v4/BackendUtilityShortcutExistsRector.php +++ b/src/Rector/v9/v4/BackendUtilityShortcutExistsRector.php @@ -44,7 +44,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, BackendUtility::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, BackendUtility::class)) { return null; } if (! $this->isName($node->name, 'shortcutExists')) { diff --git a/src/Rector/v9/v4/CallEnableFieldsFromPageRepositoryRector.php b/src/Rector/v9/v4/CallEnableFieldsFromPageRepositoryRector.php index b1b707273..9073a0ccc 100644 --- a/src/Rector/v9/v4/CallEnableFieldsFromPageRepositoryRector.php +++ b/src/Rector/v9/v4/CallEnableFieldsFromPageRepositoryRector.php @@ -30,7 +30,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, ContentObjectRenderer::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, ContentObjectRenderer::class)) { return null; } if (! $this->isName($node->name, 'enableFields')) { diff --git a/src/Rector/v9/v4/DocumentTemplateAddStyleSheetRector.php b/src/Rector/v9/v4/DocumentTemplateAddStyleSheetRector.php index c4b739a2c..f977b1145 100644 --- a/src/Rector/v9/v4/DocumentTemplateAddStyleSheetRector.php +++ b/src/Rector/v9/v4/DocumentTemplateAddStyleSheetRector.php @@ -28,7 +28,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, DocumentTemplate::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, DocumentTemplate::class)) { return null; } diff --git a/src/Rector/v9/v4/RefactorDeprecatedConcatenateMethodsPageRendererRector.php b/src/Rector/v9/v4/RefactorDeprecatedConcatenateMethodsPageRendererRector.php index 037175571..52fdbb7a7 100644 --- a/src/Rector/v9/v4/RefactorDeprecatedConcatenateMethodsPageRendererRector.php +++ b/src/Rector/v9/v4/RefactorDeprecatedConcatenateMethodsPageRendererRector.php @@ -29,7 +29,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, PageRenderer::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, PageRenderer::class)) { return null; } if ($this->isName($node->name, 'getConcatenateFiles')) { diff --git a/src/Rector/v9/v4/RefactorExplodeUrl2ArrayFromGeneralUtilityRector.php b/src/Rector/v9/v4/RefactorExplodeUrl2ArrayFromGeneralUtilityRector.php index 656f9c20e..b218f102d 100644 --- a/src/Rector/v9/v4/RefactorExplodeUrl2ArrayFromGeneralUtilityRector.php +++ b/src/Rector/v9/v4/RefactorExplodeUrl2ArrayFromGeneralUtilityRector.php @@ -37,7 +37,7 @@ public function refactor(Node $node): ?Node } /** @var StaticCall|MethodCall $call */ $call = $node->expr; - if (! $this->isMethodStaticCallOrClassMethodObjectType($call, GeneralUtility::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($call, GeneralUtility::class)) { return null; } if (! $this->isName($call->name, 'explodeUrl2Array')) { diff --git a/src/Rector/v9/v4/RemoveInitMethodGraphicalFunctionsRector.php b/src/Rector/v9/v4/RemoveInitMethodGraphicalFunctionsRector.php index 98710a017..d608efde2 100644 --- a/src/Rector/v9/v4/RemoveInitMethodGraphicalFunctionsRector.php +++ b/src/Rector/v9/v4/RemoveInitMethodGraphicalFunctionsRector.php @@ -26,7 +26,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, GraphicalFunctions::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, GraphicalFunctions::class)) { return null; } if (! $this->isName($node->name, 'init')) { diff --git a/src/Rector/v9/v4/RemoveInitMethodTemplateServiceRector.php b/src/Rector/v9/v4/RemoveInitMethodTemplateServiceRector.php index 012eb61ab..801746633 100644 --- a/src/Rector/v9/v4/RemoveInitMethodTemplateServiceRector.php +++ b/src/Rector/v9/v4/RemoveInitMethodTemplateServiceRector.php @@ -26,7 +26,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, TemplateService::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, TemplateService::class)) { return null; } if (! $this->isName($node->name, 'init')) { diff --git a/src/Rector/v9/v4/RemoveInitTemplateMethodCallRector.php b/src/Rector/v9/v4/RemoveInitTemplateMethodCallRector.php index ebc4127fe..882b53f35 100644 --- a/src/Rector/v9/v4/RemoveInitTemplateMethodCallRector.php +++ b/src/Rector/v9/v4/RemoveInitTemplateMethodCallRector.php @@ -54,7 +54,10 @@ public function refactor(Node $node): ?Node if (! $node instanceof MethodCall) { return null; } - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, TypoScriptFrontendController::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType( + $node, + TypoScriptFrontendController::class + )) { return null; } if (! $this->isName($node->name, 'initTemplate')) { diff --git a/src/Rector/v9/v4/UseAddJsFileInsteadOfLoadJavascriptLibRector.php b/src/Rector/v9/v4/UseAddJsFileInsteadOfLoadJavascriptLibRector.php index c6c82dcd4..8d05f770d 100644 --- a/src/Rector/v9/v4/UseAddJsFileInsteadOfLoadJavascriptLibRector.php +++ b/src/Rector/v9/v4/UseAddJsFileInsteadOfLoadJavascriptLibRector.php @@ -28,7 +28,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, ModuleTemplate::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, ModuleTemplate::class)) { return null; } diff --git a/src/Rector/v9/v4/UseClassSchemaInsteadReflectionServiceMethodsRector.php b/src/Rector/v9/v4/UseClassSchemaInsteadReflectionServiceMethodsRector.php index 764bd7a66..c13691f52 100644 --- a/src/Rector/v9/v4/UseClassSchemaInsteadReflectionServiceMethodsRector.php +++ b/src/Rector/v9/v4/UseClassSchemaInsteadReflectionServiceMethodsRector.php @@ -98,7 +98,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, ReflectionService::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, ReflectionService::class)) { return null; } diff --git a/src/Rector/v9/v4/UseContextApiForVersioningWorkspaceIdRector.php b/src/Rector/v9/v4/UseContextApiForVersioningWorkspaceIdRector.php index c734e6259..24091ab6e 100644 --- a/src/Rector/v9/v4/UseContextApiForVersioningWorkspaceIdRector.php +++ b/src/Rector/v9/v4/UseContextApiForVersioningWorkspaceIdRector.php @@ -49,7 +49,7 @@ public function refactor(Node $node): ?Node return null; } - $parentNode = $node->getAttribute('parent'); + $parentNode = $node->getAttribute(AttributeKey::PARENT_NODE); // Check if we have an assigment to the property, if so do not change it if ($parentNode instanceof Assign && $parentNode->var instanceof PropertyFetch) { diff --git a/src/Rector/v9/v4/UseGetMenuInsteadOfGetFirstWebPageRector.php b/src/Rector/v9/v4/UseGetMenuInsteadOfGetFirstWebPageRector.php index 958c805ac..007db5ba3 100644 --- a/src/Rector/v9/v4/UseGetMenuInsteadOfGetFirstWebPageRector.php +++ b/src/Rector/v9/v4/UseGetMenuInsteadOfGetFirstWebPageRector.php @@ -101,7 +101,7 @@ public function getRuleDefinition(): RuleDefinition private function shouldSkip(MethodCall $node): bool { - if ($this->isMethodStaticCallOrClassMethodObjectType($node, PageRepository::class)) { + if ($this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, PageRepository::class)) { return false; } diff --git a/src/Rector/v9/v4/UseLanguageAspectForTsfeLanguagePropertiesRector.php b/src/Rector/v9/v4/UseLanguageAspectForTsfeLanguagePropertiesRector.php index 4ffbadea3..6e50bec30 100644 --- a/src/Rector/v9/v4/UseLanguageAspectForTsfeLanguagePropertiesRector.php +++ b/src/Rector/v9/v4/UseLanguageAspectForTsfeLanguagePropertiesRector.php @@ -8,6 +8,7 @@ use PhpParser\Node\Expr\Assign; use PhpParser\Node\Expr\PropertyFetch; use Rector\Core\Rector\AbstractRector; +use Rector\NodeTypeResolver\Node\AttributeKey; use Ssch\TYPO3Rector\Helper\Typo3NodeResolver; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; @@ -51,7 +52,7 @@ public function refactor(Node $node): ?Node return null; } - $parentNode = $node->getAttribute('parent'); + $parentNode = $node->getAttribute(AttributeKey::PARENT_NODE); // Check if we have an assigment to the property, if so do not change it if ($parentNode instanceof Assign && $parentNode->var instanceof PropertyFetch) { return null; diff --git a/src/Rector/v9/v4/UseRootlineUtilityInsteadOfGetRootlineMethodRector.php b/src/Rector/v9/v4/UseRootlineUtilityInsteadOfGetRootlineMethodRector.php index 2b1fc468f..082279799 100644 --- a/src/Rector/v9/v4/UseRootlineUtilityInsteadOfGetRootlineMethodRector.php +++ b/src/Rector/v9/v4/UseRootlineUtilityInsteadOfGetRootlineMethodRector.php @@ -81,7 +81,7 @@ public function getRuleDefinition(): RuleDefinition private function shouldSkip(MethodCall $node): bool { - if ($this->isMethodStaticCallOrClassMethodObjectType($node, PageRepository::class)) { + if ($this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, PageRepository::class)) { return false; } diff --git a/src/Rector/v9/v4/UseSignalAfterExtensionInstallInsteadOfHasInstalledExtensionsRector.php b/src/Rector/v9/v4/UseSignalAfterExtensionInstallInsteadOfHasInstalledExtensionsRector.php index debc4c38c..a67ebdf1a 100644 --- a/src/Rector/v9/v4/UseSignalAfterExtensionInstallInsteadOfHasInstalledExtensionsRector.php +++ b/src/Rector/v9/v4/UseSignalAfterExtensionInstallInsteadOfHasInstalledExtensionsRector.php @@ -7,6 +7,7 @@ use PhpParser\Node; use PhpParser\Node\Expr\MethodCall; use Rector\Core\Rector\AbstractRector; +use Ssch\TYPO3Rector\NodeAnalyzer\ClassConstAnalyzer; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use TYPO3\CMS\Extbase\SignalSlot\Dispatcher; @@ -18,6 +19,16 @@ */ final class UseSignalAfterExtensionInstallInsteadOfHasInstalledExtensionsRector extends AbstractRector { + /** + * @var ClassConstAnalyzer + */ + private $classConstAnalyzer; + + public function __construct(ClassConstAnalyzer $classConstAnalyzer) + { + $this->classConstAnalyzer = $classConstAnalyzer; + } + public function getNodeTypes(): array { return [MethodCall::class]; @@ -28,7 +39,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, Dispatcher::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, Dispatcher::class)) { return null; } @@ -36,7 +47,10 @@ public function refactor(Node $node): ?Node return null; } - if (! $this->isClassConstReference($node->args[0]->value, ExtensionManagementService::class)) { + if (! $this->classConstAnalyzer->isClassConstReference( + $node->args[0]->value, + ExtensionManagementService::class + )) { return null; } diff --git a/src/Rector/v9/v4/UseSignalTablesDefinitionIsBeingBuiltSqlExpectedSchemaServiceRector.php b/src/Rector/v9/v4/UseSignalTablesDefinitionIsBeingBuiltSqlExpectedSchemaServiceRector.php index 6baf8fcbb..7d4b76aea 100644 --- a/src/Rector/v9/v4/UseSignalTablesDefinitionIsBeingBuiltSqlExpectedSchemaServiceRector.php +++ b/src/Rector/v9/v4/UseSignalTablesDefinitionIsBeingBuiltSqlExpectedSchemaServiceRector.php @@ -18,6 +18,16 @@ */ final class UseSignalTablesDefinitionIsBeingBuiltSqlExpectedSchemaServiceRector extends AbstractRector { + /** + * @var \Ssch\TYPO3Rector\NodeAnalyzer\ClassConstAnalyzer + */ + private $classConstAnalyzer; + + public function __construct(\Ssch\TYPO3Rector\NodeAnalyzer\ClassConstAnalyzer $classConstAnalyzer) + { + $this->classConstAnalyzer = $classConstAnalyzer; + } + public function getNodeTypes(): array { return [MethodCall::class]; @@ -28,7 +38,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, Dispatcher::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, Dispatcher::class)) { return null; } @@ -36,7 +46,7 @@ public function refactor(Node $node): ?Node return null; } - if (! $this->isClassConstReference($node->args[0]->value, InstallUtility::class)) { + if (! $this->classConstAnalyzer->isClassConstReference($node->args[0]->value, InstallUtility::class)) { return null; } diff --git a/src/Rector/v9/v5/RefactorProcessOutputRector.php b/src/Rector/v9/v5/RefactorProcessOutputRector.php index dceafb9fd..6312c8bec 100644 --- a/src/Rector/v9/v5/RefactorProcessOutputRector.php +++ b/src/Rector/v9/v5/RefactorProcessOutputRector.php @@ -48,7 +48,10 @@ public function refactor(Node $node): ?Node return null; } - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, TypoScriptFrontendController::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType( + $node, + TypoScriptFrontendController::class + )) { return null; } diff --git a/src/Rector/v9/v5/RefactorPropertiesOfTypoScriptFrontendControllerRector.php b/src/Rector/v9/v5/RefactorPropertiesOfTypoScriptFrontendControllerRector.php index 79766d9bb..fa3d6194e 100644 --- a/src/Rector/v9/v5/RefactorPropertiesOfTypoScriptFrontendControllerRector.php +++ b/src/Rector/v9/v5/RefactorPropertiesOfTypoScriptFrontendControllerRector.php @@ -8,6 +8,7 @@ use PhpParser\Node\Expr\Assign; use PhpParser\Node\Expr\PropertyFetch; use Rector\Core\Rector\AbstractRector; +use Rector\NodeTypeResolver\Node\AttributeKey; use Ssch\TYPO3Rector\Helper\Typo3NodeResolver; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; @@ -48,7 +49,7 @@ public function refactor(Node $node): ?Node return null; } - $parentNode = $node->getAttribute('parent'); + $parentNode = $node->getAttribute(AttributeKey::PARENT_NODE); // Check if we have an assigment to the property, if so do not change it if ($parentNode instanceof Assign && $parentNode->var instanceof PropertyFetch) { diff --git a/src/Rector/v9/v5/RemoveInitMethodFromPageRepositoryRector.php b/src/Rector/v9/v5/RemoveInitMethodFromPageRepositoryRector.php index 7b0e1e0ed..7feb68104 100644 --- a/src/Rector/v9/v5/RemoveInitMethodFromPageRepositoryRector.php +++ b/src/Rector/v9/v5/RemoveInitMethodFromPageRepositoryRector.php @@ -31,7 +31,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, PageRepository::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, PageRepository::class)) { return null; } if (! $this->isName($node->name, 'init')) { diff --git a/tests/Rector/Extensions/solr/ApacheSolrDocumentToSolariumDocument/ApacheSolrDocumentToSolariumDocumentRectorTest.php b/tests/Rector/Extensions/solr/ApacheSolrDocumentToSolariumDocument/ApacheSolrDocumentToSolariumDocumentRectorTest.php index 4777e4518..1c313a622 100644 --- a/tests/Rector/Extensions/solr/ApacheSolrDocumentToSolariumDocument/ApacheSolrDocumentToSolariumDocumentRectorTest.php +++ b/tests/Rector/Extensions/solr/ApacheSolrDocumentToSolariumDocument/ApacheSolrDocumentToSolariumDocumentRectorTest.php @@ -5,9 +5,7 @@ namespace Ssch\TYPO3Rector\Tests\Rector\Extensions\solr\ApacheSolrDocumentToSolariumDocument; use Iterator; -use Rector\Core\Configuration\Option; use Rector\Testing\PHPUnit\AbstractRectorTestCase; -use Ssch\TYPO3Rector\Set\Typo3SetList; use Symplify\SmartFileSystem\SmartFileInfo; final class ApacheSolrDocumentToSolariumDocumentRectorTest extends AbstractRectorTestCase @@ -17,7 +15,6 @@ final class ApacheSolrDocumentToSolariumDocumentRectorTest extends AbstractRecto */ public function test(SmartFileInfo $fileInfo): void { - $this->setParameter(Option::AUTO_IMPORT_NAMES, true); $this->doTestFileInfo($fileInfo); } @@ -28,6 +25,6 @@ public function provideData(): Iterator protected function provideConfigFileInfo(): ?SmartFileInfo { - return new SmartFileInfo(Typo3SetList::SOLR_SOLR_PHP_CLIENT_TO_SOLARIUM); + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/tests/Rector/Extensions/solr/ApacheSolrDocumentToSolariumDocument/config/configured_rule.php b/tests/Rector/Extensions/solr/ApacheSolrDocumentToSolariumDocument/config/configured_rule.php new file mode 100644 index 000000000..d95e1511d --- /dev/null +++ b/tests/Rector/Extensions/solr/ApacheSolrDocumentToSolariumDocument/config/configured_rule.php @@ -0,0 +1,14 @@ +import(Typo3SetList::SOLR_SOLR_PHP_CLIENT_TO_SOLARIUM); + + $parameters = $containerConfigurator->parameters(); + $parameters->set(Option::AUTO_IMPORT_NAMES, true); +}; diff --git a/tests/Rector/Migrations/RenameClassMapAliasRectorTest.php b/tests/Rector/Migrations/RenameClassMapAliasRectorTest.php index a7979bae4..ef83e624c 100644 --- a/tests/Rector/Migrations/RenameClassMapAliasRectorTest.php +++ b/tests/Rector/Migrations/RenameClassMapAliasRectorTest.php @@ -6,7 +6,6 @@ use Iterator; use Rector\Testing\PHPUnit\AbstractRectorTestCase; -use Ssch\TYPO3Rector\Rector\Migrations\RenameClassMapAliasRector; use Symplify\SmartFileSystem\SmartFileInfo; final class RenameClassMapAliasRectorTest extends AbstractRectorTestCase @@ -24,14 +23,8 @@ public function provideDataForTest(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - RenameClassMapAliasRector::class => [ - RenameClassMapAliasRector::CLASS_ALIAS_MAPS => [ - __DIR__ . '/../../../Migrations/TYPO3/9.5/typo3/sysext/fluid/Migrations/Code/ClassAliasMap.php', - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/tests/Rector/Migrations/config/configured_rule.php b/tests/Rector/Migrations/config/configured_rule.php new file mode 100644 index 000000000..f9990425e --- /dev/null +++ b/tests/Rector/Migrations/config/configured_rule.php @@ -0,0 +1,21 @@ +parameters(); + $parameters->set(Option::AUTO_IMPORT_NAMES, true); + + $services = $containerConfigurator->services(); + + $services->set(RenameClassMapAliasRector::class) + ->call('configure', [[ + RenameClassMapAliasRector::CLASS_ALIAS_MAPS => [ + __DIR__ . '/../../../../Migrations/TYPO3/9.5/typo3/sysext/fluid/Migrations/Code/ClassAliasMap.php', + ], + ]]); +}; diff --git a/tests/Rector/Name/RenameClassRector/AutoImportNamesParameterTest.php b/tests/Rector/Name/RenameClassRector/AutoImportNamesParameterTest.php index f900d45ed..4a19afa96 100644 --- a/tests/Rector/Name/RenameClassRector/AutoImportNamesParameterTest.php +++ b/tests/Rector/Name/RenameClassRector/AutoImportNamesParameterTest.php @@ -5,13 +5,8 @@ namespace Ssch\TYPO3Rector\Tests\Rector\Name\RenameClassRector; use Iterator; -use Rector\Core\Configuration\Option; -use Rector\Renaming\Rector\Name\RenameClassRector; use Rector\Testing\PHPUnit\AbstractRectorTestCase; -use Ssch\TYPO3Rector\Configuration\Typo3Option; use Ssch\TYPO3Rector\PostRector\NameImportingPostRector; -use Ssch\TYPO3Rector\Tests\Rector\Name\RenameClassRector\Source\NewClass; -use Ssch\TYPO3Rector\Tests\Rector\Name\RenameClassRector\Source\OldClass; use Symplify\SmartFileSystem\SmartFileInfo; /** @@ -24,9 +19,6 @@ final class AutoImportNamesParameterTest extends AbstractRectorTestCase */ public function test(SmartFileInfo $fileInfo): void { - $this->setParameter(Option::AUTO_IMPORT_NAMES, false); - $this->setParameter(Typo3Option::AUTO_IMPORT_NAMES, true); - $this->doTestFileInfo($fileInfo); } @@ -35,17 +27,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/FixtureAutoImportNames'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - RenameClassRector::class => [ - RenameClassRector::OLD_TO_NEW_CLASSES => [ - OldClass::class => NewClass::class, - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/autoimport_rename.php'); } } diff --git a/tests/Rector/Name/RenameClassRector/SkipAutoImportNamesParameterTest.php b/tests/Rector/Name/RenameClassRector/SkipAutoImportNamesParameterTest.php index ca5c08c60..e9d0b68a8 100644 --- a/tests/Rector/Name/RenameClassRector/SkipAutoImportNamesParameterTest.php +++ b/tests/Rector/Name/RenameClassRector/SkipAutoImportNamesParameterTest.php @@ -5,13 +5,8 @@ namespace Ssch\TYPO3Rector\Tests\Rector\Name\RenameClassRector; use Iterator; -use Rector\Core\Configuration\Option; -use Rector\Renaming\Rector\Name\RenameClassRector; use Rector\Testing\PHPUnit\AbstractRectorTestCase; -use Ssch\TYPO3Rector\Configuration\Typo3Option; use Ssch\TYPO3Rector\PostRector\NameImportingPostRector; -use Ssch\TYPO3Rector\Tests\Rector\Name\RenameClassRector\Source\FirstOriginalClass; -use Ssch\TYPO3Rector\Tests\Rector\Name\RenameClassRector\Source\SecondOriginalClass; use Symplify\SmartFileSystem\SmartFileInfo; /** @@ -24,12 +19,6 @@ final class SkipAutoImportNamesParameterTest extends AbstractRectorTestCase */ public function test(SmartFileInfo $fileInfo): void { - $this->setParameter(Option::AUTO_IMPORT_NAMES, false); - $this->setParameter(Typo3Option::AUTO_IMPORT_NAMES, true); - $this->setParameter(Option::SKIP, [ - NameImportingPostRector::class => ['*_skip_import_names.php'], - ]); - $this->doTestFileInfo($fileInfo); } @@ -38,17 +27,8 @@ public function provideData(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/SkipAutoImportNames'); } - /** - * @return array - */ - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - RenameClassRector::class => [ - RenameClassRector::OLD_TO_NEW_CLASSES => [ - FirstOriginalClass::class => SecondOriginalClass::class, - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/autoimport_with_skip.php'); } } diff --git a/tests/Rector/Name/RenameClassRector/config/autoimport_rename.php b/tests/Rector/Name/RenameClassRector/config/autoimport_rename.php new file mode 100644 index 000000000..3de70454f --- /dev/null +++ b/tests/Rector/Name/RenameClassRector/config/autoimport_rename.php @@ -0,0 +1,26 @@ +parameters(); + + $parameters->set(Option::AUTO_IMPORT_NAMES, true); + $parameters->set(Typo3Option::AUTO_IMPORT_NAMES, true); + + $services = $containerConfigurator->services(); + + $services->set(RenameClassRector::class) + ->call('configure', [[ + RenameClassRector::OLD_TO_NEW_CLASSES => [ + OldClass::class => NewClass::class, + ], + ]]); +}; diff --git a/tests/Rector/Name/RenameClassRector/config/autoimport_with_skip.php b/tests/Rector/Name/RenameClassRector/config/autoimport_with_skip.php new file mode 100644 index 000000000..8fe5a5fb1 --- /dev/null +++ b/tests/Rector/Name/RenameClassRector/config/autoimport_with_skip.php @@ -0,0 +1,30 @@ +parameters(); + + $parameters->set(Option::AUTO_IMPORT_NAMES, false); + $parameters->set(Typo3Option::AUTO_IMPORT_NAMES, true); + $parameters->set(Option::SKIP, [ + NameImportingPostRector::class => ['*_skip_import_names.php'], + ]); + + $services = $containerConfigurator->services(); + + $services->set(RenameClassRector::class) + ->call('configure', [[ + RenameClassRector::OLD_TO_NEW_CLASSES => [ + FirstOriginalClass::class => SecondOriginalClass::class, + ], + ]]); +}; diff --git a/tests/Rector/Nimut/TestingFramework/NimutTestingFrameworkToTYPO3TestingFrameworkTest.php b/tests/Rector/Nimut/TestingFramework/NimutTestingFrameworkToTYPO3TestingFrameworkTest.php index a678e27ce..1cbb854bd 100644 --- a/tests/Rector/Nimut/TestingFramework/NimutTestingFrameworkToTYPO3TestingFrameworkTest.php +++ b/tests/Rector/Nimut/TestingFramework/NimutTestingFrameworkToTYPO3TestingFrameworkTest.php @@ -5,9 +5,7 @@ namespace Ssch\TYPO3Rector\Tests\Rector\Nimut\TestingFramework; use Iterator; -use Rector\Core\Configuration\Option; use Rector\Testing\PHPUnit\AbstractRectorTestCase; -use Ssch\TYPO3Rector\Set\Typo3SetList; use Symplify\SmartFileSystem\SmartFileInfo; final class NimutTestingFrameworkToTYPO3TestingFrameworkTest extends AbstractRectorTestCase @@ -17,7 +15,6 @@ final class NimutTestingFrameworkToTYPO3TestingFrameworkTest extends AbstractRec */ public function test(SmartFileInfo $fileInfo): void { - $this->setParameter(Option::AUTO_IMPORT_NAMES, true); $this->doTestFileInfo($fileInfo); } @@ -28,6 +25,6 @@ public function provideData(): Iterator protected function provideConfigFileInfo(): ?SmartFileInfo { - return new SmartFileInfo(Typo3SetList::NIMUT_TESTING_FRAMEWORK_TO_TYPO3_TESTING_FRAMEWORK); + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/tests/Rector/Nimut/TestingFramework/config/configured_rule.php b/tests/Rector/Nimut/TestingFramework/config/configured_rule.php new file mode 100644 index 000000000..f9c61f361 --- /dev/null +++ b/tests/Rector/Nimut/TestingFramework/config/configured_rule.php @@ -0,0 +1,14 @@ +import(Typo3SetList::NIMUT_TESTING_FRAMEWORK_TO_TYPO3_TESTING_FRAMEWORK); + + $parameters = $containerConfigurator->parameters(); + $parameters->set(Option::AUTO_IMPORT_NAMES, true); +}; diff --git a/tests/Rector/v10/v1/SendNotifyEmailToMailApi/Fixture/send_notify_email_to_mail_api.php.inc b/tests/Rector/v10/v1/SendNotifyEmailToMailApi/Fixture/send_notify_email_to_mail_api.php.inc index ac9da19e4..5d1ea1879 100644 --- a/tests/Rector/v10/v1/SendNotifyEmailToMailApi/Fixture/send_notify_email_to_mail_api.php.inc +++ b/tests/Rector/v10/v1/SendNotifyEmailToMailApi/Fixture/send_notify_email_to_mail_api.php.inc @@ -1,6 +1,6 @@ yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - SubstituteOldWizardIconsRector::class => [ - SubstituteOldWizardIconsRector::OLD_TO_NEW_FILE_LOCATIONS => [ - 'add.gif' => 'actions-add', - 'link_popup.gif' => 'actions-wizard-link', - 'wizard_rte2.gif' => 'actions-wizard-rte', - 'wizard_link.gif' => 'actions-wizard-rte', - 'wizard_table.gif' => 'content-table', - 'edit2.gif' => 'actions-open', - 'list.gif' => 'actions-system-list-open', - 'wizard_forms.gif' => 'EXT:backend/Resources/Public/Images/FormFieldWizard/wizard_forms.gif', - 'EXT:backend/Resources/Public/Images/FormFieldWizard/wizard_add.gif' => 'actions-add', - 'EXT:backend/Resources/Public/Images/FormFieldWizard/wizard_table.gif' => 'content-table', - 'EXT:backend/Resources/Public/Images/FormFieldWizard/wizard_edit.gif' => 'actions-open', - 'EXT:backend/Resources/Public/Images/FormFieldWizard/wizard_list.gif' => 'actions-system-list-open', - 'EXT:backend/Resources/Public/Images/FormFieldWizard/wizard_link.gif' => 'actions-wizard-link', - 'EXT:backend/Resources/Public/Images/FormFieldWizard/wizard_rte.gif' => 'actions-wizard-rte', - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/tests/Rector/v8/v4/SubstituteOldWizardIcons/config/configured_rule.php b/tests/Rector/v8/v4/SubstituteOldWizardIcons/config/configured_rule.php new file mode 100644 index 000000000..5ea9859af --- /dev/null +++ b/tests/Rector/v8/v4/SubstituteOldWizardIcons/config/configured_rule.php @@ -0,0 +1,29 @@ +services(); + $services->set(SubstituteOldWizardIconsRector::class) + ->call('configure', [[ + SubstituteOldWizardIconsRector::OLD_TO_NEW_FILE_LOCATIONS => [ + 'add.gif' => 'actions-add', + 'link_popup.gif' => 'actions-wizard-link', + 'wizard_rte2.gif' => 'actions-wizard-rte', + 'wizard_link.gif' => 'actions-wizard-rte', + 'wizard_table.gif' => 'content-table', + 'edit2.gif' => 'actions-open', + 'list.gif' => 'actions-system-list-open', + 'wizard_forms.gif' => 'EXT:backend/Resources/Public/Images/FormFieldWizard/wizard_forms.gif', + 'EXT:backend/Resources/Public/Images/FormFieldWizard/wizard_add.gif' => 'actions-add', + 'EXT:backend/Resources/Public/Images/FormFieldWizard/wizard_table.gif' => 'content-table', + 'EXT:backend/Resources/Public/Images/FormFieldWizard/wizard_edit.gif' => 'actions-open', + 'EXT:backend/Resources/Public/Images/FormFieldWizard/wizard_list.gif' => 'actions-system-list-open', + 'EXT:backend/Resources/Public/Images/FormFieldWizard/wizard_link.gif' => 'actions-wizard-link', + 'EXT:backend/Resources/Public/Images/FormFieldWizard/wizard_rte.gif' => 'actions-wizard-rte', + ], + ]]); +}; diff --git a/tests/Rector/v8/v6/MigrateOptionsOfTypeGroup/Fixture/migrate_options_of_type_group.php.inc b/tests/Rector/v8/v6/MigrateOptionsOfTypeGroup/Fixture/migrate_options_of_type_group.php.inc index 4155dd392..7f1e3df76 100644 --- a/tests/Rector/v8/v6/MigrateOptionsOfTypeGroup/Fixture/migrate_options_of_type_group.php.inc +++ b/tests/Rector/v8/v6/MigrateOptionsOfTypeGroup/Fixture/migrate_options_of_type_group.php.inc @@ -2,72 +2,78 @@ namespace Ssch\TYPO3Rector\Tests\Rector\v8\v6\MigrateOptionsOfTypeGroup\Fixture; -return [ - 'ctrl' => [], - 'columns' => [ - 'image2' => [ - 'config' => [ - 'selectedListStyle' => 'foo', - 'type' => 'group', - 'internal_type' => 'file', - 'allowed' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], - 'max_size' => $GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize'], - 'uploadfolder' => 'uploads/pics', - 'show_thumbs' => '0', - 'size' => '3', - 'maxitems' => '200', - 'minitems' => '0', - 'autoSizeMax' => 40, - 'disable_controls' => 'browser' +final class MigrateOptionsOfTypeGroup +{ + public function run() + { + return [ + 'ctrl' => [], + 'columns' => [ + 'image2' => [ + 'config' => [ + 'selectedListStyle' => 'foo', + 'type' => 'group', + 'internal_type' => 'file', + 'allowed' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], + 'max_size' => $GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize'], + 'uploadfolder' => 'uploads/pics', + 'show_thumbs' => '0', + 'size' => '3', + 'maxitems' => '200', + 'minitems' => '0', + 'autoSizeMax' => 40, + 'disable_controls' => 'browser' + ], + ], + 'image3' => [ + 'config' => [ + 'type' => 'group', + 'internal_type' => 'file', + 'allowed' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], + 'max_size' => $GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize'], + 'uploadfolder' => 'uploads/pics', + 'show_thumbs' => '0', + 'size' => '3', + 'maxitems' => '200', + 'minitems' => '0', + 'autoSizeMax' => 40, + 'disable_controls' => 'upload' + ], + ], + 'image5' => [ + 'config' => [ + 'type' => 'group', + 'internal_type' => 'file', + 'allowed' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], + 'max_size' => $GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize'], + 'uploadfolder' => 'uploads/pics', + 'show_thumbs' => '1', + 'size' => '3', + 'maxitems' => '200', + 'minitems' => '0', + 'autoSizeMax' => 40, + 'disable_controls' => 'delete' + ], + ], + 'image6' => [ + 'config' => [ + 'type' => 'group', + 'internal_type' => 'file', + 'allowed' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], + 'max_size' => $GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize'], + 'uploadfolder' => 'uploads/pics', + 'show_thumbs' => '1', + 'size' => '3', + 'maxitems' => '200', + 'minitems' => '0', + 'autoSizeMax' => 40, + 'disable_controls' => 'browser,upload,list,delete' + ], + ], ], - ], - 'image3' => [ - 'config' => [ - 'type' => 'group', - 'internal_type' => 'file', - 'allowed' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], - 'max_size' => $GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize'], - 'uploadfolder' => 'uploads/pics', - 'show_thumbs' => '0', - 'size' => '3', - 'maxitems' => '200', - 'minitems' => '0', - 'autoSizeMax' => 40, - 'disable_controls' => 'upload' - ], - ], - 'image5' => [ - 'config' => [ - 'type' => 'group', - 'internal_type' => 'file', - 'allowed' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], - 'max_size' => $GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize'], - 'uploadfolder' => 'uploads/pics', - 'show_thumbs' => '1', - 'size' => '3', - 'maxitems' => '200', - 'minitems' => '0', - 'autoSizeMax' => 40, - 'disable_controls' => 'delete' - ], - ], - 'image6' => [ - 'config' => [ - 'type' => 'group', - 'internal_type' => 'file', - 'allowed' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], - 'max_size' => $GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize'], - 'uploadfolder' => 'uploads/pics', - 'show_thumbs' => '1', - 'size' => '3', - 'maxitems' => '200', - 'minitems' => '0', - 'autoSizeMax' => 40, - 'disable_controls' => 'browser,upload,list,delete' - ], - ], - ], -]; + ]; + } +} ?> ----- @@ -75,69 +81,75 @@ return [ namespace Ssch\TYPO3Rector\Tests\Rector\v8\v6\MigrateOptionsOfTypeGroup\Fixture; -return [ - 'ctrl' => [], - 'columns' => [ - 'image2' => [ - 'config' => [ - 'type' => 'group', - 'internal_type' => 'file', - 'allowed' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], - 'max_size' => $GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize'], - 'uploadfolder' => 'uploads/pics', - 'size' => '3', - 'maxitems' => '200', - 'minitems' => '0', - 'autoSizeMax' => 40, - 'fieldControl' => ['elementBrowser' => ['disabled' => true]], - 'fieldWizard' => ['fileThumbnails' => ['disabled' => true]] - ], - ], - 'image3' => [ - 'config' => [ - 'type' => 'group', - 'internal_type' => 'file', - 'allowed' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], - 'max_size' => $GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize'], - 'uploadfolder' => 'uploads/pics', - 'size' => '3', - 'maxitems' => '200', - 'minitems' => '0', - 'autoSizeMax' => 40, - 'fieldWizard' => ['fileThumbnails' => ['disabled' => true], 'fileUpload' => ['disabled' => true]] - ], - ], - 'image5' => [ - 'config' => [ - 'type' => 'group', - 'internal_type' => 'file', - 'allowed' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], - 'max_size' => $GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize'], - 'uploadfolder' => 'uploads/pics', - 'size' => '3', - 'maxitems' => '200', - 'minitems' => '0', - 'autoSizeMax' => 40, - 'hideDeleteIcon' => true - ], - ], - 'image6' => [ - 'config' => [ - 'type' => 'group', - 'internal_type' => 'file', - 'allowed' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], - 'max_size' => $GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize'], - 'uploadfolder' => 'uploads/pics', - 'size' => '3', - 'maxitems' => '200', - 'minitems' => '0', - 'autoSizeMax' => 40, - 'hideDeleteIcon' => true, - 'fieldControl' => ['elementBrowser' => ['disabled' => true]], - 'fieldWizard' => ['fileUpload' => ['disabled' => true]] +final class MigrateOptionsOfTypeGroup +{ + public function run() + { + return [ + 'ctrl' => [], + 'columns' => [ + 'image2' => [ + 'config' => [ + 'type' => 'group', + 'internal_type' => 'file', + 'allowed' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], + 'max_size' => $GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize'], + 'uploadfolder' => 'uploads/pics', + 'size' => '3', + 'maxitems' => '200', + 'minitems' => '0', + 'autoSizeMax' => 40, + 'fieldControl' => ['elementBrowser' => ['disabled' => true]], + 'fieldWizard' => ['fileThumbnails' => ['disabled' => true]] + ], + ], + 'image3' => [ + 'config' => [ + 'type' => 'group', + 'internal_type' => 'file', + 'allowed' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], + 'max_size' => $GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize'], + 'uploadfolder' => 'uploads/pics', + 'size' => '3', + 'maxitems' => '200', + 'minitems' => '0', + 'autoSizeMax' => 40, + 'fieldWizard' => ['fileThumbnails' => ['disabled' => true], 'fileUpload' => ['disabled' => true]] + ], + ], + 'image5' => [ + 'config' => [ + 'type' => 'group', + 'internal_type' => 'file', + 'allowed' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], + 'max_size' => $GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize'], + 'uploadfolder' => 'uploads/pics', + 'size' => '3', + 'maxitems' => '200', + 'minitems' => '0', + 'autoSizeMax' => 40, + 'hideDeleteIcon' => true + ], + ], + 'image6' => [ + 'config' => [ + 'type' => 'group', + 'internal_type' => 'file', + 'allowed' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], + 'max_size' => $GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize'], + 'uploadfolder' => 'uploads/pics', + 'size' => '3', + 'maxitems' => '200', + 'minitems' => '0', + 'autoSizeMax' => 40, + 'hideDeleteIcon' => true, + 'fieldControl' => ['elementBrowser' => ['disabled' => true]], + 'fieldWizard' => ['fileUpload' => ['disabled' => true]] + ], + ], ], - ], - ], -]; + ]; + } +} ?> diff --git a/tests/Rector/v8/v7/ChangeAttemptsParameterConsoleOutput/ChangeAttemptsParameterConsoleOutputRectorTest.php b/tests/Rector/v8/v7/ChangeAttemptsParameterConsoleOutput/ChangeAttemptsParameterConsoleOutputRectorTest.php index 2709a6a72..13efa7240 100644 --- a/tests/Rector/v8/v7/ChangeAttemptsParameterConsoleOutput/ChangeAttemptsParameterConsoleOutputRectorTest.php +++ b/tests/Rector/v8/v7/ChangeAttemptsParameterConsoleOutput/ChangeAttemptsParameterConsoleOutputRectorTest.php @@ -24,10 +24,8 @@ public function provideDataForTest(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - protected function getRectorsWithConfiguration(): array + protected function getRectorClass(): string { - return [ - ChangeAttemptsParameterConsoleOutputRector::class => [], - ]; + return ChangeAttemptsParameterConsoleOutputRector::class; } } diff --git a/tests/Rector/v9/v0/ReplaceAnnotation/ReplaceAnnotationRectorTest.php b/tests/Rector/v9/v0/ReplaceAnnotation/ReplaceAnnotationRectorTest.php index 170ad8983..a01498b6e 100644 --- a/tests/Rector/v9/v0/ReplaceAnnotation/ReplaceAnnotationRectorTest.php +++ b/tests/Rector/v9/v0/ReplaceAnnotation/ReplaceAnnotationRectorTest.php @@ -6,7 +6,6 @@ use Iterator; use Rector\Testing\PHPUnit\AbstractRectorTestCase; -use Ssch\TYPO3Rector\Rector\v9\v0\ReplaceAnnotationRector; use Symplify\SmartFileSystem\SmartFileInfo; final class ReplaceAnnotationRectorTest extends AbstractRectorTestCase @@ -24,16 +23,8 @@ public function provideDataForTest(): Iterator return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); } - protected function getRectorsWithConfiguration(): array + protected function provideConfigFileInfo(): ?SmartFileInfo { - return [ - ReplaceAnnotationRector::class => [ - ReplaceAnnotationRector::OLD_TO_NEW_ANNOTATIONS => [ - 'lazy' => 'TYPO3\CMS\Extbase\Annotation\ORM\Lazy', - 'cascade' => 'TYPO3\CMS\Extbase\Annotation\ORM\Cascade("remove")', - 'transient' => 'TYPO3\CMS\Extbase\Annotation\ORM\Transient', - ], - ], - ]; + return new SmartFileInfo(__DIR__ . '/config/configured_rule.php'); } } diff --git a/tests/Rector/v9/v0/ReplaceAnnotation/config/configured_rule.php b/tests/Rector/v9/v0/ReplaceAnnotation/config/configured_rule.php new file mode 100644 index 000000000..e3464ac23 --- /dev/null +++ b/tests/Rector/v9/v0/ReplaceAnnotation/config/configured_rule.php @@ -0,0 +1,19 @@ +services(); + + $services->set(ReplaceAnnotationRector::class) + ->call('configure', [[ + ReplaceAnnotationRector::OLD_TO_NEW_ANNOTATIONS => [ + 'lazy' => 'TYPO3\CMS\Extbase\Annotation\ORM\Lazy', + 'cascade' => 'TYPO3\CMS\Extbase\Annotation\ORM\Cascade("remove")', + 'transient' => 'TYPO3\CMS\Extbase\Annotation\ORM\Transient', + ], + ]]); +}; diff --git a/tests/Rector/v9/v0/ReplaceExtKeyWithExtensionKey/Fixture/ext_localconf.php.inc b/tests/Rector/v9/v0/ReplaceExtKeyWithExtensionKey/Fixture/ext_localconf.php.inc index 2109b7582..7e1592639 100644 --- a/tests/Rector/v9/v0/ReplaceExtKeyWithExtensionKey/Fixture/ext_localconf.php.inc +++ b/tests/Rector/v9/v0/ReplaceExtKeyWithExtensionKey/Fixture/ext_localconf.php.inc @@ -2,6 +2,9 @@ use TYPO3\CMS\Extbase\Utility\ExtensionUtility; +// must be defined +$_EXTKEY = '___'; + if ( ! defined('TYPO3_MODE')) { die('Access denied.'); } @@ -40,6 +43,9 @@ $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php'][ use TYPO3\CMS\Extbase\Utility\ExtensionUtility; +// must be defined +'_temp_fixture_easy_testing' = '___'; + if ( ! defined('TYPO3_MODE')) { die('Access denied.'); } diff --git a/tests/Rector/v9/v0/ReplaceExtKeyWithExtensionKey/Fixture/ext_tables.php.inc b/tests/Rector/v9/v0/ReplaceExtKeyWithExtensionKey/Fixture/ext_tables.php.inc index 08e51b4d4..c02148750 100644 --- a/tests/Rector/v9/v0/ReplaceExtKeyWithExtensionKey/Fixture/ext_tables.php.inc +++ b/tests/Rector/v9/v0/ReplaceExtKeyWithExtensionKey/Fixture/ext_tables.php.inc @@ -3,6 +3,8 @@ use TYPO3\CMS\Extbase\Utility\ExtensionUtility; if (TYPO3_MODE === 'BE') { + // must be defined + $_EXTKEY = '___'; /** * Registers a Backend Module @@ -48,6 +50,8 @@ if (TYPO3_MODE === 'BE') { use TYPO3\CMS\Extbase\Utility\ExtensionUtility; if (TYPO3_MODE === 'BE') { + // must be defined + '_temp_fixture_easy_testing' = '___'; /** * Registers a Backend Module diff --git a/utils/rules/src/Rector/Misc/AddCodeCoverageIgnoreToMethodRectorDefinitionRector.php b/utils/rules/src/Rector/Misc/AddCodeCoverageIgnoreToMethodRectorDefinitionRector.php index fefbe3f27..1ebf0f241 100644 --- a/utils/rules/src/Rector/Misc/AddCodeCoverageIgnoreToMethodRectorDefinitionRector.php +++ b/utils/rules/src/Rector/Misc/AddCodeCoverageIgnoreToMethodRectorDefinitionRector.php @@ -24,7 +24,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->isMethodStaticCallOrClassMethodObjectType($node, AbstractRector::class)) { + if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, AbstractRector::class)) { return null; }