From 0bd8ac117eb414c3d2a1ee1d7e2d31a151d76723 Mon Sep 17 00:00:00 2001 From: Karsten Dambekalns Date: Tue, 14 May 2024 14:26:04 +0200 Subject: [PATCH 1/3] TASK: Code cleanup --- config/set/contentrepository-90.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config/set/contentrepository-90.php b/config/set/contentrepository-90.php index fa10b9c..f7ee8e2 100644 --- a/config/set/contentrepository-90.php +++ b/config/set/contentrepository-90.php @@ -110,10 +110,10 @@ ]); - /** @var $methodCallToPropertyFetches MethodCallToPropertyFetch[] */ + /** @var MethodCallToPropertyFetch[] $methodCallToPropertyFetches */ $methodCallToPropertyFetches = []; - /** @var $methodCallToWarningComments MethodCallToWarningComment[] */ + /** @var MethodCallToWarningComment[] $methodCallToWarningComments */ $methodCallToWarningComments = []; @@ -382,8 +382,8 @@ * Neos.Fusion:Attributes */ $rectorConfig->ruleWithConfiguration(FusionPrototypeNameAddComment::class, [ - new FusionPrototypeNameAddComment("Neos.Neos:PrimaryContent", 'TODO 9.0 migration: You need to refactor "Neos.Neos:PrimaryContent" to use "Neos.Neos:ContentCollection" instead.'), - 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') + new FusionPrototypeNameAddComment('Neos.Neos:PrimaryContent', 'TODO 9.0 migration: You need to refactor "Neos.Neos:PrimaryContent" to use "Neos.Neos:ContentCollection" instead.'), + 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') ]); /** From 8a5a617ad2b66369a7c0640bb743468cd11d15bf Mon Sep 17 00:00:00 2001 From: Karsten Dambekalns Date: Tue, 14 May 2024 14:28:50 +0200 Subject: [PATCH 2/3] BUGFIX: Fix error with rule configuration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes an error that slipped in with #52: ``` [ERROR] Expected an instance of this class or to this class among its parents "Rector\Core\Contract\Rector\RectorInterface". Got: "Neos\Rector\Generic\ValueObject\FusionPrototypeNameAddComment" in /…/Packages/Libraries/neos/rector/src/../config/set/contentrepository-90.php (which is being imported from "/…/rector.php"). ``` --- config/set/contentrepository-90.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/set/contentrepository-90.php b/config/set/contentrepository-90.php index f7ee8e2..5369cc1 100644 --- a/config/set/contentrepository-90.php +++ b/config/set/contentrepository-90.php @@ -48,6 +48,7 @@ use Neos\Rector\ContentRepository90\Rules\WorkspaceRepositoryCountByNameRector; use Neos\Rector\ContentRepository90\Rules\YamlDimensionConfigRector; use Neos\Rector\Generic\Rules\FusionNodePropertyPathToWarningCommentRector; +use Neos\Rector\Generic\Rules\FusionPrototypeNameAddCommentRector; use Neos\Rector\Generic\Rules\InjectServiceIfNeededRector; use Neos\Rector\Generic\Rules\MethodCallToWarningCommentRector; use Neos\Rector\Generic\Rules\RemoveInjectionsRector; @@ -381,7 +382,7 @@ * Neos.Neos:PrimaryContent * Neos.Fusion:Attributes */ - $rectorConfig->ruleWithConfiguration(FusionPrototypeNameAddComment::class, [ + $rectorConfig->ruleWithConfiguration(FusionPrototypeNameAddCommentRector::class, [ new FusionPrototypeNameAddComment('Neos.Neos:PrimaryContent', 'TODO 9.0 migration: You need to refactor "Neos.Neos:PrimaryContent" to use "Neos.Neos:ContentCollection" instead.'), 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') ]); From 5bc3f92dd66547b3c6f9216ce50c248f875b462c Mon Sep 17 00:00:00 2001 From: Karsten Dambekalns Date: Tue, 14 May 2024 14:30:10 +0200 Subject: [PATCH 3/3] BUGFIX: Initialize variable to empty array Fixes `Uncaught TypeError: count(): Argument #1 ($value)must be of type Countable|array, null given` when no comments were found. --- src/Generic/Rules/FusionPrototypeNameAddCommentRector.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Generic/Rules/FusionPrototypeNameAddCommentRector.php b/src/Generic/Rules/FusionPrototypeNameAddCommentRector.php index 1067e44..537c9e3 100644 --- a/src/Generic/Rules/FusionPrototypeNameAddCommentRector.php +++ b/src/Generic/Rules/FusionPrototypeNameAddCommentRector.php @@ -25,6 +25,7 @@ public function getRuleDefinition(): RuleDefinition public function refactorFileContent(string $fileContent): string { + $comments = []; foreach ($this->fusionPrototypeNameAddComments as $fusionPrototypeNameAddComment) { $matches = []; $pattern = '/(^|[=\s\(<\/])(' .$fusionPrototypeNameAddComment->name. ')([\s\{\)\/>]|$)/';