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

BUGFIX: Configure each rule once, as multiple definitions just override the previous ones #91

Merged
merged 1 commit into from
Nov 8, 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
14 changes: 7 additions & 7 deletions config/set/contentrepository-90.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
use Neos\Rector\ContentRepository90\Rules\WorkspaceGetNameRector;
use Neos\Rector\ContentRepository90\Rules\WorkspaceRepositoryCountByNameRector;
use Neos\Rector\ContentRepository90\Rules\YamlDimensionConfigRector;
use Neos\Rector\Generic\Rules\FusionFlowQueryNodePropertyToWarningCommentRector;
use Neos\Rector\Generic\Rules\FusionNodePropertyPathToWarningCommentRector;
use Neos\Rector\Generic\Rules\FusionPrototypeNameAddCommentRector;
use Neos\Rector\Generic\Rules\FusionReplacePrototypeNameRector;
Expand Down Expand Up @@ -119,6 +120,7 @@
new FusionPrototypeNameReplacement('Neos.Fusion:RawCollection', 'Neos.Fusion:Map',
'Migration of Neos.Fusion:RawCollection to Neos.Fusion:Map needs manual action. The key `children` has to be renamed to `items` which cannot be done automatically'
),
new FusionPrototypeNameReplacement('Neos.Neos:PrimaryContent', 'Neos.Neos:ContentCollection', '"Neos.Neos:PrimaryContent" has been removed without a complete replacement. We replaced all usages with "Neos.Neos:ContentCollection" but not the prototype definition. Please check the replacements and if you have overridden the "Neos.Neos:PrimaryContent" prototype and rewrite it for your needs.', true),
]);


Expand Down Expand Up @@ -258,7 +260,7 @@

// getOtherNodeVariants()

$rectorConfig->ruleWithConfiguration(FusionNodePropertyPathToWarningCommentRector::class, $fusionFlowQueryPropertyToComments);
$rectorConfig->ruleWithConfiguration(FusionFlowQueryNodePropertyToWarningCommentRector::class, $fusionFlowQueryPropertyToComments);


/**
Expand Down Expand Up @@ -393,16 +395,11 @@
$rectorConfig->rule(WorkspaceGetNameRector::class);

/**
* Neos.Neos:PrimaryContent
* Neos.Fusion:Attributes
*/
$rectorConfig->ruleWithConfiguration(FusionPrototypeNameAddCommentRector::class, [
new FusionPrototypeNameAddComment('Neos.Fusion:Attributes', 'TODO 9.0 migration: Neos.Fusion:Attributes has been removed without a replacement. You need to replace it by the property attributes in Neos.Fusion:Tag')
]);
$rectorConfig->ruleWithConfiguration(FusionReplacePrototypeNameRector::class, [
new FusionPrototypeNameReplacement('Neos.Neos:PrimaryContent', 'Neos.Neos:ContentCollection', '"Neos.Neos:PrimaryContent" has been removed without a complete replacement. We replaced all usages with "Neos.Neos:ContentCollection" but not the prototype definition. Please check the replacements and if you have overridden the "Neos.Neos:PrimaryContent" prototype and rewrite it for your needs.', true),
]);


$rectorConfig->rule(ContentRepositoryUtilityRenderValidNodeNameRector::class);

Expand Down Expand Up @@ -464,7 +461,10 @@
\Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateIds::class => 'toJson()',
]);

$rectorConfig->ruleWithConfiguration(RenameClassRector::class, [
// We can only add one rule per class name. As workaround, we need to alias the RenameClassRector, so we are able to
// add this rule twice.
class_alias(RenameClassRector::class, \Alias\RenameClassRectorLegacy::class);
$rectorConfig->ruleWithConfiguration(\Alias\RenameClassRectorLegacy::class, [
NodeLegacyStub::class => Node::class,
]);

Expand Down
5 changes: 4 additions & 1 deletion tests/Sets/ContentRepository90/ContentRepository90Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ public function test(string $fileInfo): void
*/
public function provideData(): \Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture', '*.fusion.inc');
$append = new \AppendIterator();
$append->append($this->yieldFilesFromDirectory(__DIR__ . '/Fixture'));
$append->append($this->yieldFilesFromDirectory(__DIR__ . '/Fixture', '*.fusion.inc'));
return $append;
}

public function provideConfigFilePath(): string
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

namespace Neos\Rector\Test;

use Neos\ContentRepository\Domain\Model\NodeInterface;
use \Neos\ContentRepository\Domain\Model\Node;

class SomeClass extends AnotherClass
{

public function foo(Node $node, NodeInterface $targetNode)
{
/** @var array<Node> $childNodes */
$childNodes = $node->getChildNodes();

$parent = $targetNode->getParent();
}

}

-----
<?php

namespace Neos\Rector\Test;

use Neos\ContentRepository\Domain\Model\NodeInterface;
use \Neos\ContentRepository\Domain\Model\Node;

class SomeClass extends AnotherClass
{

#[\Neos\Flow\Annotations\Inject]
protected \Neos\ContentRepositoryRegistry\ContentRepositoryRegistry $contentRepositoryRegistry;
public function foo(\Neos\ContentRepository\Core\Projection\ContentGraph\Node $node, \Neos\ContentRepository\Core\Projection\ContentGraph\Node $targetNode)
{
$subgraph = $this->contentRepositoryRegistry->subgraphForNode($node);
// TODO 9.0 migration: Try to remove the iterator_to_array($nodes) call.

/** @var array<\Neos\ContentRepository\Core\Projection\ContentGraph\Node> $childNodes */
$childNodes = iterator_to_array($subgraph->findChildNodes($node->nodeAggregateId, \Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindChildNodesFilter::create()));
$subgraph = $this->contentRepositoryRegistry->subgraphForNode($targetNode);

$parent = $subgraph->findParentNode($targetNode->nodeAggregateId);
}

}

Loading