Skip to content

Commit

Permalink
Merge pull request #91 from neos/bugfix/configure-rules-once
Browse files Browse the repository at this point in the history
BUGFIX: Configure each rule once, as multiple definitions just override the previous ones
  • Loading branch information
dlubitz authored Nov 8, 2024
2 parents 071852a + 236f899 commit 8887c06
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 8 deletions.
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 @@ -257,7 +259,7 @@

// getOtherNodeVariants()

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


/**
Expand Down Expand Up @@ -392,16 +394,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 @@ -463,7 +460,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);
}

}

0 comments on commit 8887c06

Please sign in to comment.