diff --git a/composer.json b/composer.json index ce70f3c..221232f 100644 --- a/composer.json +++ b/composer.json @@ -15,8 +15,7 @@ "tests": "phpunit tests" }, "require": { - "rector/rector": "0.15.24", - "phpstan/phpstan": "1.10.13", + "rector/rector": "^1.0", "symfony/yaml": "*", "neos/utility-arrays": "*", "webmozart/assert": "^1.11" diff --git a/src/ContentRepository90/Rules/ContentDimensionCombinatorGetAllAllowedCombinationsRector.php b/src/ContentRepository90/Rules/ContentDimensionCombinatorGetAllAllowedCombinationsRector.php index 2672fd6..ed8905a 100644 --- a/src/ContentRepository90/Rules/ContentDimensionCombinatorGetAllAllowedCombinationsRector.php +++ b/src/ContentRepository90/Rules/ContentDimensionCombinatorGetAllAllowedCombinationsRector.php @@ -9,8 +9,8 @@ use PhpParser\Node; use PhpParser\Node\Expr; use PHPStan\Type\ObjectType; -use Rector\Core\Rector\AbstractRector; -use Rector\PostRector\Collector\NodesToAddCollector; +use Rector\Rector\AbstractRector; + use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; final class ContentDimensionCombinatorGetAllAllowedCombinationsRector extends AbstractRector @@ -18,7 +18,7 @@ final class ContentDimensionCombinatorGetAllAllowedCombinationsRector extends Ab use AllTraits; public function __construct( - private readonly NodesToAddCollector $nodesToAddCollector + ) { } @@ -49,14 +49,14 @@ public function refactor(Node $node) : ?Node return null; } - $this->nodesToAddCollector->addNodesBeforeNode( - [ - self::assign('contentRepository', $this->this_contentRepositoryRegistry_get($this->contentRepositoryId_fromString('default'))), - self::assign('dimensionSpacePoints', $this->contentRepository_getVariationGraph_getDimensionSpacePoints()), - self::todoComment('try to directly work with $dimensionSpacePoints, instead of converting them to the legacy dimension format') - ], - $node - ); +// $this->nodesToAddCollector->addNodesBeforeNode( +// [ +// self::assign('contentRepository', $this->this_contentRepositoryRegistry_get($this->contentRepositoryId_fromString('default'))), +// self::assign('dimensionSpacePoints', $this->contentRepository_getVariationGraph_getDimensionSpacePoints()), +// self::todoComment('try to directly work with $dimensionSpacePoints, instead of converting them to the legacy dimension format') +// ], +// $node +// ); return $this->dimensionSpacePoints_toLegacyDimensionArray(); } diff --git a/src/ContentRepository90/Rules/ContextFactoryToLegacyContextStubRector.php b/src/ContentRepository90/Rules/ContextFactoryToLegacyContextStubRector.php index 8a3b067..49602d5 100644 --- a/src/ContentRepository90/Rules/ContextFactoryToLegacyContextStubRector.php +++ b/src/ContentRepository90/Rules/ContextFactoryToLegacyContextStubRector.php @@ -7,8 +7,7 @@ use Neos\Rector\Utility\CodeSampleLoader; use PhpParser\Node; use PHPStan\Type\ObjectType; -use Rector\Core\Rector\AbstractRector; -use Rector\PostRector\Collector\NodesToAddCollector; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; final class ContextFactoryToLegacyContextStubRector extends AbstractRector @@ -16,7 +15,6 @@ final class ContextFactoryToLegacyContextStubRector extends AbstractRector use AllTraits; public function __construct( - private readonly NodesToAddCollector $nodesToAddCollector ) { } diff --git a/src/ContentRepository90/Rules/ContextGetCurrentRenderingModeRector.php b/src/ContentRepository90/Rules/ContextGetCurrentRenderingModeRector.php index 797764a..066572e 100644 --- a/src/ContentRepository90/Rules/ContextGetCurrentRenderingModeRector.php +++ b/src/ContentRepository90/Rules/ContextGetCurrentRenderingModeRector.php @@ -7,9 +7,8 @@ use Neos\Rector\Utility\CodeSampleLoader; use PhpParser\Node; use PHPStan\Type\ObjectType; -use Rector\Core\Rector\AbstractRector; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; -use Rector\PostRector\Collector\NodesToAddCollector; use PhpParser\Node\Expr\Assign; final class ContextGetCurrentRenderingModeRector extends AbstractRector @@ -18,7 +17,6 @@ final class ContextGetCurrentRenderingModeRector extends AbstractRector use ContextRectorTrait; public function __construct( - private readonly NodesToAddCollector $nodesToAddCollector ) { } diff --git a/src/ContentRepository90/Rules/ContextGetFirstLevelNodeCacheRector.php b/src/ContentRepository90/Rules/ContextGetFirstLevelNodeCacheRector.php index 6849139..a474aaa 100644 --- a/src/ContentRepository90/Rules/ContextGetFirstLevelNodeCacheRector.php +++ b/src/ContentRepository90/Rules/ContextGetFirstLevelNodeCacheRector.php @@ -4,14 +4,12 @@ namespace Neos\Rector\ContentRepository90\Rules; -use Neos\Rector\ContentRepository90\Legacy\LegacyContextStub; use Neos\Rector\Utility\CodeSampleLoader; use PhpParser\Node; use PhpParser\NodeFinder; use PhpParser\NodeTraverser; use PHPStan\Type\ObjectType; -use Rector\Core\Rector\AbstractRector; -use Rector\PostRector\Collector\NodesToAddCollector; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; final class ContextGetFirstLevelNodeCacheRector extends AbstractRector @@ -19,7 +17,6 @@ final class ContextGetFirstLevelNodeCacheRector extends AbstractRector use AllTraits; public function __construct( - private readonly NodesToAddCollector $nodesToAddCollector ) { } @@ -38,14 +35,14 @@ public function getNodeTypes(): array } /** - * @param \PhpParser\Node\Expr\MethodCall $node + * @param \PhpParser\Node\Stmt\Expression $node */ - public function refactor(Node $node): ?Node + public function refactor(Node $node) { assert($node instanceof Node\Stmt\Expression); if ($this->containsContextGetFirstLevelNodeCache($node->expr)) { - $this->removeNode($node); + return NodeTraverser::REMOVE_NODE; } return $node; } diff --git a/src/ContentRepository90/Rules/ContextGetRootNodeRector.php b/src/ContentRepository90/Rules/ContextGetRootNodeRector.php index a2bbebf..ea465fd 100644 --- a/src/ContentRepository90/Rules/ContextGetRootNodeRector.php +++ b/src/ContentRepository90/Rules/ContextGetRootNodeRector.php @@ -9,8 +9,8 @@ use PhpParser\Node; use PhpParser\Node\Expr; use PHPStan\Type\ObjectType; -use Rector\Core\Rector\AbstractRector; -use Rector\PostRector\Collector\NodesToAddCollector; +use Rector\Rector\AbstractRector; + use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; final class ContextGetRootNodeRector extends AbstractRector @@ -18,7 +18,7 @@ final class ContextGetRootNodeRector extends AbstractRector use AllTraits; public function __construct( - private readonly NodesToAddCollector $nodesToAddCollector + ) { } @@ -49,19 +49,19 @@ public function refactor(Node $node) : ?Node return null; } - $this->nodesToAddCollector->addNodesBeforeNode( - [ - self::withTodoComment( - '!! MEGA DIRTY CODE! Ensure to rewrite this; by getting rid of LegacyContextStub.', - self::assign('contentRepository', $this->this_contentRepositoryRegistry_get($this->contentRepositoryId_fromString('default'))) - ), - self::assign('workspace', $this->contentRepository_getWorkspaceFinder_findOneByName($this->workspaceName_fromString($this->context_workspaceName_fallbackToLive($node->var)))), - self::assign('rootNodeAggregate', $this->contentRepository_getContentGraph_findRootNodeAggregateByType($this->workspace_currentContentStreamId(), $this->nodeTypeName_fromString('Neos.Neos:Sites'))), - self::assign('subgraph', $this->contentRepository_getContentGraph_getSubgraph($this->workspace_currentContentStreamId(), $this->dimensionSpacePoint_fromLegacyDimensionArray($this->context_dimensions_fallbackToEmpty($node->var)), $this->visibilityConstraints($node->var))), - - ], - $node - ); +// $this->nodesToAddCollector->addNodesBeforeNode( +// [ +// self::withTodoComment( +// '!! MEGA DIRTY CODE! Ensure to rewrite this; by getting rid of LegacyContextStub.', +// self::assign('contentRepository', $this->this_contentRepositoryRegistry_get($this->contentRepositoryId_fromString('default'))) +// ), +// self::assign('workspace', $this->contentRepository_getWorkspaceFinder_findOneByName($this->workspaceName_fromString($this->context_workspaceName_fallbackToLive($node->var)))), +// self::assign('rootNodeAggregate', $this->contentRepository_getContentGraph_findRootNodeAggregateByType($this->workspace_currentContentStreamId(), $this->nodeTypeName_fromString('Neos.Neos:Sites'))), +// self::assign('subgraph', $this->contentRepository_getContentGraph_getSubgraph($this->workspace_currentContentStreamId(), $this->dimensionSpacePoint_fromLegacyDimensionArray($this->context_dimensions_fallbackToEmpty($node->var)), $this->visibilityConstraints($node->var))), +// +// ], +// $node +// ); return $this->subgraph_findNodeById( $this->nodeFactory->createPropertyFetch('rootNodeAggregate', 'nodeAggregateId') diff --git a/src/ContentRepository90/Rules/ContextIsInBackendRector.php b/src/ContentRepository90/Rules/ContextIsInBackendRector.php index d22bfab..a35a6bb 100644 --- a/src/ContentRepository90/Rules/ContextIsInBackendRector.php +++ b/src/ContentRepository90/Rules/ContextIsInBackendRector.php @@ -7,9 +7,8 @@ use Neos\Rector\Utility\CodeSampleLoader; use PhpParser\Node; use PHPStan\Type\ObjectType; -use Rector\Core\Rector\AbstractRector; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; -use Rector\PostRector\Collector\NodesToAddCollector; use PhpParser\Node\Expr\Assign; use PhpParser\NodeDumper; @@ -19,7 +18,6 @@ final class ContextIsInBackendRector extends AbstractRector use ContextRectorTrait; public function __construct( - private readonly NodesToAddCollector $nodesToAddCollector ) { } @@ -38,7 +36,7 @@ public function getNodeTypes(): array } /** - * @param \PhpParser\Node\Stmt\Expression $node + * @param \PhpParser\Node\Expr\MethodCall $node */ public function refactor(Node $node): ?Node { diff --git a/src/ContentRepository90/Rules/ContextIsLiveRector.php b/src/ContentRepository90/Rules/ContextIsLiveRector.php index c587160..5737ad1 100644 --- a/src/ContentRepository90/Rules/ContextIsLiveRector.php +++ b/src/ContentRepository90/Rules/ContextIsLiveRector.php @@ -7,9 +7,8 @@ use Neos\Rector\Utility\CodeSampleLoader; use PhpParser\Node; use PHPStan\Type\ObjectType; -use Rector\Core\Rector\AbstractRector; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; -use Rector\PostRector\Collector\NodesToAddCollector; use PhpParser\Node\Expr\Assign; use PhpParser\NodeDumper; @@ -19,7 +18,6 @@ final class ContextIsLiveRector extends AbstractRector use ContextRectorTrait; public function __construct( - private readonly NodesToAddCollector $nodesToAddCollector ) { } @@ -38,7 +36,7 @@ public function getNodeTypes(): array } /** - * @param \PhpParser\Node\Stmt\Expression $node + * @param \PhpParser\Node\Expr\MethodCall $node */ public function refactor(Node $node): ?Node { diff --git a/src/ContentRepository90/Rules/ContextRectorTrait.php b/src/ContentRepository90/Rules/ContextRectorTrait.php index d14b509..0ad1807 100644 --- a/src/ContentRepository90/Rules/ContextRectorTrait.php +++ b/src/ContentRepository90/Rules/ContextRectorTrait.php @@ -4,15 +4,8 @@ namespace Neos\Rector\ContentRepository90\Rules; -use Neos\Rector\Utility\CodeSampleLoader; use PhpParser\Node; -use PhpParser\NodeFinder; use PHPStan\Type\ObjectType; -use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; -use Rector\PostRector\Collector\NodesToAddCollector; -use PhpParser\Node\Expr\Assign; -use PhpParser\NodeDumper; trait ContextRectorTrait { diff --git a/src/ContentRepository90/Rules/NodeFactoryResetRector.php b/src/ContentRepository90/Rules/NodeFactoryResetRector.php index 7078e9f..08486b5 100644 --- a/src/ContentRepository90/Rules/NodeFactoryResetRector.php +++ b/src/ContentRepository90/Rules/NodeFactoryResetRector.php @@ -5,8 +5,9 @@ use Neos\Rector\Utility\CodeSampleLoader; use PhpParser\Node; +use PhpParser\NodeTraverser; use PHPStan\Type\ObjectType; -use Rector\Core\Rector\AbstractRector; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; final class NodeFactoryResetRector extends AbstractRector @@ -33,7 +34,7 @@ public function getNodeTypes() : array /** * @param \PhpParser\Node\Expr\MethodCall $node */ - public function refactor(Node $node) : ?Node + public function refactor(Node $node) { assert($node instanceof Node\Expr\MethodCall); @@ -44,6 +45,7 @@ public function refactor(Node $node) : ?Node return null; } + // return NodeTraverser::REMOVE_NODE; $this->removeNode($node); return $node; diff --git a/src/ContentRepository90/Rules/NodeFindParentNodeRector.php b/src/ContentRepository90/Rules/NodeFindParentNodeRector.php index 18c9deb..ece8403 100644 --- a/src/ContentRepository90/Rules/NodeFindParentNodeRector.php +++ b/src/ContentRepository90/Rules/NodeFindParentNodeRector.php @@ -7,8 +7,8 @@ use Neos\Rector\Utility\CodeSampleLoader; use PhpParser\Node; use PHPStan\Type\ObjectType; -use Rector\Core\Rector\AbstractRector; -use Rector\PostRector\Collector\NodesToAddCollector; +use Rector\Rector\AbstractRector; + use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; final class NodeFindParentNodeRector extends AbstractRector @@ -16,7 +16,7 @@ final class NodeFindParentNodeRector extends AbstractRector use AllTraits; public function __construct( - private readonly NodesToAddCollector $nodesToAddCollector + ) { } @@ -48,12 +48,12 @@ public function refactor(Node $node): ?Node return null; } - $this->nodesToAddCollector->addNodesBeforeNode( - [ - self::assign('subgraph', $this->this_contentRepositoryRegistry_subgraphForNode($node->var)), - ], - $node - ); +// $this->nodesToAddCollector->addNodesBeforeNode( +// [ +// self::assign('subgraph', $this->this_contentRepositoryRegistry_subgraphForNode($node->var)), +// ], +// $node +// ); return $this->subgraph_findParentNode($node->var); } diff --git a/src/ContentRepository90/Rules/NodeGetChildNodesRector.php b/src/ContentRepository90/Rules/NodeGetChildNodesRector.php index eafa683..f95fda7 100644 --- a/src/ContentRepository90/Rules/NodeGetChildNodesRector.php +++ b/src/ContentRepository90/Rules/NodeGetChildNodesRector.php @@ -6,8 +6,8 @@ use Neos\Rector\Utility\CodeSampleLoader; use PhpParser\Node; use PHPStan\Type\ObjectType; -use Rector\Core\Rector\AbstractRector; -use Rector\PostRector\Collector\NodesToAddCollector; +use Rector\Rector\AbstractRector; + use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; final class NodeGetChildNodesRector extends AbstractRector @@ -15,7 +15,7 @@ final class NodeGetChildNodesRector extends AbstractRector use AllTraits; public function __construct( - private readonly NodesToAddCollector $nodesToAddCollector + ) { } @@ -70,13 +70,13 @@ public function refactor(Node $node) : ?Node } } - $this->nodesToAddCollector->addNodesBeforeNode( - [ - self::assign('subgraph', $this->this_contentRepositoryRegistry_subgraphForNode($node->var)), - self::todoComment('Try to remove the iterator_to_array($nodes) call.') - ], - $node - ); +// $this->nodesToAddCollector->addNodesBeforeNode( +// [ +// self::assign('subgraph', $this->this_contentRepositoryRegistry_subgraphForNode($node->var)), +// self::todoComment('Try to remove the iterator_to_array($nodes) call.') +// ], +// $node +// ); return $this->iteratorToArray( $this->subgraph_findChildNodes($node->var, $nodeTypeFilterExpr, $limitExpr, $offsetExpr) diff --git a/src/ContentRepository90/Rules/NodeGetContextGetWorkspaceNameRector.php b/src/ContentRepository90/Rules/NodeGetContextGetWorkspaceNameRector.php index defc1c8..2830980 100644 --- a/src/ContentRepository90/Rules/NodeGetContextGetWorkspaceNameRector.php +++ b/src/ContentRepository90/Rules/NodeGetContextGetWorkspaceNameRector.php @@ -7,8 +7,8 @@ use Neos\Rector\Utility\CodeSampleLoader; use PhpParser\Node; use PHPStan\Type\ObjectType; -use Rector\Core\Rector\AbstractRector; -use Rector\PostRector\Collector\NodesToAddCollector; +use Rector\Rector\AbstractRector; + use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; final class NodeGetContextGetWorkspaceNameRector extends AbstractRector @@ -16,7 +16,7 @@ final class NodeGetContextGetWorkspaceNameRector extends AbstractRector use AllTraits; public function __construct( - private readonly NodesToAddCollector $nodesToAddCollector + ) { } @@ -56,17 +56,17 @@ public function refactor(Node $node): ?Node } $nodeVar = $node->var->var; - $this->nodesToAddCollector->addNodesBeforeNode( - [ - self::assign( - 'contentRepository', - $this->this_contentRepositoryRegistry_get( - $this->node_subgraphIdentity_contentRepositoryId($nodeVar) - ) - ) - ], - $node - ); +// $this->nodesToAddCollector->addNodesBeforeNode( +// [ +// self::assign( +// 'contentRepository', +// $this->this_contentRepositoryRegistry_get( +// $this->node_subgraphIdentity_contentRepositoryId($nodeVar) +// ) +// ) +// ], +// $node +// ); $workspace = $this->contentRepository_getWorkspaceFinder_findOneByCurrentContentStreamId( $this->node_subgraphIdentity_contentStreamId($nodeVar) diff --git a/src/ContentRepository90/Rules/NodeGetContextGetWorkspaceRector.php b/src/ContentRepository90/Rules/NodeGetContextGetWorkspaceRector.php index a63c834..786f905 100644 --- a/src/ContentRepository90/Rules/NodeGetContextGetWorkspaceRector.php +++ b/src/ContentRepository90/Rules/NodeGetContextGetWorkspaceRector.php @@ -7,8 +7,8 @@ use Neos\Rector\Utility\CodeSampleLoader; use PhpParser\Node; use PHPStan\Type\ObjectType; -use Rector\Core\Rector\AbstractRector; -use Rector\PostRector\Collector\NodesToAddCollector; +use Rector\Rector\AbstractRector; + use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; final class NodeGetContextGetWorkspaceRector extends AbstractRector @@ -16,7 +16,7 @@ final class NodeGetContextGetWorkspaceRector extends AbstractRector use AllTraits; public function __construct( - private readonly NodesToAddCollector $nodesToAddCollector + ) { } @@ -56,17 +56,17 @@ public function refactor(Node $node): ?Node } $nodeVar = $node->var->var; - $this->nodesToAddCollector->addNodesBeforeNode( - [ - self::assign( - 'contentRepository', - $this->this_contentRepositoryRegistry_get( - $this->node_subgraphIdentity_contentRepositoryId($nodeVar) - ) - ) - ], - $node - ); +// $this->nodesToAddCollector->addNodesBeforeNode( +// [ +// self::assign( +// 'contentRepository', +// $this->this_contentRepositoryRegistry_get( +// $this->node_subgraphIdentity_contentRepositoryId($nodeVar) +// ) +// ) +// ], +// $node +// ); return $this->contentRepository_getWorkspaceFinder_findOneByCurrentContentStreamId( $this->node_subgraphIdentity_contentStreamId($nodeVar) diff --git a/src/ContentRepository90/Rules/NodeGetDepthRector.php b/src/ContentRepository90/Rules/NodeGetDepthRector.php index e232dc9..248eb56 100644 --- a/src/ContentRepository90/Rules/NodeGetDepthRector.php +++ b/src/ContentRepository90/Rules/NodeGetDepthRector.php @@ -6,8 +6,8 @@ use Neos\Rector\Utility\CodeSampleLoader; use PhpParser\Node; use PHPStan\Type\ObjectType; -use Rector\Core\Rector\AbstractRector; -use Rector\PostRector\Collector\NodesToAddCollector; +use Rector\Rector\AbstractRector; + use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; final class NodeGetDepthRector extends AbstractRector @@ -15,7 +15,7 @@ final class NodeGetDepthRector extends AbstractRector use AllTraits; public function __construct( - private readonly NodesToAddCollector $nodesToAddCollector + ) { } @@ -46,12 +46,12 @@ public function refactor(Node $node) : ?Node return null; } - $this->nodesToAddCollector->addNodesBeforeNode( - [ - self::assign('subgraph', $this->this_contentRepositoryRegistry_subgraphForNode($node->var)), - ], - $node - ); +// $this->nodesToAddCollector->addNodesBeforeNode( +// [ +// self::assign('subgraph', $this->this_contentRepositoryRegistry_subgraphForNode($node->var)), +// ], +// $node +// ); return $this->subgraph_findNodePath_getDepth($node->var); } diff --git a/src/ContentRepository90/Rules/NodeGetDimensionsRector.php b/src/ContentRepository90/Rules/NodeGetDimensionsRector.php index 88c9704..c10d916 100644 --- a/src/ContentRepository90/Rules/NodeGetDimensionsRector.php +++ b/src/ContentRepository90/Rules/NodeGetDimensionsRector.php @@ -6,8 +6,8 @@ use Neos\Rector\Utility\CodeSampleLoader; use PhpParser\Node; use PHPStan\Type\ObjectType; -use Rector\Core\Rector\AbstractRector; -use Rector\PostRector\Collector\NodesToAddCollector; +use Rector\Rector\AbstractRector; + use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; final class NodeGetDimensionsRector extends AbstractRector @@ -15,7 +15,7 @@ final class NodeGetDimensionsRector extends AbstractRector use AllTraits; public function __construct( - private readonly NodesToAddCollector $nodesToAddCollector + ) { } @@ -46,12 +46,12 @@ public function refactor(Node $node) : ?Node return null; } - $this->nodesToAddCollector->addNodesBeforeNode( - [ - self::todoComment('Try to remove the toLegacyDimensionArray() call and make your codebase more typesafe.') - ], - $node - ); +// $this->nodesToAddCollector->addNodesBeforeNode( +// [ +// self::todoComment('Try to remove the toLegacyDimensionArray() call and make your codebase more typesafe.') +// ], +// $node +// ); return $this->node_originDimensionSpacePoint_toLegacyDimensionArray($node->var); } diff --git a/src/ContentRepository90/Rules/NodeGetIdentifierRector.php b/src/ContentRepository90/Rules/NodeGetIdentifierRector.php index e75b64b..ecc2142 100644 --- a/src/ContentRepository90/Rules/NodeGetIdentifierRector.php +++ b/src/ContentRepository90/Rules/NodeGetIdentifierRector.php @@ -7,8 +7,8 @@ use Neos\Rector\Utility\CodeSampleLoader; use PhpParser\Node; use PHPStan\Type\ObjectType; -use Rector\Core\Rector\AbstractRector; -use Rector\PostRector\Collector\NodesToAddCollector; +use Rector\Rector\AbstractRector; + use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; final class NodeGetIdentifierRector extends AbstractRector @@ -16,7 +16,6 @@ final class NodeGetIdentifierRector extends AbstractRector use AllTraits; public function __construct( - private readonly NodesToAddCollector $nodesToAddCollector, ) { } @@ -47,12 +46,12 @@ public function refactor(Node $node): ?Node return null; } - $this->nodesToAddCollector->addNodesBeforeNode( - [ - self::todoComment('Check if you could change your code to work with the NodeAggregateId value object instead.') - ], - $node - ); +// $this->nodesToAddCollector->addNodesBeforeNode( +// [ +// self::todoComment('Check if you could change your code to work with the NodeAggregateId value object instead.') +// ], +// $node +// ); $propertyFetchAggregateId = $this->nodeFactory->createPropertyFetch($node->var, 'nodeAggregateId'); return $this->nodeFactory->createPropertyFetch($propertyFetchAggregateId, 'value'); diff --git a/src/ContentRepository90/Rules/NodeGetParentRector.php b/src/ContentRepository90/Rules/NodeGetParentRector.php index a05627e..fc4c320 100644 --- a/src/ContentRepository90/Rules/NodeGetParentRector.php +++ b/src/ContentRepository90/Rules/NodeGetParentRector.php @@ -6,8 +6,8 @@ use Neos\Rector\Utility\CodeSampleLoader; use PhpParser\Node; use PHPStan\Type\ObjectType; -use Rector\Core\Rector\AbstractRector; -use Rector\PostRector\Collector\NodesToAddCollector; +use Rector\Rector\AbstractRector; + use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; final class NodeGetParentRector extends AbstractRector @@ -15,7 +15,7 @@ final class NodeGetParentRector extends AbstractRector use AllTraits; public function __construct( - private readonly NodesToAddCollector $nodesToAddCollector + ) { } @@ -46,12 +46,12 @@ public function refactor(Node $node) : ?Node return null; } - $this->nodesToAddCollector->addNodesBeforeNode( - [ - self::assign('subgraph', $this->this_contentRepositoryRegistry_subgraphForNode($node->var)), - ], - $node - ); +// $this->nodesToAddCollector->addNodesBeforeNode( +// [ +// self::assign('subgraph', $this->this_contentRepositoryRegistry_subgraphForNode($node->var)), +// ], +// $node +// ); return $this->subgraph_findParentNode($node->var); } diff --git a/src/ContentRepository90/Rules/NodeGetPathRector.php b/src/ContentRepository90/Rules/NodeGetPathRector.php index f5d69f8..7000f51 100644 --- a/src/ContentRepository90/Rules/NodeGetPathRector.php +++ b/src/ContentRepository90/Rules/NodeGetPathRector.php @@ -6,8 +6,8 @@ use Neos\Rector\Utility\CodeSampleLoader; use PhpParser\Node; use PHPStan\Type\ObjectType; -use Rector\Core\Rector\AbstractRector; -use Rector\PostRector\Collector\NodesToAddCollector; +use Rector\Rector\AbstractRector; + use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; final class NodeGetPathRector extends AbstractRector @@ -15,7 +15,7 @@ final class NodeGetPathRector extends AbstractRector use AllTraits; public function __construct( - private readonly NodesToAddCollector $nodesToAddCollector + ) { } @@ -46,13 +46,13 @@ public function refactor(Node $node) : ?Node return null; } - $this->nodesToAddCollector->addNodesBeforeNode( - [ - self::assign('subgraph', $this->this_contentRepositoryRegistry_subgraphForNode($node->var)), - self::todoComment('Try to remove the (string) cast and make your code more type-safe.') - ], - $node - ); +// $this->nodesToAddCollector->addNodesBeforeNode( +// [ +// self::assign('subgraph', $this->this_contentRepositoryRegistry_subgraphForNode($node->var)), +// self::todoComment('Try to remove the (string) cast and make your code more type-safe.') +// ], +// $node +// ); return $this->castToString( $this->subgraph_findNodePath($node->var) diff --git a/src/ContentRepository90/Rules/NodeIsHiddenInIndexRector.php b/src/ContentRepository90/Rules/NodeIsHiddenInIndexRector.php index 96f618a..e9b4515 100644 --- a/src/ContentRepository90/Rules/NodeIsHiddenInIndexRector.php +++ b/src/ContentRepository90/Rules/NodeIsHiddenInIndexRector.php @@ -8,8 +8,7 @@ use PhpParser\Node; use PhpParser\Node\Expr\MethodCall; use PHPStan\Type\ObjectType; -use Rector\Core\Rector\AbstractRector; -use Rector\PostRector\Collector\NodesToAddCollector; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; final class NodeIsHiddenInIndexRector extends AbstractRector @@ -17,7 +16,6 @@ final class NodeIsHiddenInIndexRector extends AbstractRector use AllTraits; public function __construct( - private readonly NodesToAddCollector $nodesToAddCollector ) { } diff --git a/src/ContentRepository90/Rules/NodeIsHiddenRector.php b/src/ContentRepository90/Rules/NodeIsHiddenRector.php index 6e35f89..e682752 100644 --- a/src/ContentRepository90/Rules/NodeIsHiddenRector.php +++ b/src/ContentRepository90/Rules/NodeIsHiddenRector.php @@ -1,6 +1,7 @@ > */ - public function getNodeTypes() : array + public function getNodeTypes(): array { return [\PhpParser\Node\Expr\MethodCall::class]; } + /** * @param \PhpParser\Node\Expr\MethodCall $node */ - public function refactor(Node $node) : ?Node + public function refactor(Node $node): ?Node { assert($node instanceof Node\Expr\MethodCall); @@ -54,14 +53,14 @@ public function refactor(Node $node) : ?Node $getNodeHiddenStateFinder = $this->contentRepository_projectionState(NodeHiddenStateFinder::class); $getHiddenState = $this->nodeHiddenStateFinder_findHiddenState($node->var); - $this->nodesToAddCollector->addNodesBeforeNode( - [ - self::assign('contentRepository', $getContentRepository), - self::assign('nodeHiddenStateFinder', $getNodeHiddenStateFinder), - self::assign('hiddenState', $getHiddenState), - ], - $node - ); +// $this->nodesToAddCollector->addNodesBeforeNode( +// [ +// self::assign('contentRepository', $getContentRepository), +// self::assign('nodeHiddenStateFinder', $getNodeHiddenStateFinder), +// self::assign('hiddenState', $getHiddenState), +// ], +// $node +// ); return $this->nodeFactory->createMethodCall( new Variable('hiddenState'), diff --git a/src/ContentRepository90/Rules/NodeTypeAllowsGrandchildNodeTypeRector.php b/src/ContentRepository90/Rules/NodeTypeAllowsGrandchildNodeTypeRector.php index 298973e..836e47c 100644 --- a/src/ContentRepository90/Rules/NodeTypeAllowsGrandchildNodeTypeRector.php +++ b/src/ContentRepository90/Rules/NodeTypeAllowsGrandchildNodeTypeRector.php @@ -7,8 +7,7 @@ use Neos\Rector\Utility\CodeSampleLoader; use PhpParser\Node; use PHPStan\Type\ObjectType; -use Rector\Core\Rector\AbstractRector; -use Rector\PostRector\Collector\NodesToAddCollector; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use Neos\ContentRepository\Core\NodeType\NodeType; use PhpParser\NodeDumper; @@ -18,7 +17,7 @@ final class NodeTypeAllowsGrandchildNodeTypeRector extends AbstractRector use AllTraits; public function __construct( - private readonly NodesToAddCollector $nodesToAddCollector + ) { } @@ -50,15 +49,15 @@ public function refactor(Node $node): ?Node return null; } - $this->nodesToAddCollector->addNodesBeforeNode( - [ - self::withTodoComment( - 'Make this code aware of multiple Content Repositories.', - self::assign('contentRepository', $this->this_contentRepositoryRegistry_get($this->contentRepositoryId_fromString('default'))), - ) - ], - $node - ); +// $this->nodesToAddCollector->addNodesBeforeNode( +// [ +// self::withTodoComment( +// 'Make this code aware of multiple Content Repositories.', +// self::assign('contentRepository', $this->this_contentRepositoryRegistry_get($this->contentRepositoryId_fromString('default'))), +// ) +// ], +// $node +// ); return $this->nodeFactory->createMethodCall( $this->contentRepository_getNodeTypeManager(), diff --git a/src/ContentRepository90/Rules/NodeTypeGetAutoCreatedChildNodesRector.php b/src/ContentRepository90/Rules/NodeTypeGetAutoCreatedChildNodesRector.php index 36eb25b..9078656 100644 --- a/src/ContentRepository90/Rules/NodeTypeGetAutoCreatedChildNodesRector.php +++ b/src/ContentRepository90/Rules/NodeTypeGetAutoCreatedChildNodesRector.php @@ -6,8 +6,8 @@ use Neos\Rector\Utility\CodeSampleLoader; use PhpParser\Node; use PHPStan\Type\ObjectType; -use Rector\Core\Rector\AbstractRector; -use Rector\PostRector\Collector\NodesToAddCollector; +use Rector\Rector\AbstractRector; + use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use Neos\ContentRepository\Core\NodeType\NodeType; @@ -16,7 +16,7 @@ final class NodeTypeGetAutoCreatedChildNodesRector extends AbstractRector use AllTraits; public function __construct( - private readonly NodesToAddCollector $nodesToAddCollector + ) { } @@ -48,15 +48,15 @@ public function refactor(Node $node) : ?Node return null; } - $this->nodesToAddCollector->addNodesBeforeNode( - [ - self::withTodoComment( - 'Make this code aware of multiple Content Repositories.', - self::assign('contentRepository', $this->this_contentRepositoryRegistry_get($this->contentRepositoryId_fromString('default'))), - ) - ], - $node - ); +// $this->nodesToAddCollector->addNodesBeforeNode( +// [ +// self::withTodoComment( +// 'Make this code aware of multiple Content Repositories.', +// self::assign('contentRepository', $this->this_contentRepositoryRegistry_get($this->contentRepositoryId_fromString('default'))), +// ) +// ], +// $node +// ); return $this->nodeFactory->createMethodCall( $this->contentRepository_getNodeTypeManager(), diff --git a/src/ContentRepository90/Rules/NodeTypeGetNameRector.php b/src/ContentRepository90/Rules/NodeTypeGetNameRector.php index 0deac54..d6daafe 100644 --- a/src/ContentRepository90/Rules/NodeTypeGetNameRector.php +++ b/src/ContentRepository90/Rules/NodeTypeGetNameRector.php @@ -7,8 +7,7 @@ use Neos\Rector\Utility\CodeSampleLoader; use PhpParser\Node; use PHPStan\Type\ObjectType; -use Rector\Core\Rector\AbstractRector; -use Rector\PostRector\Collector\NodesToAddCollector; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; final class NodeTypeGetNameRector extends AbstractRector @@ -16,7 +15,6 @@ final class NodeTypeGetNameRector extends AbstractRector use AllTraits; public function __construct( - private readonly NodesToAddCollector $nodesToAddCollector ) { } diff --git a/src/ContentRepository90/Rules/NodeTypeGetTypeOfAutoCreatedChildNodeRector.php b/src/ContentRepository90/Rules/NodeTypeGetTypeOfAutoCreatedChildNodeRector.php index 23bf140..1814c24 100644 --- a/src/ContentRepository90/Rules/NodeTypeGetTypeOfAutoCreatedChildNodeRector.php +++ b/src/ContentRepository90/Rules/NodeTypeGetTypeOfAutoCreatedChildNodeRector.php @@ -6,8 +6,8 @@ use Neos\Rector\Utility\CodeSampleLoader; use PhpParser\Node; use PHPStan\Type\ObjectType; -use Rector\Core\Rector\AbstractRector; -use Rector\PostRector\Collector\NodesToAddCollector; +use Rector\Rector\AbstractRector; + use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use Neos\ContentRepository\Core\NodeType\NodeType; use PhpParser\NodeDumper; @@ -17,7 +17,6 @@ final class NodeTypeGetTypeOfAutoCreatedChildNodeRector extends AbstractRector use AllTraits; public function __construct( - private readonly NodesToAddCollector $nodesToAddCollector ) { } @@ -49,15 +48,15 @@ public function refactor(Node $node) : ?Node return null; } - $this->nodesToAddCollector->addNodesBeforeNode( - [ - self::withTodoComment( - 'Make this code aware of multiple Content Repositories.', - self::assign('contentRepository', $this->this_contentRepositoryRegistry_get($this->contentRepositoryId_fromString('default'))), - ) - ], - $node - ); +// $this->nodesToAddCollector->addNodesBeforeNode( +// [ +// self::withTodoComment( +// 'Make this code aware of multiple Content Repositories.', +// self::assign('contentRepository', $this->this_contentRepositoryRegistry_get($this->contentRepositoryId_fromString('default'))), +// ) +// ], +// $node +// ); return $this->nodeFactory->createMethodCall( $this->contentRepository_getNodeTypeManager(), diff --git a/src/ContentRepository90/Rules/NodeTypeManagerAccessRector.php b/src/ContentRepository90/Rules/NodeTypeManagerAccessRector.php index 1be72f7..93321da 100644 --- a/src/ContentRepository90/Rules/NodeTypeManagerAccessRector.php +++ b/src/ContentRepository90/Rules/NodeTypeManagerAccessRector.php @@ -10,8 +10,8 @@ use PhpParser\Node; use PhpParser\Node\Expr; use PHPStan\Type\ObjectType; -use Rector\Core\Rector\AbstractRector; -use Rector\PostRector\Collector\NodesToAddCollector; +use Rector\Rector\AbstractRector; + use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; final class NodeTypeManagerAccessRector extends AbstractRector @@ -19,7 +19,7 @@ final class NodeTypeManagerAccessRector extends AbstractRector use AllTraits; public function __construct( - private readonly NodesToAddCollector $nodesToAddCollector + ) { } @@ -47,15 +47,15 @@ public function refactor(Node $node) : ?Node return null; } - $this->nodesToAddCollector->addNodesBeforeNode( - [ - self::withTodoComment( - 'Make this code aware of multiple Content Repositories.', - self::assign('contentRepository', $this->this_contentRepositoryRegistry_get($this->contentRepositoryId_fromString('default'))), - ) - ], - $node - ); +// $this->nodesToAddCollector->addNodesBeforeNode( +// [ +// self::withTodoComment( +// 'Make this code aware of multiple Content Repositories.', +// self::assign('contentRepository', $this->this_contentRepositoryRegistry_get($this->contentRepositoryId_fromString('default'))), +// ) +// ], +// $node +// ); return $this->contentRepository_getNodeTypeManager(); } diff --git a/src/ContentRepository90/Rules/WorkspaceGetNameRector.php b/src/ContentRepository90/Rules/WorkspaceGetNameRector.php index ba768ae..24dca8b 100644 --- a/src/ContentRepository90/Rules/WorkspaceGetNameRector.php +++ b/src/ContentRepository90/Rules/WorkspaceGetNameRector.php @@ -7,8 +7,8 @@ use Neos\Rector\Utility\CodeSampleLoader; use PhpParser\Node; use PHPStan\Type\ObjectType; -use Rector\Core\Rector\AbstractRector; -use Rector\PostRector\Collector\NodesToAddCollector; +use Rector\Rector\AbstractRector; + use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use Neos\ContentRepository\Core\Projection\Workspace\Workspace; @@ -17,7 +17,6 @@ final class WorkspaceGetNameRector extends AbstractRector use AllTraits; public function __construct( - private readonly NodesToAddCollector $nodesToAddCollector, ) { } @@ -48,12 +47,12 @@ public function refactor(Node $node): ?Node return null; } - $this->nodesToAddCollector->addNodesBeforeNode( - [ - self::todoComment('Check if you could change your code to work with the WorkspaceName value object instead.') - ], - $node - ); +// $this->nodesToAddCollector->addNodesBeforeNode( +// [ +// self::todoComment('Check if you could change your code to work with the WorkspaceName value object instead.') +// ], +// $node +// ); $propertyFetchAggregateId = $this->nodeFactory->createPropertyFetch($node->var, 'workspaceName'); return $this->nodeFactory->createPropertyFetch($propertyFetchAggregateId, 'value'); diff --git a/src/ContentRepository90/Rules/WorkspaceRepositoryCountByNameRector.php b/src/ContentRepository90/Rules/WorkspaceRepositoryCountByNameRector.php index 4a18a0f..728ece3 100644 --- a/src/ContentRepository90/Rules/WorkspaceRepositoryCountByNameRector.php +++ b/src/ContentRepository90/Rules/WorkspaceRepositoryCountByNameRector.php @@ -8,8 +8,8 @@ use PhpParser\Node; use PhpParser\Node\Expr; use PHPStan\Type\ObjectType; -use Rector\Core\Rector\AbstractRector; -use Rector\PostRector\Collector\NodesToAddCollector; +use Rector\Rector\AbstractRector; + use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; final class WorkspaceRepositoryCountByNameRector extends AbstractRector @@ -17,7 +17,7 @@ final class WorkspaceRepositoryCountByNameRector extends AbstractRector use AllTraits; public function __construct( - private readonly NodesToAddCollector $nodesToAddCollector + ) { } @@ -50,13 +50,13 @@ public function refactor(Node $node): ?Node } - $this->nodesToAddCollector->addNodesBeforeNode( - [ - self::assign('contentRepository', $this->this_contentRepositoryRegistry_get($this->contentRepositoryId_fromString('default'))), - self::todoComment('remove ternary operator (...? 1 : 0 ) - unnecessary complexity',) - ], - $node - ); +// $this->nodesToAddCollector->addNodesBeforeNode( +// [ +// self::assign('contentRepository', $this->this_contentRepositoryRegistry_get($this->contentRepositoryId_fromString('default'))), +// self::todoComment('remove ternary operator (...? 1 : 0 ) - unnecessary complexity',) +// ], +// $node +// ); return new Node\Expr\Ternary( new Node\Expr\BinaryOp\NotIdentical( diff --git a/src/Core/FusionProcessing/FusionRectorInterface.php b/src/Core/FusionProcessing/FusionRectorInterface.php index 0fd19df..19253db 100644 --- a/src/Core/FusionProcessing/FusionRectorInterface.php +++ b/src/Core/FusionProcessing/FusionRectorInterface.php @@ -4,7 +4,7 @@ namespace Neos\Rector\Core\FusionProcessing; -use Rector\Core\Contract\Rector\RectorInterface; +use Rector\Contract\Rector\RectorInterface; interface FusionRectorInterface extends RectorInterface { diff --git a/src/Core/YamlProcessing/YamlRectorInterface.php b/src/Core/YamlProcessing/YamlRectorInterface.php index e29a662..0959bd1 100644 --- a/src/Core/YamlProcessing/YamlRectorInterface.php +++ b/src/Core/YamlProcessing/YamlRectorInterface.php @@ -4,7 +4,7 @@ namespace Neos\Rector\Core\YamlProcessing; -use Rector\Core\Contract\Rector\RectorInterface; +use Rector\Contract\Rector\RectorInterface; interface YamlRectorInterface extends RectorInterface { diff --git a/src/Generic/Rules/FusionFlowQueryNodePropertyToWarningCommentRector.php b/src/Generic/Rules/FusionFlowQueryNodePropertyToWarningCommentRector.php index 3a919af..540fa69 100644 --- a/src/Generic/Rules/FusionFlowQueryNodePropertyToWarningCommentRector.php +++ b/src/Generic/Rules/FusionFlowQueryNodePropertyToWarningCommentRector.php @@ -10,7 +10,7 @@ use Neos\Rector\Core\FusionProcessing\FusionRectorInterface; use Neos\Rector\Core\FusionProcessing\Helper\RegexCommentTemplatePair; use Neos\Rector\Utility\CodeSampleLoader; -use Rector\Core\Contract\Rector\ConfigurableRectorInterface; +use Rector\Contract\Rector\ConfigurableRectorInterface; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use Webmozart\Assert\Assert; use Neos\Rector\Generic\ValueObject\FusionFlowQueryNodePropertyToWarningComment; diff --git a/src/Generic/Rules/FusionNodePropertyPathToWarningCommentRector.php b/src/Generic/Rules/FusionNodePropertyPathToWarningCommentRector.php index 5c40906..79947c4 100644 --- a/src/Generic/Rules/FusionNodePropertyPathToWarningCommentRector.php +++ b/src/Generic/Rules/FusionNodePropertyPathToWarningCommentRector.php @@ -11,7 +11,7 @@ use Neos\Rector\Core\FusionProcessing\Helper\RegexCommentTemplatePair; use Neos\Rector\Generic\ValueObject\FusionNodePropertyPathToWarningComment; use Neos\Rector\Utility\CodeSampleLoader; -use Rector\Core\Contract\Rector\ConfigurableRectorInterface; +use Rector\Contract\Rector\ConfigurableRectorInterface; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use Webmozart\Assert\Assert; diff --git a/src/Generic/Rules/FusionPrototypeNameAddCommentRector.php b/src/Generic/Rules/FusionPrototypeNameAddCommentRector.php index 1067e44..91e7dc5 100644 --- a/src/Generic/Rules/FusionPrototypeNameAddCommentRector.php +++ b/src/Generic/Rules/FusionPrototypeNameAddCommentRector.php @@ -5,7 +5,7 @@ use Neos\Rector\Core\FusionProcessing\FusionRectorInterface; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use Neos\Rector\Utility\CodeSampleLoader; -use Rector\Core\Contract\Rector\ConfigurableRectorInterface; +use Rector\Contract\Rector\ConfigurableRectorInterface; use Neos\Rector\Generic\ValueObject\FusionNodePropertyPathToWarningComment; use Webmozart\Assert\Assert; use Neos\Rector\Generic\ValueObject\FusionPrototypeNameReplacement; diff --git a/src/Generic/Rules/FusionReplacePrototypeNameRector.php b/src/Generic/Rules/FusionReplacePrototypeNameRector.php index 1505ae9..2310611 100644 --- a/src/Generic/Rules/FusionReplacePrototypeNameRector.php +++ b/src/Generic/Rules/FusionReplacePrototypeNameRector.php @@ -5,7 +5,7 @@ use Neos\Rector\Core\FusionProcessing\FusionRectorInterface; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use Neos\Rector\Utility\CodeSampleLoader; -use Rector\Core\Contract\Rector\ConfigurableRectorInterface; +use Rector\Contract\Rector\ConfigurableRectorInterface; use Neos\Rector\Generic\ValueObject\FusionNodePropertyPathToWarningComment; use Webmozart\Assert\Assert; use Neos\Rector\Generic\ValueObject\FusionPrototypeNameReplacement; diff --git a/src/Generic/Rules/InjectServiceIfNeededRector.php b/src/Generic/Rules/InjectServiceIfNeededRector.php index c83948b..220fab0 100644 --- a/src/Generic/Rules/InjectServiceIfNeededRector.php +++ b/src/Generic/Rules/InjectServiceIfNeededRector.php @@ -11,12 +11,12 @@ use PhpParser\Node\Name\FullyQualified; use PhpParser\Node\Stmt\Class_; use PhpParser\Node\Stmt\Property; -use Rector\Core\NodeManipulator\ClassInsertManipulator; -use Rector\Core\Rector\AbstractRector; +use Rector\NodeManipulator\ClassInsertManipulator; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use Webmozart\Assert\Assert; use Neos\Rector\Generic\ValueObject\AddInjection; -use Rector\Core\Contract\Rector\ConfigurableRectorInterface; +use Rector\Contract\Rector\ConfigurableRectorInterface; // Modelled after https://raw.githubusercontent.com/sabbelasichon/typo3-rector/main/src/Rector/v10/v2/InjectEnvironmentServiceIfNeededInResponseRector.php final class InjectServiceIfNeededRector extends AbstractRector implements ConfigurableRectorInterface diff --git a/src/Generic/Rules/MethodCallToWarningCommentRector.php b/src/Generic/Rules/MethodCallToWarningCommentRector.php index 25bf7aa..0ebddb9 100644 --- a/src/Generic/Rules/MethodCallToWarningCommentRector.php +++ b/src/Generic/Rules/MethodCallToWarningCommentRector.php @@ -8,9 +8,9 @@ use Neos\Rector\Utility\CodeSampleLoader; use PhpParser\Node; use PHPStan\Type\ObjectType; -use Rector\Core\Contract\Rector\ConfigurableRectorInterface; -use Rector\Core\Rector\AbstractRector; -use Rector\PostRector\Collector\NodesToAddCollector; +use Rector\Contract\Rector\ConfigurableRectorInterface; +use Rector\Rector\AbstractRector; + use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use Webmozart\Assert\Assert; use Neos\Rector\ContentRepository90\Legacy\NodeLegacyStub; @@ -25,7 +25,7 @@ final class MethodCallToWarningCommentRector extends AbstractRector implements C private array $methodCallsToWarningComments = []; public function __construct( - private readonly NodesToAddCollector $nodesToAddCollector + ) { } @@ -59,12 +59,12 @@ public function refactor(Node $node): ?Node continue; } - $this->nodesToAddCollector->addNodesBeforeNode( - [ - self::todoComment($methodCallToWarningComment->warningMessage) - ], - $node - ); +// $this->nodesToAddCollector->addNodesBeforeNode( +// [ +// self::todoComment($methodCallToWarningComment->warningMessage) +// ], +// $node +// ); return $node; } diff --git a/src/Generic/Rules/RemoveDuplicateCommentRector.php b/src/Generic/Rules/RemoveDuplicateCommentRector.php index d932256..705458a 100644 --- a/src/Generic/Rules/RemoveDuplicateCommentRector.php +++ b/src/Generic/Rules/RemoveDuplicateCommentRector.php @@ -4,15 +4,12 @@ namespace Neos\Rector\Generic\Rules; -use Neos\Rector\Generic\ValueObject\MethodCallToWarningComment; use Neos\Rector\Utility\CodeSampleLoader; use PhpParser\Node; +use PhpParser\NodeTraverser; use PHPStan\Type\ObjectType; -use Rector\Core\Contract\Rector\ConfigurableRectorInterface; -use Rector\Core\Rector\AbstractRector; -use Rector\PostRector\Collector\NodesToAddCollector; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; -use Webmozart\Assert\Assert; final class RemoveDuplicateCommentRector extends AbstractRector { @@ -47,7 +44,7 @@ public function getNodeTypes(): array /** * @param Node $node */ - public function refactor(Node $node): ?Node + public function refactor(Node $node) { if (self::commentContains90Comment($node)) { $filePath = $this->file->getFilePath(); @@ -61,8 +58,7 @@ public function refactor(Node $node): ?Node if ($node instanceof Node\Stmt\Nop) { $node->setAttribute('comments', []); - $this->removeNode($node); - return $node; + return NodeTraverser::REMOVE_NODE; } } else { $newComments[] = $comment; diff --git a/src/Generic/Rules/RemoveInjectionsRector.php b/src/Generic/Rules/RemoveInjectionsRector.php index 5aacd0c..0c298d5 100644 --- a/src/Generic/Rules/RemoveInjectionsRector.php +++ b/src/Generic/Rules/RemoveInjectionsRector.php @@ -7,10 +7,10 @@ use Neos\Rector\Generic\ValueObject\RemoveInjection; use Neos\Rector\Utility\CodeSampleLoader; use PhpParser\Node; +use PhpParser\NodeTraverser; use PHPStan\Type\ObjectType; -use Rector\Core\Contract\Rector\ConfigurableRectorInterface; -use Rector\Core\Rector\AbstractRector; -use Rector\PostRector\Collector\NodesToRemoveCollector; +use Rector\Contract\Rector\ConfigurableRectorInterface; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use Webmozart\Assert\Assert; @@ -23,9 +23,8 @@ final class RemoveInjectionsRector extends AbstractRector implements Configurabl */ private array $injectionsToRemove = []; - public function __construct( - private readonly NodesToRemoveCollector $nodesToRemoveCollector - ) { + public function __construct() + { } public function getRuleDefinition(): RuleDefinition @@ -46,12 +45,13 @@ public function getNodeTypes(): array /** * @param \PhpParser\Node\Expr\MethodCall $node */ - public function refactor(Node $node): ?Node + public function refactor(Node $node) { assert($node instanceof Node\Stmt\Property); foreach ($this->injectionsToRemove as $removeInjection) { if ($this->isObjectType($node, new ObjectType($removeInjection->objectType))) { if (self::hasFlowInjectAttribute($node->attrGroups) || $this->hasFlowInjectDocComment($node)) { + // return NodeTraverser::REMOVE_NODE; $this->removeNode($node); return $node; } diff --git a/src/Generic/Rules/RemoveParentClassRector.php b/src/Generic/Rules/RemoveParentClassRector.php index 6d5cf1c..d01bfe7 100644 --- a/src/Generic/Rules/RemoveParentClassRector.php +++ b/src/Generic/Rules/RemoveParentClassRector.php @@ -4,17 +4,13 @@ namespace Neos\Rector\Generic\Rules; -use Neos\Rector\Generic\ValueObject\RemoveInjection; use Neos\Rector\Generic\ValueObject\RemoveParentClass; use Neos\Rector\Utility\CodeSampleLoader; use PhpParser\Comment; use PhpParser\Node; use PHPStan\Type\ObjectType; -use Rector\Core\Contract\Rector\ConfigurableRectorInterface; -use Rector\Core\Rector\AbstractRector; -use Rector\NodeTypeResolver\NodeTypeResolver; -use Rector\PostRector\Collector\NodesToRemoveCollector; -use Rector\Removing\Rector\Class_\RemoveParentRector; +use Rector\Contract\Rector\ConfigurableRectorInterface; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use Webmozart\Assert\Assert; @@ -30,8 +26,8 @@ final class RemoveParentClassRector extends AbstractRector implements Configurab */ private array $parentClassesToRemove = []; - public function __construct( - ) { + public function __construct() + { } public function getRuleDefinition(): RuleDefinition diff --git a/src/Generic/Rules/ToStringToMethodCallOrPropertyFetchRector.php b/src/Generic/Rules/ToStringToMethodCallOrPropertyFetchRector.php index 07c4988..398269c 100644 --- a/src/Generic/Rules/ToStringToMethodCallOrPropertyFetchRector.php +++ b/src/Generic/Rules/ToStringToMethodCallOrPropertyFetchRector.php @@ -12,8 +12,8 @@ use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Identifier; use PHPStan\Type\ObjectType; -use Rector\Core\Contract\Rector\ConfigurableRectorInterface; -use Rector\Core\Rector\AbstractRector; +use Rector\Contract\Rector\ConfigurableRectorInterface; +use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use Webmozart\Assert\Assert; diff --git a/tests/ContentRepository90/Rules/FusionNodeContextPathRector/config/configured_rule.php b/tests/ContentRepository90/Rules/FusionNodeContextPathRector/config/configured_rule.php index b05ebef..721fbad 100644 --- a/tests/ContentRepository90/Rules/FusionNodeContextPathRector/config/configured_rule.php +++ b/tests/ContentRepository90/Rules/FusionNodeContextPathRector/config/configured_rule.php @@ -6,14 +6,9 @@ use Rector\Config\RectorConfig; use Neos\Rector\ContentRepository90\Rules\FusionNodeContextPathRector; -return static function (RectorConfig $rectorConfig): void { - $services = $rectorConfig->services(); - $services->defaults() - ->public() - ->autowire() - ->autoconfigure(); - $services->set(FusionFileProcessor::class); - $rectorConfig->disableParallel(); // does not work for fusion files - see https://github.com/rectorphp/rector-src/pull/2597#issuecomment-1190120688 - - $rectorConfig->rule(FusionNodeContextPathRector::class); -}; +return RectorConfig::configure() + ->registerService(FusionFileProcessor::class) + ->withoutParallel() + ->withRules([ + FusionNodeContextPathRector::class + ]); \ No newline at end of file diff --git a/tests/Generic/Rules/RemoveDuplicateCommentRector/RemoveDuplicateCommentRector.php b/tests/Generic/Rules/RemoveDuplicateCommentRector/RemoveDuplicateCommentRectorTest.php similarity index 100% rename from tests/Generic/Rules/RemoveDuplicateCommentRector/RemoveDuplicateCommentRector.php rename to tests/Generic/Rules/RemoveDuplicateCommentRector/RemoveDuplicateCommentRectorTest.php diff --git a/tests/Generic/Rules/RemoveDuplicateCommentRector/RemoveDuplicateCommentRectortEST.php b/tests/Generic/Rules/RemoveDuplicateCommentRector/RemoveDuplicateCommentRectortEST.php new file mode 100644 index 0000000..c57735e --- /dev/null +++ b/tests/Generic/Rules/RemoveDuplicateCommentRector/RemoveDuplicateCommentRectortEST.php @@ -0,0 +1,31 @@ +doTestFile($fileInfo); + } + + /** + * @return \Iterator + */ + public function provideData(): \Iterator + { + return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); + } + + public function provideConfigFilePath(): string + { + return __DIR__ . '/config/configured_rule.php'; + } +}