Skip to content

Commit dba6af9

Browse files
authored
Merge pull request #19 from PackageFactory/remove-abstract-lists
Remove abstract lists
2 parents 3c0ee05 + 6403cec commit dba6af9

11 files changed

Lines changed: 81 additions & 212 deletions

File tree

Classes/Domain/AbstractImmutableArrayObject.php

Lines changed: 0 additions & 52 deletions
This file was deleted.

Classes/Domain/Component/AbstractComponentArray.php

Lines changed: 0 additions & 17 deletions
This file was deleted.

Classes/Domain/Component/Component.php

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -123,46 +123,33 @@ public function getComponentArrayContent(): string
123123
' . $this->name->renderClassComment() . '
124124
125125
use Neos\Flow\Annotations as Flow;
126-
use PackageFactory\AtomicFusion\PresentationObjects\Domain\Component\AbstractComponentArray;
127126
128127
/**
129128
* @Flow\Proxy(false)
130129
*/
131-
final class ' . $this->name->getSimpleComponentArrayName() . ' extends AbstractComponentArray
130+
final class ' . $this->name->getSimpleComponentArrayName() . ' implements \IteratorAggregate
132131
{
132+
/**
133+
* @var array<int,' . $this->name->getSimpleInterfaceName() . '>|' . $this->name->getSimpleInterfaceName() . '[]
134+
*/
135+
private array $' . $this->name->getSimpleComponentArrayPropertyName() . ';
136+
133137
public function __construct($array)
134138
{
135139
foreach ($array as $element) {
136140
if (!$element instanceof ' . $this->name->getSimpleInterfaceName() . ') {
137141
throw new \InvalidArgumentException(self::class . \' can only consist of \' . ' . $this->name->getSimpleInterfaceName() . '::class);
138142
}
139143
}
140-
parent::__construct($array);
141-
}
142-
143-
/**
144-
* @param mixed $key
145-
* @return ' . $this->name->getSimpleInterfaceName() . '|false
146-
*/
147-
public function offsetGet($key)
148-
{
149-
return parent::offsetGet($key);
150-
}
151-
152-
/**
153-
* @return array|'. $this->name->getSimpleInterfaceName() . '[]
154-
*/
155-
public function getArrayCopy(): array
156-
{
157-
return parent::getArrayCopy();
144+
$this->' . $this->name->getSimpleComponentArrayPropertyName() . ' = $array;
158145
}
159146
160147
/**
161-
* @return \ArrayIterator|' . $this->name->getSimpleInterfaceName() . '[]
148+
* @return \ArrayIterator<int,' . $this->name->getSimpleInterfaceName() . '>|' . $this->name->getSimpleInterfaceName() . '[]
162149
*/
163150
public function getIterator(): \ArrayIterator
164151
{
165-
return parent::getIterator();
152+
return new \ArrayIterator($this->' . $this->name->getSimpleComponentArrayPropertyName() . ');
166153
}
167154
}
168155
';

Classes/Domain/Component/ComponentName.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,11 @@ public function getSimpleComponentArrayName(): string
175175
return PluralName::forName($this->name);
176176
}
177177

178+
public function getSimpleComponentArrayPropertyName(): string
179+
{
180+
return lcfirst(PluralName::forName($this->name));
181+
}
182+
178183
/**
179184
* @return class-string<mixed>
180185
*/

Classes/Domain/Component/PropType/IsComponentArray.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
*/
77

88
use Neos\Flow\Annotations as Flow;
9-
use PackageFactory\AtomicFusion\PresentationObjects\Domain\AbstractImmutableArrayObject;
10-
use PackageFactory\AtomicFusion\PresentationObjects\Domain\Component\AbstractComponentArray;
11-
use PackageFactory\AtomicFusion\PresentationObjects\Fusion\ComponentPresentationObjectInterface;
129

1310
/**
1411
* The specification for component array classes
@@ -24,6 +21,6 @@ public static function isSatisfiedByInputString(string $input): bool
2421
public static function isSatisfiedByClassName(string $className): bool
2522
{
2623
return class_exists($className)
27-
&& is_subclass_of($className, AbstractComponentArray::class);
24+
&& is_subclass_of($className, \Traversable::class);
2825
}
2926
}

Tests/Unit/Domain/Component/ComponentTest.php

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -415,46 +415,33 @@ public function testGetComponentArrayContent(): void
415415
*/
416416
417417
use Neos\Flow\Annotations as Flow;
418-
use PackageFactory\AtomicFusion\PresentationObjects\Domain\Component\AbstractComponentArray;
419418
420419
/**
421420
* @Flow\Proxy(false)
422421
*/
423-
final class MyNewComponents extends AbstractComponentArray
422+
final class MyNewComponents implements \IteratorAggregate
424423
{
424+
/**
425+
* @var array<int,MyNewComponentInterface>|MyNewComponentInterface[]
426+
*/
427+
private array $myNewComponents;
428+
425429
public function __construct($array)
426430
{
427431
foreach ($array as $element) {
428432
if (!$element instanceof MyNewComponentInterface) {
429433
throw new \InvalidArgumentException(self::class . \' can only consist of \' . MyNewComponentInterface::class);
430434
}
431435
}
432-
parent::__construct($array);
433-
}
434-
435-
/**
436-
* @param mixed $key
437-
* @return MyNewComponentInterface|false
438-
*/
439-
public function offsetGet($key)
440-
{
441-
return parent::offsetGet($key);
442-
}
443-
444-
/**
445-
* @return array|MyNewComponentInterface[]
446-
*/
447-
public function getArrayCopy(): array
448-
{
449-
return parent::getArrayCopy();
436+
$this->myNewComponents = $array;
450437
}
451438
452439
/**
453-
* @return \ArrayIterator|MyNewComponentInterface[]
440+
* @return \ArrayIterator<int,MyNewComponentInterface>|MyNewComponentInterface[]
454441
*/
455442
public function getIterator(): \ArrayIterator
456443
{
457-
return parent::getIterator();
444+
return new \ArrayIterator($this->myNewComponents);
458445
}
459446
}
460447
',

Tests/Unit/Domain/Component/__snapshots__/ComponentGeneratorTest__generatesComponents with data set textWithArray__2.txt

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,45 +6,32 @@ namespace Vendor\Site\Presentation\Component\NewText;
66
*/
77

88
use Neos\Flow\Annotations as Flow;
9-
use PackageFactory\AtomicFusion\PresentationObjects\Domain\Component\AbstractComponentArray;
109

1110
/**
1211
* @Flow\Proxy(false)
1312
*/
14-
final class NewTexts extends AbstractComponentArray
13+
final class NewTexts implements \IteratorAggregate
1514
{
15+
/**
16+
* @var array<int,NewTextInterface>|NewTextInterface[]
17+
*/
18+
private array $newTexts;
19+
1620
public function __construct($array)
1721
{
1822
foreach ($array as $element) {
1923
if (!$element instanceof NewTextInterface) {
2024
throw new \InvalidArgumentException(self::class . ' can only consist of ' . NewTextInterface::class);
2125
}
2226
}
23-
parent::__construct($array);
24-
}
25-
26-
/**
27-
* @param mixed $key
28-
* @return NewTextInterface|false
29-
*/
30-
public function offsetGet($key)
31-
{
32-
return parent::offsetGet($key);
33-
}
34-
35-
/**
36-
* @return array|NewTextInterface[]
37-
*/
38-
public function getArrayCopy(): array
39-
{
40-
return parent::getArrayCopy();
27+
$this->newTexts = $array;
4128
}
4229

4330
/**
44-
* @return \ArrayIterator|NewTextInterface[]
31+
* @return \ArrayIterator<int,NewTextInterface>|NewTextInterface[]
4532
*/
4633
public function getIterator(): \ArrayIterator
4734
{
48-
return parent::getIterator();
35+
return new \ArrayIterator($this->newTexts);
4936
}
5037
}

Tests/Unit/Fixtures/Shared/Presentation/Component/Text/Texts.php

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,46 +6,34 @@
66
*/
77

88
use Neos\Flow\Annotations as Flow;
9-
use PackageFactory\AtomicFusion\PresentationObjects\Domain\Component\AbstractComponentArray;
109

1110
/**
12-
* A text component array
11+
* A list of texts
1312
* @Flow\Proxy(false)
1413
*/
15-
final class Texts extends AbstractComponentArray
14+
final class Texts implements \IteratorAggregate
1615
{
16+
/**
17+
* @var array<int,TextInterface>|TextInterface[]
18+
*/
19+
private array $texts;
20+
1721
public function __construct($array)
1822
{
1923
foreach ($array as $element) {
2024
if (!$element instanceof TextInterface) {
2125
throw new \InvalidArgumentException(self::class . ' can only consist of ' . TextInterface::class);
2226
}
2327
}
24-
parent::__construct($array);
25-
}
26-
27-
/**
28-
* @param mixed $key
29-
* @return TextInterface|false
30-
*/
31-
public function offsetGet($key)
32-
{
33-
return parent::offsetGet($key);
34-
}
3528

36-
/**
37-
* @return array|TextInterface[]
38-
*/
39-
public function getArrayCopy(): array
40-
{
41-
return parent::getArrayCopy();
29+
$this->texts = $array;
4230
}
4331

4432
/**
45-
* @return \ArrayIterator|TextInterface[]
33+
* @return \ArrayIterator<int,TextInterface>|TextInterface[]
4634
*/
4735
public function getIterator(): \ArrayIterator
4836
{
49-
return parent::getIterator();
37+
return new \ArrayIterator($this->texts);
5038
}
5139
}

Tests/Unit/Fixtures/Site/Presentation/Component/AnotherComponent/AnotherComponents.php

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,33 @@
66
*/
77

88
use Neos\Flow\Annotations as Flow;
9-
use PackageFactory\AtomicFusion\PresentationObjects\Domain\Component\AbstractComponentArray;
109

1110
/**
12-
* A dummy component array
11+
* A list of anotherComponents
1312
* @Flow\Proxy(false)
1413
*/
15-
final class AnotherComponents extends AbstractComponentArray
14+
final class AnotherComponents implements \IteratorAggregate
1615
{
16+
/**
17+
* @var array<int,AnotherComponentInterface>|AnotherComponentInterface[]
18+
*/
19+
private array $anotherComponents;
20+
1721
public function __construct($array)
1822
{
1923
foreach ($array as $element) {
20-
if (!$element instanceof AnotherComponent) {
24+
if (!$element instanceof AnotherComponentInterface) {
2125
throw new \InvalidArgumentException(self::class . ' can only consist of ' . AnotherComponentInterface::class);
2226
}
2327
}
24-
parent::__construct($array);
28+
$this->anotherComponents = $array;
29+
}
30+
31+
/**
32+
* @return \ArrayIterator<int,AnotherComponentInterface>|AnotherComponentInterface[]
33+
*/
34+
public function getIterator(): \ArrayIterator
35+
{
36+
return new \ArrayIterator($this->anotherComponents);
2537
}
2638
}

0 commit comments

Comments
 (0)