Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEATURE: Add todo warnings for all NodeData::* methods #117

Merged
merged 1 commit into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions config/set/contentrepository-90.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Generic/Rules/MethodCallToWarningCommentRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class SomeClass
{
public function run(NodeLegacyStub $node)
{
$node->getNode();
return $node->getWorkspace();
}
}
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.'),
]);
};
157 changes: 157 additions & 0 deletions tests/Sets/ContentRepository90/Fixture/node-data.php.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
<?php


use Neos\ContentRepository\Domain\Model\NodeData;

class SomeClass {

public function foo(NodeData $nodeData)
{
$nodeData->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();
}
}
-----
<?php


use Neos\ContentRepository\Domain\Model\NodeData;

class SomeClass {

public function foo(NodeData $nodeData)
{
// TODO 9.0 migration: !! NodeData::createNodeData 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->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();
}
}
Loading