Skip to content

Commit 7779a03

Browse files
committed
[FEATURE] Add MigrateItemsIndexedKeysToAssociativeFractor
1 parent 1b7efac commit 7779a03

File tree

8 files changed

+525
-2
lines changed

8 files changed

+525
-2
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"ergebnis/composer-normalize": "^2.42",
3636
"phpstan/phpstan-phpunit": "^1.3",
3737
"phpunit/phpunit": "^10.5",
38-
"rector/rector": "^1.0",
38+
"rector/rector": "^1.2.6",
3939
"symplify/easy-coding-standard": "^12.3",
4040
"symplify/monorepo-builder": "^11.2",
4141
"symplify/rule-doc-generator": "12.1.3"

packages/typo3-fractor/config/typo3-12.php

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use a9f\Typo3Fractor\TYPO3v12\FlexForm\MigrateEmailFlagToEmailTypeFlexFormFractor;
66
use a9f\Typo3Fractor\TYPO3v12\FlexForm\MigrateEvalIntAndDouble2ToTypeNumberFlexFormFractor;
77
use a9f\Typo3Fractor\TYPO3v12\FlexForm\MigrateInternalTypeFolderToTypeFolderFlexFormFractor;
8+
use a9f\Typo3Fractor\TYPO3v12\FlexForm\MigrateItemsIndexedKeysToAssociativeFractor;
89
use a9f\Typo3Fractor\TYPO3v12\FlexForm\MigrateNullFlagFlexFormFractor;
910
use a9f\Typo3Fractor\TYPO3v12\FlexForm\MigratePasswordAndSaltedPasswordToPasswordTypeFlexFormFractor;
1011
use a9f\Typo3Fractor\TYPO3v12\FlexForm\MigrateRenderTypeColorpickerToTypeColorFlexFormFractor;
@@ -50,4 +51,5 @@
5051
$services->set(RenameConfigXhtmlDoctypeToDoctypeFractor::class);
5152
$services->set(RenameTcemainLinkHandlerMailKeyFractor::class);
5253
$services->set(UseConfigArrayForTSFEPropertiesFractor::class);
54+
$services->set(MigrateItemsIndexedKeysToAssociativeFractor::class);
5355
};

packages/typo3-fractor/docs/typo3-fractor-rules.md

+56-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 24 Rules Overview
1+
# 25 Rules Overview
22

33
## AbstractMessageGetSeverityFluidFractor
44

@@ -134,6 +134,61 @@ Migrates TCA internal_type into new new TCA type folder
134134

135135
<br>
136136

137+
## MigrateItemsIndexedKeysToAssociativeFractor
138+
139+
Migrates indexed item array keys to associative for type select, radio and check
140+
141+
- class: [`a9f\Typo3Fractor\TYPO3v12\FlexForm\MigrateItemsIndexedKeysToAssociativeFractor`](../rules/TYPO3v12/FlexForm/MigrateItemsIndexedKeysToAssociativeFractor.php)
142+
143+
```diff
144+
<T3DataStructure>
145+
<sheets>
146+
<sDEF>
147+
<ROOT>
148+
<sheetTitle>Sheet Title</sheetTitle>
149+
<type>array</type>
150+
<el>
151+
<selectSingleColumn>
152+
<config>
153+
<type>select</type>
154+
<renderType>selectSingle</renderType>
155+
<items type="array">
156+
<numIndex index="0" type="array">
157+
- <numIndex index="0"/>
158+
- <numIndex index="1"/>
159+
+ <label/>
160+
+ <value/>
161+
</numIndex>
162+
<numIndex index="1" type="array">
163+
- <numIndex index="0">Label 1</numIndex>
164+
- <numIndex index="1">1</numIndex>
165+
+ <label>Label 1</label>
166+
+ <value>1</value>
167+
</numIndex>
168+
<numIndex index="2" type="array">
169+
- <numIndex index="0">Label 2</numIndex>
170+
- <numIndex index="1">2</numIndex>
171+
+ <label>Label 2</label>
172+
+ <value>2</value>
173+
</numIndex>
174+
<numIndex index="3" type="array">
175+
- <numIndex index="0">Label 3</numIndex>
176+
- <numIndex index="1">3</numIndex>
177+
+ <label>Label 3</label>
178+
+ <value>3</value>
179+
</numIndex>
180+
</items>
181+
</config>
182+
</selectSingleColumn>
183+
</el>
184+
</ROOT>
185+
</sDEF>
186+
</sheets>
187+
</T3DataStructure>
188+
```
189+
190+
<br>
191+
137192
## MigrateNullFlagFlexFormFractor
138193

139194
Migrate null flag
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<T3DataStructure>
3+
<sheets>
4+
<sDEF>
5+
<ROOT>
6+
<sheetTitle>sheetTitle</sheetTitle>
7+
<type>array</type>
8+
<el>
9+
<selectSingleColumn>
10+
<config>
11+
<type>select</type>
12+
<renderType>selectSingle</renderType>
13+
<items type="array">
14+
<numIndex index="0" type="array">
15+
<numIndex index="0"/>
16+
<numIndex index="1"/>
17+
</numIndex>
18+
<numIndex index="1" type="array">
19+
<numIndex index="0">Label 1</numIndex>
20+
<numIndex index="1">1</numIndex>
21+
</numIndex>
22+
<numIndex index="2" type="array">
23+
<numIndex index="0">Label 2</numIndex>
24+
<numIndex index="1">2</numIndex>
25+
</numIndex>
26+
<numIndex index="3" type="array">
27+
<numIndex index="0">Label 3</numIndex>
28+
<numIndex index="1">3</numIndex>
29+
</numIndex>
30+
</items>
31+
</config>
32+
</selectSingleColumn>
33+
<selectCheckBoxColumn>
34+
<config>
35+
<type>select</type>
36+
<renderType>selectCheckBox</renderType>
37+
<items type="array">
38+
<numIndex index="0" type="array">
39+
<numIndex index="0">My label</numIndex>
40+
<numIndex index="1">0</numIndex>
41+
<numIndex index="2">my-icon</numIndex>
42+
<numIndex index="3">group1</numIndex>
43+
<numIndex index="4">My Description</numIndex>
44+
</numIndex>
45+
<numIndex index="1" type="array">
46+
<numIndex index="0">My label 1</numIndex>
47+
<numIndex index="1">1</numIndex>
48+
<numIndex index="2">my-icon</numIndex>
49+
<numIndex index="3">group1</numIndex>
50+
<numIndex index="4">My Description</numIndex>
51+
</numIndex>
52+
</items>
53+
</config>
54+
</selectCheckBoxColumn>
55+
<radioColumn>
56+
<config>
57+
<type>radio</type>
58+
<items type="array">
59+
<numIndex index="0" type="array">
60+
<numIndex index="0">My label</numIndex>
61+
<numIndex index="1">0</numIndex>
62+
</numIndex>
63+
<numIndex index="1" type="array">
64+
<numIndex index="0">My label 1</numIndex>
65+
<numIndex index="1">1</numIndex>
66+
</numIndex>
67+
<numIndex index="2" type="array">
68+
<numIndex index="0">My label 2</numIndex>
69+
<numIndex index="1">2</numIndex>
70+
</numIndex>
71+
</items>
72+
</config>
73+
</radioColumn>
74+
<checkColumn>
75+
<config>
76+
<type>check</type>
77+
<items type="array">
78+
<numIndex index="0" type="array">
79+
<numIndex index="0">My label</numIndex>
80+
<invertStateDisplay>1</invertStateDisplay>
81+
</numIndex>
82+
<numIndex index="1" type="array">
83+
<label>My label 2</label>
84+
<invertStateDisplay>1</invertStateDisplay>
85+
</numIndex>
86+
</items>
87+
</config>
88+
</checkColumn>
89+
<alreadyMigratedSelectCheckBox>
90+
<config>
91+
<type>select</type>
92+
<renderType>selectCheckBox</renderType>
93+
<items type="array">
94+
<numIndex index="0">
95+
<label>My label</label>
96+
<value>0</value>
97+
<icon>my-icon</icon>
98+
<group>group1</group>
99+
<description>My Description</description>
100+
</numIndex>
101+
</items>
102+
</config>
103+
</alreadyMigratedSelectCheckBox>
104+
</el>
105+
</ROOT>
106+
</sDEF>
107+
</sheets>
108+
</T3DataStructure>
109+
-----
110+
<?xml version="1.0" encoding="UTF-8"?>
111+
<T3DataStructure>
112+
<sheets>
113+
<sDEF>
114+
<ROOT>
115+
<sheetTitle>sheetTitle</sheetTitle>
116+
<type>array</type>
117+
<el>
118+
<selectSingleColumn>
119+
<config>
120+
<type>select</type>
121+
<renderType>selectSingle</renderType>
122+
<items type="array">
123+
<numIndex index="0" type="array">
124+
<label/>
125+
<value/>
126+
</numIndex>
127+
<numIndex index="1" type="array">
128+
<label>Label 1</label>
129+
<value>1</value>
130+
</numIndex>
131+
<numIndex index="2" type="array">
132+
<label>Label 2</label>
133+
<value>2</value>
134+
</numIndex>
135+
<numIndex index="3" type="array">
136+
<label>Label 3</label>
137+
<value>3</value>
138+
</numIndex>
139+
</items>
140+
</config>
141+
</selectSingleColumn>
142+
<selectCheckBoxColumn>
143+
<config>
144+
<type>select</type>
145+
<renderType>selectCheckBox</renderType>
146+
<items type="array">
147+
<numIndex index="0" type="array">
148+
<label>My label</label>
149+
<value>0</value>
150+
<icon>my-icon</icon>
151+
<group>group1</group>
152+
<description>My Description</description>
153+
</numIndex>
154+
<numIndex index="1" type="array">
155+
<label>My label 1</label>
156+
<value>1</value>
157+
<icon>my-icon</icon>
158+
<group>group1</group>
159+
<description>My Description</description>
160+
</numIndex>
161+
</items>
162+
</config>
163+
</selectCheckBoxColumn>
164+
<radioColumn>
165+
<config>
166+
<type>radio</type>
167+
<items type="array">
168+
<numIndex index="0" type="array">
169+
<label>My label</label>
170+
<value>0</value>
171+
</numIndex>
172+
<numIndex index="1" type="array">
173+
<label>My label 1</label>
174+
<value>1</value>
175+
</numIndex>
176+
<numIndex index="2" type="array">
177+
<label>My label 2</label>
178+
<value>2</value>
179+
</numIndex>
180+
</items>
181+
</config>
182+
</radioColumn>
183+
<checkColumn>
184+
<config>
185+
<type>check</type>
186+
<items type="array">
187+
<numIndex index="0" type="array">
188+
<label>My label</label>
189+
<invertStateDisplay>1</invertStateDisplay>
190+
</numIndex>
191+
<numIndex index="1" type="array">
192+
<label>My label 2</label>
193+
<invertStateDisplay>1</invertStateDisplay>
194+
</numIndex>
195+
</items>
196+
</config>
197+
</checkColumn>
198+
<alreadyMigratedSelectCheckBox>
199+
<config>
200+
<type>select</type>
201+
<renderType>selectCheckBox</renderType>
202+
<items type="array">
203+
<numIndex index="0">
204+
<label>My label</label>
205+
<value>0</value>
206+
<icon>my-icon</icon>
207+
<group>group1</group>
208+
<description>My Description</description>
209+
</numIndex>
210+
</items>
211+
</config>
212+
</alreadyMigratedSelectCheckBox>
213+
</el>
214+
</ROOT>
215+
</sDEF>
216+
</sheets>
217+
</T3DataStructure>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace a9f\Typo3Fractor\Tests\TYPO3v12\FlexForm\MigrateItemsIndexedKeysToAssociativeFractor;
6+
7+
use a9f\Fractor\Testing\PHPUnit\AbstractFractorTestCase;
8+
use PHPUnit\Framework\Attributes\DataProvider;
9+
10+
final class MigrateItemsIndexedKeysToAssociativeFractorTest extends AbstractFractorTestCase
11+
{
12+
#[DataProvider('provideData')]
13+
public function test(string $filePath): void
14+
{
15+
$this->doTestFile($filePath);
16+
}
17+
18+
public static function provideData(): \Iterator
19+
{
20+
return self::yieldFilesFromDirectory(__DIR__ . '/Fixtures', '*.xml');
21+
}
22+
23+
public function provideConfigFilePath(): ?string
24+
{
25+
return __DIR__ . '/config/fractor.php';
26+
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use a9f\Fractor\Configuration\FractorConfiguration;
6+
use a9f\Fractor\ValueObject\Indent;
7+
use a9f\FractorXml\Configuration\XmlProcessorOption;
8+
use a9f\Typo3Fractor\TYPO3v12\FlexForm\MigrateItemsIndexedKeysToAssociativeFractor;
9+
10+
return FractorConfiguration::configure()
11+
->withOptions([
12+
XmlProcessorOption::INDENT_CHARACTER => Indent::STYLE_TAB,
13+
XmlProcessorOption::INDENT_SIZE => 1,
14+
])
15+
->withRules([MigrateItemsIndexedKeysToAssociativeFractor::class]);

0 commit comments

Comments
 (0)