Repository: sabbelasichon/typo3-rector (php)

Issue:
[BUG] ConstantsToBackedEnumValueRector migrates incorrectly
### Minimal PHP Code Causing Issue

This rule migrates the following constants to enums:

`TYPO3\CMS\Core\Resource\File::FILETYPE_*`

Example:

```diff
- TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE => [
+ TYPO3\CMS\Core\Resource\FileType::IMAGE => [
```

The problem is that those constants were integers and the replacement is an enum (object) with a corresponding integer value. This however breaks most, if not all code.

### Applied rules

`\Ssch\TYPO3Rector\General\Renaming\ConstantsToBackedEnumValueRector`

### Expected Behaviour

Expected behaviour would be to replace int constant usages with int enum values:

```diff
- TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE => [
+ TYPO3\CMS\Core\Resource\FileType::IMAGE->value => [
```

### Package Version

2.0.7

### PHP Version

8.2.0

### TYPO3 Version

13.4.0

### Notes

See: #4060 
See: #3698
See: #4449
See: #3698

Pull request:
[BUGFIX] Split migration to enums and enum values
Fixes #4473
Related: #4449

Patch:
diff --git a/config/v13/typo3-130.php b/config/v13/typo3-130.php
index 05f67656..ea610dce 100644
--- a/config/v13/typo3-130.php
+++ b/config/v13/typo3-130.php
@@ -4,6 +4,7 @@ declare(strict_types=1);
 
 use Rector\Config\RectorConfig;
 use Rector\Renaming\ValueObject\RenameClassAndConstFetch;
+use Ssch\TYPO3Rector\General\Renaming\ConstantsToBackedEnumRector;
 use Ssch\TYPO3Rector\General\Renaming\ConstantsToBackedEnumValueRector;
 use Ssch\TYPO3Rector\General\Renaming\RenameAttributeRector;
 use Ssch\TYPO3Rector\General\Renaming\ValueObject\RenameAttribute;
@@ -26,7 +27,42 @@ return static function (RectorConfig $rectorConfig): void {
     $rectorConfig->singleton(StrictTypesPersistenceManagerRector::class);
     $rectorConfig->singleton(UseStrictTypesInExtbaseActionControllerRector::class);
 
+    $rectorConfig->ruleWithConfiguration(ConstantsToBackedEnumRector::class, [
+        // See https://github.com/sabbelasichon/typo3-rector/issues/3698
+        new RenameClassAndConstFetch(
+            'TYPO3\CMS\Core\Imaging\Icon',
+            'SIZE_DEFAULT',
+            'TYPO3\CMS\Core\Imaging\IconSize',
+            'DEFAULT'
+        ),
+        new RenameClassAndConstFetch(
+            'TYPO3\CMS\Core\Imaging\Icon',
+            'SIZE_SMALL',
+            'TYPO3\CMS\Core\Imaging\IconSize',
+            'SMALL'
+        ),
+        new RenameClassAndConstFetch(
+            'TYPO3\CMS\Core\Imaging\Icon',
+            'SIZE_MEDIUM',
+            'TYPO3\CMS\Core\Imaging\IconSize',
+            'MEDIUM'
+        ),
+        new RenameClassAndConstFetch(
+            'TYPO3\CMS\Core\Imaging\Icon',
+            'SIZE_LARGE',
+            'TYPO3\CMS\Core\Imaging\IconSize',
+            'LARGE'
+        ),
+        new RenameClassAndConstFetch(
+            'TYPO3\CMS\Core\Imaging\Icon',
+            'SIZE_MEGA',
+            'TYPO3\CMS\Core\Imaging\IconSize',
+            'MEGA'
+        ),
+    ]);
+
     $rectorConfig->ruleWithConfiguration(ConstantsToBackedEnumValueRector::class, [
+        // see https://github.com/sabbelasichon/typo3-rector/issues/3704
         new RenameClassAndConstFetch(
             'TYPO3\CMS\Core\Resource\AbstractFile',
             'FILETYPE_UNKNOWN',
@@ -64,37 +100,9 @@ return static function (RectorConfig $rectorConfig): void {
             'APPLICATION'
         ),
 
-        new RenameClassAndConstFetch(
-            'TYPO3\CMS\Core\Imaging\Icon',
-            'SIZE_DEFAULT',
-            'TYPO3\CMS\Core\Imaging\IconSize',
-            'DEFAULT'
-        ),
-        new RenameClassAndConstFetch(
-            'TYPO3\CMS\Core\Imaging\Icon',
-            'SIZE_SMALL',
-            'TYPO3\CMS\Core\Imaging\IconSize',
-            'SMALL'
-        ),
-        new RenameClassAndConstFetch(
-            'TYPO3\CMS\Core\Imaging\Icon',
-            'SIZE_MEDIUM',
-            'TYPO3\CMS\Core\Imaging\IconSize',
-            'MEDIUM'
-        ),
-        new RenameClassAndConstFetch(
-            'TYPO3\CMS\Core\Imaging\Icon',
-            'SIZE_LARGE',
-            'TYPO3\CMS\Core\Imaging\IconSize',
-            'LARGE'
-        ),
-        new RenameClassAndConstFetch(
-            'TYPO3\CMS\Core\Imaging\Icon',
-            'SIZE_MEGA',
-            'TYPO3\CMS\Core\Imaging\IconSize',
-            'MEGA'
-        ),
-        new RenameClassAndConstFetch(
+        // see https://github.com/sabbelasichon/typo3-rector/issues/3650
+        // FIXME: This causes an infinite loop
+        /*new RenameClassAndConstFetch(
             'TYPO3\CMS\Core\Authentication\LoginType',
             'LOGIN',
             'TYPO3\CMS\Core\Authentication\LoginType',
@@ -105,7 +113,7 @@ return static function (RectorConfig $rectorConfig): void {
             'LOGOUT',
             'TYPO3\CMS\Core\Authentication\LoginType',
             'LOGOUT'
-        ),
+        ),*/
     ]);
     $rectorConfig->ruleWithConfiguration(RenameAttributeRector::class, [
         new RenameAttribute('TYPO3\CMS\Backend\Attribute\Controller', 'TYPO3\CMS\Backend\Attribute\AsController'),
diff --git a/rules/General/Renaming/ConstantsToBackedEnumRector.php b/rules/General/Renaming/ConstantsToBackedEnumRector.php
new file mode 100644
index 00000000..26eed660
--- /dev/null
+++ b/rules/General/Renaming/ConstantsToBackedEnumRector.php
@@ -0,0 +1,103 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Ssch\TYPO3Rector\General\Renaming;
+
+use PhpParser\Node;
+use PhpParser\Node\Expr\ClassConstFetch;
+use Rector\Contract\Rector\ConfigurableRectorInterface;
+use Rector\Rector\AbstractRector;
+use Rector\Renaming\ValueObject\RenameClassAndConstFetch;
+use Rector\ValueObject\PhpVersionFeature;
+use Rector\VersionBonding\Contract\MinPhpVersionInterface;
+use Ssch\TYPO3Rector\Contract\NoChangelogRequiredInterface;
+use Symplify\RuleDocGenerator\Contract\DocumentedRuleInterface;
+use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
+use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
+use Webmozart\Assert\Assert;
+
+/**
+ * @see \Ssch\TYPO3Rector\Tests\Rector\General\Renaming\ConstantsToBackedEnumRector\ConstantsToBackedEnumRectorTest
+ */
+final class ConstantsToBackedEnumRector extends AbstractRector implements ConfigurableRectorInterface, MinPhpVersionInterface, NoChangelogRequiredInterface, DocumentedRuleInterface
+{
+    /**
+     * @var RenameClassAndConstFetch[]
+     */
+    private array $renameClassConstFetches = [];
+
+    /**
+     * @param array<int, RenameClassAndConstFetch> $configuration
+     */
+    public function configure(array $configuration): void
+    {
+        Assert::allIsAOf($configuration, RenameClassAndConstFetch::class);
+        $this->renameClassConstFetches = $configuration;
+    }
+
+    public function getRuleDefinition(): RuleDefinition
+    {
+        return new RuleDefinition('Migrate constants to enum class', [
+            new ConfiguredCodeSample(
+                <<<'CODE_SAMPLE'
+\TYPO3\CMS\Core\Imaging\Icon::SIZE_DEFAULT
+\TYPO3\CMS\Core\Imaging\Icon::SIZE_SMALL
+\TYPO3\CMS\Core\Imaging\Icon::SIZE_MEDIUM
+\TYPO3\CMS\Core\Imaging\Icon::SIZE_LARGE
+\TYPO3\CMS\Core\Imaging\Icon::SIZE_MEGA
+CODE_SAMPLE
+                ,
+                <<<'CODE_SAMPLE'
+TYPO3\CMS\Core\Imaging\IconSize::DEFAULT
+TYPO3\CMS\Core\Imaging\IconSize::SMALL
+TYPO3\CMS\Core\Imaging\IconSize::MEDIUM
+TYPO3\CMS\Core\Imaging\IconSize::LARGE
+TYPO3\CMS\Core\Imaging\IconSize::MEGA
+CODE_SAMPLE
+                ,
+                [
+                    new RenameClassAndConstFetch(
+                        'TYPO3\CMS\Core\Imaging\Icon',
+                        'SIZE_MEDIUM',
+                        'TYPO3\CMS\Core\Imaging\IconSize',
+                        'MEDIUM'
+                    ),
+                ]
+            ),
+        ]);
+    }
+
+    public function getNodeTypes(): array
+    {
+        return [ClassConstFetch::class];
+    }
+
+    /**
+     * @param ClassConstFetch $node
+     */
+    public function refactor(Node $node): ?Node
+    {
+        foreach ($this->renameClassConstFetches as $renameClassConstFetch) {
+            if (! $this->isName($node->name, $renameClassConstFetch->getOldConstant())) {
+                continue;
+            }
+
+            if (! $this->isObjectType($node->class, $renameClassConstFetch->getOldObjectType())) {
+                continue;
+            }
+
+            return $this->nodeFactory->createClassConstFetch(
+                $renameClassConstFetch->getNewClass(),
+                $renameClassConstFetch->getNewConstant()
+            );
+        }
+
+        return null;
+    }
+
+    public function provideMinPhpVersion(): int
+    {
+        return PhpVersionFeature::ENUM;
+    }
+}
diff --git a/rules/General/Renaming/ConstantsToBackedEnumValueRector.php b/rules/General/Renaming/ConstantsToBackedEnumValueRector.php
index af8ffe66..df73e692 100644
--- a/rules/General/Renaming/ConstantsToBackedEnumValueRector.php
+++ b/rules/General/Renaming/ConstantsToBackedEnumValueRector.php
@@ -6,6 +6,7 @@ namespace Ssch\TYPO3Rector\General\Renaming;
 
 use PhpParser\Node;
 use PhpParser\Node\Expr\ClassConstFetch;
+use PhpParser\Node\Expr\PropertyFetch;
 use Rector\Contract\Rector\ConfigurableRectorInterface;
 use Rector\Rector\AbstractRector;
 use Rector\Renaming\ValueObject\RenameClassAndConstFetch;
@@ -38,22 +39,32 @@ final class ConstantsToBackedEnumValueRector extends AbstractRector implements C
 
     public function getRuleDefinition(): RuleDefinition
     {
-        return new RuleDefinition('Migrate all FILETYPE_* constants from AbstractFile to FileType enum class', [
+        return new RuleDefinition('Migrate constants to enum class values', [
             new ConfiguredCodeSample(
                 <<<'CODE_SAMPLE'
-\TYPO3\CMS\Core\Resource\AbstractFile::FILETYPE_UNKNOWN;
+\TYPO3\CMS\Core\Resource\AbstractFile::FILETYPE_UNKNOWN
+\TYPO3\CMS\Core\Resource\AbstractFile::FILETYPE_TEXT
+\TYPO3\CMS\Core\Resource\AbstractFile::FILETYPE_IMAGE
+\TYPO3\CMS\Core\Resource\AbstractFile::FILETYPE_AUDIO
+\TYPO3\CMS\Core\Resource\AbstractFile::FILETYPE_VIDEO
+\TYPO3\CMS\Core\Resource\AbstractFile::FILETYPE_APPLICATION
 CODE_SAMPLE
                 ,
                 <<<'CODE_SAMPLE'
-\TYPO3\CMS\Core\Resource\FileType::UNKNOWN;
+\TYPO3\CMS\Core\Resource\FileType::UNKNOWN->value
+\TYPO3\CMS\Core\Resource\FileType::TEXT->value
+\TYPO3\CMS\Core\Resource\FileType::IMAGE->value
+\TYPO3\CMS\Core\Resource\FileType::AUDIO->value
+\TYPO3\CMS\Core\Resource\FileType::VIDEO->value
+\TYPO3\CMS\Core\Resource\FileType::APPLICATION->value
 CODE_SAMPLE
                 ,
                 [
                     new RenameClassAndConstFetch(
-                        'TYPO3\CMS\Core\Imaging\Icon',
-                        'SIZE_MEDIUM',
-                        'TYPO3\CMS\Core\Imaging\IconSize',
-                        'MEDIUM'
+                        '\TYPO3\CMS\Core\Resource\AbstractFile',
+                        'FILETYPE_UNKNOWN',
+                        '\TYPO3\CMS\Core\Resource\FileType',
+                        'UNKNOWN'
                     ),
                 ]
             ),
@@ -79,10 +90,12 @@ CODE_SAMPLE
                 continue;
             }
 
-            return $this->nodeFactory->createClassConstFetch(
+            $enumConstFetch = $this->nodeFactory->createClassConstFetch(
                 $renameClassConstFetch->getNewClass(),
                 $renameClassConstFetch->getNewConstant()
             );
+
+            return new PropertyFetch($enumConstFetch, 'value');
         }
 
         return null;
diff --git a/stubs/TYPO3/CMS/Core/Authentication/LoginType.php b/stubs/TYPO3/CMS/Core/Authentication/LoginType.php
new file mode 100644
index 00000000..6b7610c1
--- /dev/null
+++ b/stubs/TYPO3/CMS/Core/Authentication/LoginType.php
@@ -0,0 +1,17 @@
+<?php
+
+declare(strict_types=1);
+
+namespace TYPO3\CMS\Core\Authentication;
+
+use TYPO3\CMS\Core\Type\Enumeration;
+
+if (class_exists('TYPO3\CMS\Core\Authentication\LoginType')) {
+    return;
+}
+
+class LoginType extends Enumeration
+{
+    public const LOGIN = 'login';
+    public const LOGOUT = 'logout';
+}
diff --git a/stubs/TYPO3/CMS/Core/Resource/AbstractFile.php b/stubs/TYPO3/CMS/Core/Resource/AbstractFile.php
index b1b4f7e6..9ffdcb03 100644
--- a/stubs/TYPO3/CMS/Core/Resource/AbstractFile.php
+++ b/stubs/TYPO3/CMS/Core/Resource/AbstractFile.php
@@ -1,4 +1,5 @@
 <?php
+
 declare(strict_types=1);
 
 namespace TYPO3\CMS\Core\Resource;
@@ -24,26 +25,21 @@ abstract class AbstractFile implements FileInterface
 
     public function getIdentifier(): string
     {
-        // TODO: Implement getIdentifier() method.
     }
 
     public function getName(): string
     {
-        // TODO: Implement getName() method.
     }
 
     public function getStorage(): ResourceStorage
     {
-        // TODO: Implement getStorage() method.
     }
 
     public function getHashedIdentifier(): string
     {
-        // TODO: Implement getHashedIdentifier() method.
     }
 
     public function getParentFolder(): FolderInterface
     {
-        // TODO: Implement getParentFolder() method.
     }
 }
diff --git a/stubs/TYPO3/CMS/Core/Type/Enumeration.php b/stubs/TYPO3/CMS/Core/Type/Enumeration.php
new file mode 100644
index 00000000..1d0989f3
--- /dev/null
+++ b/stubs/TYPO3/CMS/Core/Type/Enumeration.php
@@ -0,0 +1,13 @@
+<?php
+
+declare(strict_types=1);
+
+namespace TYPO3\CMS\Core\Type;
+
+if (class_exists('TYPO3\CMS\Core\Type\Enumeration')) {
+    return;
+}
+
+abstract class Enumeration
+{
+}


Test patch:
diff --git a/tests/Rector/General/Renaming/ConstantsToBackedEnumRector/ConstantsToBackedEnumRectorTest.php b/tests/Rector/General/Renaming/ConstantsToBackedEnumRector/ConstantsToBackedEnumRectorTest.php
new file mode 100644
index 00000000..78244530
--- /dev/null
+++ b/tests/Rector/General/Renaming/ConstantsToBackedEnumRector/ConstantsToBackedEnumRectorTest.php
@@ -0,0 +1,31 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Ssch\TYPO3Rector\Tests\Rector\General\Renaming\ConstantsToBackedEnumRector;
+
+use Rector\Testing\PHPUnit\AbstractRectorTestCase;
+
+final class ConstantsToBackedEnumRectorTest extends AbstractRectorTestCase
+{
+    /**
+     * @dataProvider provideData()
+     */
+    public function test(string $filePath): void
+    {
+        $this->doTestFile($filePath);
+    }
+
+    /**
+     * @return \Iterator<array<string>>
+     */
+    public static function provideData(): \Iterator
+    {
+        return self::yieldFilesFromDirectory(__DIR__ . '/Fixture');
+    }
+
+    public function provideConfigFilePath(): string
+    {
+        return __DIR__ . '/config/configured_rule.php';
+    }
+}
diff --git a/tests/Rector/General/Renaming/ConstantsToBackedEnumRector/Fixture/icon_types.php.inc b/tests/Rector/General/Renaming/ConstantsToBackedEnumRector/Fixture/icon_types.php.inc
new file mode 100644
index 00000000..fd5c887b
--- /dev/null
+++ b/tests/Rector/General/Renaming/ConstantsToBackedEnumRector/Fixture/icon_types.php.inc
@@ -0,0 +1,24 @@
+<?php
+
+use TYPO3\CMS\Core\Imaging\Icon;
+
+$icon1 = Icon::SIZE_DEFAULT;
+$icon2 = Icon::SIZE_SMALL;
+$icon3 = Icon::SIZE_MEDIUM;
+$icon4 = Icon::SIZE_LARGE;
+$icon5 = Icon::SIZE_MEGA;
+
+?>
+-----
+<?php
+
+use TYPO3\CMS\Core\Imaging\IconSize;
+use TYPO3\CMS\Core\Imaging\Icon;
+
+$icon1 = IconSize::DEFAULT;
+$icon2 = IconSize::SMALL;
+$icon3 = IconSize::MEDIUM;
+$icon4 = IconSize::LARGE;
+$icon5 = IconSize::MEGA;
+
+?>
diff --git a/tests/Rector/General/Renaming/ConstantsToBackedEnumRector/Source/MyOtherFileType.php b/tests/Rector/General/Renaming/ConstantsToBackedEnumRector/Source/MyOtherFileType.php
new file mode 100644
index 00000000..1e5053f7
--- /dev/null
+++ b/tests/Rector/General/Renaming/ConstantsToBackedEnumRector/Source/MyOtherFileType.php
@@ -0,0 +1,10 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Ssch\TYPO3Rector\Tests\Rector\General\Renaming\ConstantsToBackedEnumRector\Source;
+
+final class MyOtherFileType
+{
+    public const FILETYPE_UNKNOWN = 0;
+}
diff --git a/tests/Rector/General/Renaming/ConstantsToBackedEnumRector/config/configured_rule.php b/tests/Rector/General/Renaming/ConstantsToBackedEnumRector/config/configured_rule.php
new file mode 100644
index 00000000..2b3b6a55
--- /dev/null
+++ b/tests/Rector/General/Renaming/ConstantsToBackedEnumRector/config/configured_rule.php
@@ -0,0 +1,45 @@
+<?php
+
+declare(strict_types=1);
+
+use Rector\Config\RectorConfig;
+use Rector\Renaming\ValueObject\RenameClassAndConstFetch;
+use Rector\ValueObject\PhpVersion;
+use Ssch\TYPO3Rector\General\Renaming\ConstantsToBackedEnumRector;
+
+return static function (RectorConfig $rectorConfig): void {
+    $rectorConfig->import(__DIR__ . '/../../../../../../config/config_test.php');
+    $rectorConfig->phpVersion(PhpVersion::PHP_81);
+    $rectorConfig->ruleWithConfiguration(ConstantsToBackedEnumRector::class, [
+        new RenameClassAndConstFetch(
+            'TYPO3\CMS\Core\Imaging\Icon',
+            'SIZE_DEFAULT',
+            'TYPO3\CMS\Core\Imaging\IconSize',
+            'DEFAULT'
+        ),
+        new RenameClassAndConstFetch(
+            'TYPO3\CMS\Core\Imaging\Icon',
+            'SIZE_SMALL',
+            'TYPO3\CMS\Core\Imaging\IconSize',
+            'SMALL'
+        ),
+        new RenameClassAndConstFetch(
+            'TYPO3\CMS\Core\Imaging\Icon',
+            'SIZE_MEDIUM',
+            'TYPO3\CMS\Core\Imaging\IconSize',
+            'MEDIUM'
+        ),
+        new RenameClassAndConstFetch(
+            'TYPO3\CMS\Core\Imaging\Icon',
+            'SIZE_LARGE',
+            'TYPO3\CMS\Core\Imaging\IconSize',
+            'LARGE'
+        ),
+        new RenameClassAndConstFetch(
+            'TYPO3\CMS\Core\Imaging\Icon',
+            'SIZE_MEGA',
+            'TYPO3\CMS\Core\Imaging\IconSize',
+            'MEGA'
+        ),
+    ]);
+};
diff --git a/tests/Rector/General/Renaming/ConstantsToBackedEnumValueRector/Fixture/abstract_file_types.php.inc b/tests/Rector/General/Renaming/ConstantsToBackedEnumValueRector/Fixture/abstract_file_types.php.inc
index 4b7e2b10..718d82f5 100644
--- a/tests/Rector/General/Renaming/ConstantsToBackedEnumValueRector/Fixture/abstract_file_types.php.inc
+++ b/tests/Rector/General/Renaming/ConstantsToBackedEnumValueRector/Fixture/abstract_file_types.php.inc
@@ -1,7 +1,6 @@
 <?php
 
 use Ssch\TYPO3Rector\Tests\Rector\General\Renaming\ConstantsToBackedEnumValueRector\Source\MyOtherFileType;
-use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Resource\AbstractFile;
 
 $type1 = AbstractFile::FILETYPE_UNKNOWN;
@@ -13,35 +12,21 @@ $type6 = AbstractFile::FILETYPE_APPLICATION;
 $otherConst = AbstractFile::OTHER_CONSTANT;
 $typeFromOtherClass = MyOtherFileType::FILETYPE_UNKNOWN;
 
-$icon1 = Icon::SIZE_DEFAULT;
-$icon2 = Icon::SIZE_SMALL;
-$icon3 = Icon::SIZE_MEDIUM;
-$icon4 = Icon::SIZE_LARGE;
-$icon5 = Icon::SIZE_MEGA;
-
 ?>
 -----
 <?php
 
 use TYPO3\CMS\Core\Resource\FileType;
-use TYPO3\CMS\Core\Imaging\IconSize;
 use Ssch\TYPO3Rector\Tests\Rector\General\Renaming\ConstantsToBackedEnumValueRector\Source\MyOtherFileType;
-use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Resource\AbstractFile;
 
-$type1 = FileType::UNKNOWN;
-$type2 = FileType::TEXT;
-$type3 = FileType::IMAGE;
-$type4 = FileType::AUDIO;
-$type5 = FileType::VIDEO;
-$type6 = FileType::APPLICATION;
+$type1 = FileType::UNKNOWN->value;
+$type2 = FileType::TEXT->value;
+$type3 = FileType::IMAGE->value;
+$type4 = FileType::AUDIO->value;
+$type5 = FileType::VIDEO->value;
+$type6 = FileType::APPLICATION->value;
 $otherConst = AbstractFile::OTHER_CONSTANT;
 $typeFromOtherClass = MyOtherFileType::FILETYPE_UNKNOWN;
 
-$icon1 = IconSize::DEFAULT;
-$icon2 = IconSize::SMALL;
-$icon3 = IconSize::MEDIUM;
-$icon4 = IconSize::LARGE;
-$icon5 = IconSize::MEGA;
-
 ?>
diff --git a/tests/Rector/General/Renaming/ConstantsToBackedEnumValueRector/Fixture/login_types.php.broken b/tests/Rector/General/Renaming/ConstantsToBackedEnumValueRector/Fixture/login_types.php.broken
new file mode 100644
index 00000000..b9322cf1
--- /dev/null
+++ b/tests/Rector/General/Renaming/ConstantsToBackedEnumValueRector/Fixture/login_types.php.broken
@@ -0,0 +1,17 @@
+<?php
+
+use TYPO3\CMS\Core\Authentication\LoginType;
+
+$loginType = LoginType::LOGIN->value;
+$logoutType = LoginType::LOGOUT;
+
+?>
+-----
+<?php
+
+use TYPO3\CMS\Core\Authentication\LoginType;
+
+$loginType = LoginType::LOGIN->value;
+$logoutType = LoginType::LOGOUT->value;
+
+?>
diff --git a/tests/Rector/General/Renaming/ConstantsToBackedEnumValueRector/config/configured_rule.php b/tests/Rector/General/Renaming/ConstantsToBackedEnumValueRector/config/configured_rule.php
index 8e902fe4..8286e844 100644
--- a/tests/Rector/General/Renaming/ConstantsToBackedEnumValueRector/config/configured_rule.php
+++ b/tests/Rector/General/Renaming/ConstantsToBackedEnumValueRector/config/configured_rule.php
@@ -48,35 +48,18 @@ return static function (RectorConfig $rectorConfig): void {
             'APPLICATION'
         ),
 
-        new RenameClassAndConstFetch(
-            'TYPO3\CMS\Core\Imaging\Icon',
-            'SIZE_DEFAULT',
-            'TYPO3\CMS\Core\Imaging\IconSize',
-            'DEFAULT'
-        ),
-        new RenameClassAndConstFetch(
-            'TYPO3\CMS\Core\Imaging\Icon',
-            'SIZE_SMALL',
-            'TYPO3\CMS\Core\Imaging\IconSize',
-            'SMALL'
-        ),
-        new RenameClassAndConstFetch(
-            'TYPO3\CMS\Core\Imaging\Icon',
-            'SIZE_MEDIUM',
-            'TYPO3\CMS\Core\Imaging\IconSize',
-            'MEDIUM'
-        ),
-        new RenameClassAndConstFetch(
-            'TYPO3\CMS\Core\Imaging\Icon',
-            'SIZE_LARGE',
-            'TYPO3\CMS\Core\Imaging\IconSize',
-            'LARGE'
+        // FIXME: This causes an infinite loop
+        /*new RenameClassAndConstFetch(
+            'TYPO3\CMS\Core\Authentication\LoginType',
+            'LOGIN',
+            'TYPO3\CMS\Core\Authentication\LoginType',
+            'LOGIN'
         ),
         new RenameClassAndConstFetch(
-            'TYPO3\CMS\Core\Imaging\Icon',
-            'SIZE_MEGA',
-            'TYPO3\CMS\Core\Imaging\IconSize',
-            'MEGA'
-        ),
+            'TYPO3\CMS\Core\Authentication\LoginType',
+            'LOGOUT',
+            'TYPO3\CMS\Core\Authentication\LoginType',
+            'LOGOUT'
+        ),*/
     ]);
 };