diff --git a/config/set/contentrepository-90.php b/config/set/contentrepository-90.php index 798c236..70328e4 100644 --- a/config/set/contentrepository-90.php +++ b/config/set/contentrepository-90.php @@ -435,6 +435,79 @@ */ $rectorConfig->rule(WorkspaceGetNameRector::class); + /** + * NodeData + */ + $nodeDataWarningMessage = '!! NodeData::%2$s is removed in Neos 9.0 - the new CR is not based around the concept of NodeData anymore. You need to rewrite your code here.'; + // createNodeData(name: string, [nodeType: NodeType|null = null], [identifier: null|string = null], [workspace: Workspace|null = null], [dimensions: array|null = null]): NodeData + $methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'createNodeData', $nodeDataWarningMessage); + // createNodeDataFromTemplate(nodeTemplate: NodeTemplate, [nodeName: null|string = null], [workspace: Workspace|null = null], [dimensions: array|null = null]): NodeData + $methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'createNodeDataFromTemplate', $nodeDataWarningMessage); + // createShadow(path: string): NodeData + $methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'createShadow', $nodeDataWarningMessage); + // createSingleNodeData(name: string, [nodeType: NodeType|null = null], [identifier: null|string = null], [workspace: Workspace|null = null], [dimensions: array|null = null]): NodeData + $methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'createSingleNodeData', $nodeDataWarningMessage); + // getContextPath(): string + $methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'getContextPath', $nodeDataWarningMessage); + // getDepth(): int + $methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'getDepth', $nodeDataWarningMessage); + // getDimensions(): NodeDimension[] + $methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'getDimensions', $nodeDataWarningMessage); + // getDimensionsHash(): string + $methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'getDimensionsHash', $nodeDataWarningMessage); + // getDimensionValues(): array + $methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'getDimensionValues', $nodeDataWarningMessage); + // getIdentifier(): string + $methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'getIdentifier', $nodeDataWarningMessage); + // getIndex(): int + $methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'getIndex', $nodeDataWarningMessage); + // getMovedTo(): NodeData + $methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'getMovedTo', $nodeDataWarningMessage); + // getName(): string + $methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'getName', $nodeDataWarningMessage); + // getNumberOfChildNodes(nodeTypeFilter: string, workspace: Workspace, dimensions: array): int + $methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'getNumberOfChildNodes', $nodeDataWarningMessage); + // getParent(): NodeData|null + $methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'getParent', $nodeDataWarningMessage); + // getParentPath(): string + $methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'getParentPath', $nodeDataWarningMessage); + // getPath(): string + $methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'getPath', $nodeDataWarningMessage); + // getWorkspace(): Workspace + $methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'getWorkspace', $nodeDataWarningMessage); + // hasAccessRestrictions(): bool + $methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'hasAccessRestrictions', $nodeDataWarningMessage); + // isAccessible(): bool + $methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'isAccessible', $nodeDataWarningMessage); + // isInternal(): bool + $methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'isInternal', $nodeDataWarningMessage); + // isRemoved(): bool + $methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'isRemoved', $nodeDataWarningMessage); + // isVisible(): bool + $methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'isVisible', $nodeDataWarningMessage); + // matchesWorkspaceAndDimensions(workspace: Workspace, [dimensions: array|null = null]): bool + $methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'matchesWorkspaceAndDimensions', $nodeDataWarningMessage); + // move(targetPath: string, targetWorkspace: Workspace): NodeData|null + $methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'targetPath', $nodeDataWarningMessage); + // remove(): void + $methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'remove', $nodeDataWarningMessage); + // setDimensions(dimensionsToBeSet: array): void + $methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'setDimensions', $nodeDataWarningMessage); + // setIdentifier(identifier: string): void + $methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'setIdentifier', $nodeDataWarningMessage); + // setIndex(index: int): void + $methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'setIndex', $nodeDataWarningMessage); + // setMovedTo([nodeData: NodeData|null = null]): void + $methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'setMovedTo', $nodeDataWarningMessage); + // setPath(path: string, [recursive: bool = true]): void + $methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'setPath', $nodeDataWarningMessage); + // setRemoved(removed: bool): void + $methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'setRemoved', $nodeDataWarningMessage); + // setWorkspace([workspace: Workspace|null = null]): void + $methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'setWorkspace', $nodeDataWarningMessage); + // similarize(sourceNode: AbstractNodeData, [isCopy: bool = false]): void + $methodCallToWarningComments[] = new MethodCallToWarningComment(\Neos\ContentRepository\Domain\Model\NodeData::class, 'similarize', $nodeDataWarningMessage); + /** * Signals and Slots * https://docs.neos.io/api/upgrade-instructions/9/signals-and-slots diff --git a/src/Generic/Rules/MethodCallToWarningCommentRector.php b/src/Generic/Rules/MethodCallToWarningCommentRector.php index 25bf7aa..eb2f196 100644 --- a/src/Generic/Rules/MethodCallToWarningCommentRector.php +++ b/src/Generic/Rules/MethodCallToWarningCommentRector.php @@ -61,7 +61,7 @@ public function refactor(Node $node): ?Node $this->nodesToAddCollector->addNodesBeforeNode( [ - self::todoComment($methodCallToWarningComment->warningMessage) + self::todoComment(sprintf($methodCallToWarningComment->warningMessage, $methodCallToWarningComment->objectType, $methodCallToWarningComment->methodName)) ], $node ); diff --git a/tests/Rules/MethodCallToWarningCommentRector/Fixture/some_class.php.inc b/tests/Rules/MethodCallToWarningCommentRector/Fixture/some_class.php.inc index 8718bab..284b0af 100644 --- a/tests/Rules/MethodCallToWarningCommentRector/Fixture/some_class.php.inc +++ b/tests/Rules/MethodCallToWarningCommentRector/Fixture/some_class.php.inc @@ -6,6 +6,7 @@ class SomeClass { public function run(NodeLegacyStub $node) { + $node->getNode(); return $node->getWorkspace(); } } @@ -20,6 +21,9 @@ class SomeClass { public function run(NodeLegacyStub $node) { + // TODO 9.0 migration: !! Neos\Rector\ContentRepository90\Legacy\NodeLegacyStub::getNode() has been removed. + + $node->getNode(); // TODO 9.0 migration: !! Node::getWorkspace() does not make sense anymore concept-wise. In Neos < 9, it pointed to the workspace where the node was *at home at*. Now, the closest we have here is the node identity. return $node->getWorkspace(); diff --git a/tests/Rules/MethodCallToWarningCommentRector/config/configured_rule.php b/tests/Rules/MethodCallToWarningCommentRector/config/configured_rule.php index e783d63..a63a3a4 100644 --- a/tests/Rules/MethodCallToWarningCommentRector/config/configured_rule.php +++ b/tests/Rules/MethodCallToWarningCommentRector/config/configured_rule.php @@ -8,6 +8,7 @@ use Rector\Config\RectorConfig; return static function (RectorConfig $rectorConfig) : void { $rectorConfig->ruleWithConfiguration(MethodCallToWarningCommentRector::class, [ - new MethodCallToWarningComment(NodeLegacyStub::class, 'getWorkspace', '!! Node::getWorkspace() does not make sense anymore concept-wise. In Neos < 9, it pointed to the workspace where the node was *at home at*. Now, the closest we have here is the node identity.') + new MethodCallToWarningComment(NodeLegacyStub::class, 'getWorkspace', '!! Node::getWorkspace() does not make sense anymore concept-wise. In Neos < 9, it pointed to the workspace where the node was *at home at*. Now, the closest we have here is the node identity.'), + new MethodCallToWarningComment(NodeLegacyStub::class, 'getNode', '!! %%1$s::%%2$s() has been removed.'), ]); }; diff --git a/tests/Sets/ContentRepository90/Fixture/node-data.php.inc b/tests/Sets/ContentRepository90/Fixture/node-data.php.inc new file mode 100644 index 0000000..e901fdf --- /dev/null +++ b/tests/Sets/ContentRepository90/Fixture/node-data.php.inc @@ -0,0 +1,157 @@ +createNodeData(); + $nodeData->createNodeDataFromTemplate(); + $nodeData->createShadow(); + $nodeData->createSingleNodeData(); + $nodeData->getContextPath(); + $nodeData->getDepth(); + $nodeData->getDimensions(); + $nodeData->getDimensionsHash(); + $nodeData->getDimensionValues(); + $nodeData->getIdentifier(); + $nodeData->getIndex(); + $nodeData->getMovedTo(); + $nodeData->getName(); + $nodeData->getNumberOfChildNodes(); + $nodeData->getParent(); + $nodeData->getParentPath(); + $nodeData->getPath(); + $nodeData->getWorkspace(); + $nodeData->hasAccessRestrictions(); + $nodeData->isAccessible(); + $nodeData->isInternal(); + $nodeData->isRemoved(); + $nodeData->isVisible(); + $nodeData->matchesWorkspaceAndDimensions(); + $nodeData->move(); + $nodeData->remove(); + $nodeData->setDimensions(); + $nodeData->setIdentifier(); + $nodeData->setIndex(); + $nodeData->setMovedTo(); + $nodeData->setPath(); + $nodeData->setRemoved(); + $nodeData->setWorkspace(); + $nodeData->similarize(); + } +} +----- +createNodeData(); + // TODO 9.0 migration: !! NodeData::createNodeDataFromTemplate is removed in Neos 9.0 - the new CR is not based around the concept of NodeData anymore. You need to rewrite your code here. + + $nodeData->createNodeDataFromTemplate(); + // TODO 9.0 migration: !! NodeData::createShadow is removed in Neos 9.0 - the new CR is not based around the concept of NodeData anymore. You need to rewrite your code here. + + $nodeData->createShadow(); + // TODO 9.0 migration: !! NodeData::createSingleNodeData is removed in Neos 9.0 - the new CR is not based around the concept of NodeData anymore. You need to rewrite your code here. + + $nodeData->createSingleNodeData(); + // TODO 9.0 migration: !! NodeData::getContextPath is removed in Neos 9.0 - the new CR is not based around the concept of NodeData anymore. You need to rewrite your code here. + + $nodeData->getContextPath(); + // TODO 9.0 migration: !! NodeData::getDepth is removed in Neos 9.0 - the new CR is not based around the concept of NodeData anymore. You need to rewrite your code here. + + $nodeData->getDepth(); + // TODO 9.0 migration: !! NodeData::getDimensions is removed in Neos 9.0 - the new CR is not based around the concept of NodeData anymore. You need to rewrite your code here. + + $nodeData->getDimensions(); + // TODO 9.0 migration: !! NodeData::getDimensionsHash is removed in Neos 9.0 - the new CR is not based around the concept of NodeData anymore. You need to rewrite your code here. + + $nodeData->getDimensionsHash(); + // TODO 9.0 migration: !! NodeData::getDimensionValues is removed in Neos 9.0 - the new CR is not based around the concept of NodeData anymore. You need to rewrite your code here. + + $nodeData->getDimensionValues(); + // TODO 9.0 migration: !! NodeData::getIdentifier is removed in Neos 9.0 - the new CR is not based around the concept of NodeData anymore. You need to rewrite your code here. + + $nodeData->getIdentifier(); + // TODO 9.0 migration: !! NodeData::getIndex is removed in Neos 9.0 - the new CR is not based around the concept of NodeData anymore. You need to rewrite your code here. + + $nodeData->getIndex(); + // TODO 9.0 migration: !! NodeData::getMovedTo is removed in Neos 9.0 - the new CR is not based around the concept of NodeData anymore. You need to rewrite your code here. + + $nodeData->getMovedTo(); + // TODO 9.0 migration: !! NodeData::getName is removed in Neos 9.0 - the new CR is not based around the concept of NodeData anymore. You need to rewrite your code here. + + $nodeData->getName(); + // TODO 9.0 migration: !! NodeData::getNumberOfChildNodes is removed in Neos 9.0 - the new CR is not based around the concept of NodeData anymore. You need to rewrite your code here. + + $nodeData->getNumberOfChildNodes(); + // TODO 9.0 migration: !! NodeData::getParent is removed in Neos 9.0 - the new CR is not based around the concept of NodeData anymore. You need to rewrite your code here. + + $nodeData->getParent(); + // TODO 9.0 migration: !! NodeData::getParentPath is removed in Neos 9.0 - the new CR is not based around the concept of NodeData anymore. You need to rewrite your code here. + + $nodeData->getParentPath(); + // TODO 9.0 migration: !! NodeData::getPath is removed in Neos 9.0 - the new CR is not based around the concept of NodeData anymore. You need to rewrite your code here. + + $nodeData->getPath(); + // TODO 9.0 migration: !! NodeData::getWorkspace is removed in Neos 9.0 - the new CR is not based around the concept of NodeData anymore. You need to rewrite your code here. + + $nodeData->getWorkspace(); + // TODO 9.0 migration: !! NodeData::hasAccessRestrictions is removed in Neos 9.0 - the new CR is not based around the concept of NodeData anymore. You need to rewrite your code here. + + $nodeData->hasAccessRestrictions(); + // TODO 9.0 migration: !! NodeData::isAccessible is removed in Neos 9.0 - the new CR is not based around the concept of NodeData anymore. You need to rewrite your code here. + + $nodeData->isAccessible(); + // TODO 9.0 migration: !! NodeData::isInternal is removed in Neos 9.0 - the new CR is not based around the concept of NodeData anymore. You need to rewrite your code here. + + $nodeData->isInternal(); + // TODO 9.0 migration: !! NodeData::isRemoved is removed in Neos 9.0 - the new CR is not based around the concept of NodeData anymore. You need to rewrite your code here. + + $nodeData->isRemoved(); + // TODO 9.0 migration: !! NodeData::isVisible is removed in Neos 9.0 - the new CR is not based around the concept of NodeData anymore. You need to rewrite your code here. + + $nodeData->isVisible(); + // TODO 9.0 migration: !! NodeData::matchesWorkspaceAndDimensions is removed in Neos 9.0 - the new CR is not based around the concept of NodeData anymore. You need to rewrite your code here. + + $nodeData->matchesWorkspaceAndDimensions(); + $nodeData->move(); + // TODO 9.0 migration: !! NodeData::remove is removed in Neos 9.0 - the new CR is not based around the concept of NodeData anymore. You need to rewrite your code here. + + $nodeData->remove(); + // TODO 9.0 migration: !! NodeData::setDimensions is removed in Neos 9.0 - the new CR is not based around the concept of NodeData anymore. You need to rewrite your code here. + + $nodeData->setDimensions(); + // TODO 9.0 migration: !! NodeData::setIdentifier is removed in Neos 9.0 - the new CR is not based around the concept of NodeData anymore. You need to rewrite your code here. + + $nodeData->setIdentifier(); + // TODO 9.0 migration: !! NodeData::setIndex is removed in Neos 9.0 - the new CR is not based around the concept of NodeData anymore. You need to rewrite your code here. + + $nodeData->setIndex(); + // TODO 9.0 migration: !! NodeData::setMovedTo is removed in Neos 9.0 - the new CR is not based around the concept of NodeData anymore. You need to rewrite your code here. + + $nodeData->setMovedTo(); + // TODO 9.0 migration: !! NodeData::setPath is removed in Neos 9.0 - the new CR is not based around the concept of NodeData anymore. You need to rewrite your code here. + + $nodeData->setPath(); + // TODO 9.0 migration: !! NodeData::setRemoved is removed in Neos 9.0 - the new CR is not based around the concept of NodeData anymore. You need to rewrite your code here. + + $nodeData->setRemoved(); + // TODO 9.0 migration: !! NodeData::setWorkspace is removed in Neos 9.0 - the new CR is not based around the concept of NodeData anymore. You need to rewrite your code here. + + $nodeData->setWorkspace(); + // TODO 9.0 migration: !! NodeData::similarize is removed in Neos 9.0 - the new CR is not based around the concept of NodeData anymore. You need to rewrite your code here. + + $nodeData->similarize(); + } +}