Repository: sabbelasichon/typo3-rector (php)

Issue:
max property is being removed for every type input
# Bug Report

<!-- First, thank you for reporting a bug. That takes time and we appreciate that! -->

| Subject        | Details                                                         |
| :------------- | :---------------------------------------------------------------|
| Rector version | v0.17.0             |

<!-- Please describe your problem here. -->

## Minimal PHP Code Causing Issue

```
'config' => [
    'type' => 'input',
    'max' => 255,
],
```

## Expected Behaviour

Normal input fields should be allowed to define a max property, right?
I think "MigrateToEmailTypeRector" is used for this, and it shouldn't.


Pull request description:
[BUGFIX] Keep max property for other input types
Resolves #3925

Patch:
diff --git a/src/Rector/v12/v0/flexform/MigrateEvalIntAndDouble2ToTypeNumberFlexFormRector.php b/src/Rector/v12/v0/flexform/MigrateEvalIntAndDouble2ToTypeNumberFlexFormRector.php
index 14ba5c20..c1249e9b 100644
--- a/src/Rector/v12/v0/flexform/MigrateEvalIntAndDouble2ToTypeNumberFlexFormRector.php
+++ b/src/Rector/v12/v0/flexform/MigrateEvalIntAndDouble2ToTypeNumberFlexFormRector.php
@@ -120,7 +120,9 @@ CODE_SAMPLE
             return;
         }
 
-        if (! StringUtility::inList($evalListValue, self::INT) && ! StringUtility::inList($evalListValue, self::DOUBLE2)) {
+        if (! StringUtility::inList($evalListValue, self::INT)
+            && ! StringUtility::inList($evalListValue, self::DOUBLE2)
+        ) {
             return;
         }
 
diff --git a/src/Rector/v12/v0/tca/MigrateEvalIntAndDouble2ToTypeNumberRector.php b/src/Rector/v12/v0/tca/MigrateEvalIntAndDouble2ToTypeNumberRector.php
index 51c36781..0c93ad32 100644
--- a/src/Rector/v12/v0/tca/MigrateEvalIntAndDouble2ToTypeNumberRector.php
+++ b/src/Rector/v12/v0/tca/MigrateEvalIntAndDouble2ToTypeNumberRector.php
@@ -103,7 +103,9 @@ CODE_SAMPLE
             return;
         }
 
-        if (! StringUtility::inList($evalListValue, self::INT) && ! StringUtility::inList($evalListValue, self::DOUBLE2)) {
+        if (! StringUtility::inList($evalListValue, self::INT)
+            && ! StringUtility::inList($evalListValue, self::DOUBLE2)
+        ) {
             return;
         }
 
diff --git a/src/Rector/v12/v0/tca/MigrateToEmailTypeRector.php b/src/Rector/v12/v0/tca/MigrateToEmailTypeRector.php
index bef7c239..7f9a0027 100644
--- a/src/Rector/v12/v0/tca/MigrateToEmailTypeRector.php
+++ b/src/Rector/v12/v0/tca/MigrateToEmailTypeRector.php
@@ -81,8 +81,6 @@ CODE_SAMPLE
             return;
         }
 
-        $this->removeArrayItemFromArrayByKey($configArray, 'max');
-
         if (! $this->hasKey($configArray, 'eval')) {
             return;
         }
@@ -103,6 +101,8 @@ CODE_SAMPLE
             return;
         }
 
+        $this->removeArrayItemFromArrayByKey($configArray, 'max');
+
         $evalList = ArrayUtility::trimExplode(',', $evalListValue, true);
 
         // Remove "email" and "trim" from $evalList


Test patch:
diff --git a/tests/Rector/v12/v0/tca/MigrateToEmailTypeRector/Fixture/fixture_keep_max_for_other_types.php.inc b/tests/Rector/v12/v0/tca/MigrateToEmailTypeRector/Fixture/fixture_keep_max_for_other_types.php.inc
new file mode 100644
index 00000000..d3a2420c
--- /dev/null
+++ b/tests/Rector/v12/v0/tca/MigrateToEmailTypeRector/Fixture/fixture_keep_max_for_other_types.php.inc
@@ -0,0 +1,39 @@
+<?php
+
+namespace Ssch\TYPO3Rector\Tests\Rector\v12\v0\tca\MigrateToEmailTypeRector\Fixture;
+
+return [
+    'ctrl' => [],
+    'columns' => [
+        'email_field' => [
+            'label' => 'Text',
+            'config' => [
+                'type' => 'input',
+                'eval' => 'trim',
+                'max' => 255,
+            ],
+        ],
+    ],
+];
+
+?>
+-----
+<?php
+
+namespace Ssch\TYPO3Rector\Tests\Rector\v12\v0\tca\MigrateToEmailTypeRector\Fixture;
+
+return [
+    'ctrl' => [],
+    'columns' => [
+        'email_field' => [
+            'label' => 'Text',
+            'config' => [
+                'type' => 'input',
+                'eval' => 'trim',
+                'max' => 255,
+            ],
+        ],
+    ],
+];
+
+?>