diff --git a/src/Adapter/Filesystem/Decode.php b/src/Adapter/Filesystem/Decode.php index 9d2b30b..a7badd0 100644 --- a/src/Adapter/Filesystem/Decode.php +++ b/src/Adapter/Filesystem/Decode.php @@ -17,6 +17,7 @@ use Innmind\Immutable\{ Maybe, Set, + Sequence, Predicate\Instance, }; @@ -67,8 +68,7 @@ public function __invoke(Aggregate\Id $id = null): callable ->map(static fn($file) => Aggregate\Property::of( $file->name()->toString(), Json::decode($file->content()->toString()), - )) - ->toSet(), + )), ), $directory ->get(Name::of('entities')) @@ -86,11 +86,9 @@ public function __invoke(Aggregate\Id $id = null): callable ->map(static fn($property) => Aggregate\Property::of( $property->name()->toString(), Json::decode($property->content()->toString()), - )) - ->toSet(), + )), ), - ) - ->toSet(), + ), ), $directory ->get(Name::of('optionals')) @@ -112,12 +110,10 @@ public function __invoke(Aggregate\Id $id = null): callable ->map(static fn($property) => Aggregate\Property::of( $property->name()->toString(), Json::decode($property->content()->toString()), - )) - ->toSet(), + )), ), ), - ) - ->toSet(), + ), ), $directory ->get(Name::of('collections')) @@ -132,7 +128,7 @@ public function __invoke(Aggregate\Id $id = null): callable Set::of(...Json::decode($collection->content()->toString()))->map( static fn($entity) => Aggregate\Collection\Entity::of( Reference::of($entity['reference']), - Set::of(...$entity['properties'])->map( + Sequence::of(...$entity['properties'])->map( static fn($property) => Aggregate\Property::of( $property[0], $property[1], @@ -141,10 +137,9 @@ public function __invoke(Aggregate\Id $id = null): callable ), ), ), - ) - ->toSet(), + ), ), - )->map(static fn(Set $properties, Set $entities, Set $optionals, Set $collections) => Aggregate::of( + )->map(static fn(Sequence $properties, Sequence $entities, Sequence $optionals, Sequence $collections) => Aggregate::of( $id($directory), $properties, $entities, diff --git a/src/Adapter/SQL/CollectionTable.php b/src/Adapter/SQL/CollectionTable.php index 0e9f5eb..8048187 100644 --- a/src/Adapter/SQL/CollectionTable.php +++ b/src/Adapter/SQL/CollectionTable.php @@ -34,8 +34,8 @@ final class CollectionTable /** @var Definition */ private Definition $definition; private Table\Name\Aliased $name; - /** @var Set */ - private Set $columns; + /** @var Sequence */ + private Sequence $columns; private Column\Name\Namespaced $id; private Column\Name\Namespaced $reference; private Select $select; @@ -98,9 +98,9 @@ public function foreignKey(): Table\Column } /** - * @return Set + * @return Sequence */ - public function columnsDefinition(MapType $mapType): Set + public function columnsDefinition(MapType $mapType): Sequence { return $this ->definition @@ -117,9 +117,9 @@ public function name(): Table\Name\Aliased } /** - * @return Set + * @return Sequence */ - public function columns(): Set + public function columns(): Sequence { return $this->columns; } diff --git a/src/Adapter/SQL/Decode.php b/src/Adapter/SQL/Decode.php index 284f686..f753308 100644 --- a/src/Adapter/SQL/Decode.php +++ b/src/Adapter/SQL/Decode.php @@ -16,6 +16,7 @@ use Innmind\Immutable\{ Maybe, Set, + Sequence, Str, }; @@ -77,8 +78,7 @@ public function __invoke(Aggregate\Id $id = null): callable ->map(static fn($value) => Aggregate\Property::of( Str::of($value->column()->toString())->drop(7)->toString(), $value->value(), - )) - ->toSet(), + )), $this ->mainTable ->entities() @@ -154,11 +154,11 @@ public static function of( /** * @psalm-pure * - * @param Set $columns + * @param Sequence $columns * - * @return Set + * @return Sequence */ - private static function properties(Row $row, Set $columns): Set + private static function properties(Row $row, Sequence $columns): Sequence { /** @psalm-suppress MixedArgument Due to the access-layer type */ return $columns->flatMap( @@ -171,8 +171,7 @@ private static function properties(Row $row, Set $columns): Set }, $value, )) - ->toSequence() - ->toSet(), + ->toSequence(), ); } } diff --git a/src/Adapter/SQL/Encode.php b/src/Adapter/SQL/Encode.php index 75f614a..9cd0445 100644 --- a/src/Adapter/SQL/Encode.php +++ b/src/Adapter/SQL/Encode.php @@ -8,10 +8,7 @@ Raw\Aggregate, }; use Formal\AccessLayer\Query; -use Innmind\Immutable\{ - Set, - Sequence, -}; +use Innmind\Immutable\Sequence; /** * @internal @@ -47,12 +44,10 @@ public function __invoke(Aggregate $data): Sequence $optionals = $this->optionals($data); $collections = $this->collections($data); - return Sequence::of( - $main, - ...$entities->toList(), - ...$optionals->toList(), - ...$collections->toList(), - ); + return Sequence::of($main) + ->append($entities) + ->append($optionals) + ->append($collections); } /** @@ -73,9 +68,9 @@ public static function of( } /** - * @return Set + * @return Sequence */ - private function entities(Aggregate $data): Set + private function entities(Aggregate $data): Sequence { return $data ->entities() @@ -86,15 +81,14 @@ private function entities(Aggregate $data): Set ->map( static fn($table) => $table->insert($data->id(), $entity->properties()), ) - ->toSequence() - ->toSet(), + ->toSequence(), ); } /** - * @return Set + * @return Sequence */ - private function optionals(Aggregate $data): Set + private function optionals(Aggregate $data): Sequence { return $data ->optionals() @@ -107,8 +101,7 @@ private function optionals(Aggregate $data): Set static fn($properties) => $table->insert($data->id(), $properties), ), ) - ->toSequence() - ->toSet(), + ->toSequence(), ); } @@ -121,9 +114,9 @@ private function main(Aggregate $data): Query } /** - * @return Set + * @return Sequence */ - private function collections(Aggregate $data): Set + private function collections(Aggregate $data): Sequence { return $data ->collections() @@ -137,8 +130,7 @@ private function collections(Aggregate $data): Set $collection->entities(), ), ) - ->toSequence() - ->toSet(), + ->toSequence(), ); } } diff --git a/src/Adapter/SQL/EntityTable.php b/src/Adapter/SQL/EntityTable.php index 5249c87..cf5f8da 100644 --- a/src/Adapter/SQL/EntityTable.php +++ b/src/Adapter/SQL/EntityTable.php @@ -18,7 +18,7 @@ }; use Innmind\Specification\Sign; use Innmind\Immutable\{ - Set, + Sequence, Maybe, }; @@ -31,8 +31,8 @@ final class EntityTable /** @var Definition */ private Definition $definition; private Table\Name\Aliased $name; - /** @var Set */ - private Set $columns; + /** @var Sequence */ + private Sequence $columns; /** * @param Definition $definition @@ -77,9 +77,9 @@ public function primaryKey(): Table\Column } /** - * @return Set + * @return Sequence */ - public function columnsDefinition(MapType $mapType): Set + public function columnsDefinition(MapType $mapType): Sequence { return $this ->definition @@ -96,9 +96,9 @@ public function name(): Table\Name\Aliased } /** - * @return Set + * @return Sequence */ - public function columns(): Set + public function columns(): Sequence { return $this->columns; } @@ -106,9 +106,9 @@ public function columns(): Set /** * @internal * - * @param Set $properties + * @param Sequence $properties */ - public function insert(Id $id, Set $properties): Query + public function insert(Id $id, Sequence $properties): Query { $table = $this->name->name(); @@ -132,11 +132,11 @@ public function insert(Id $id, Set $properties): Query /** * @internal * - * @param Set $properties + * @param Sequence $properties * * @return Maybe */ - public function update(Id $id, Set $properties): Maybe + public function update(Id $id, Sequence $properties): Maybe { return Maybe::just($properties) ->filter(static fn($properties) => !$properties->empty()) diff --git a/src/Adapter/SQL/MainTable.php b/src/Adapter/SQL/MainTable.php index 0559d10..69d9746 100644 --- a/src/Adapter/SQL/MainTable.php +++ b/src/Adapter/SQL/MainTable.php @@ -33,7 +33,7 @@ use Innmind\Immutable\{ Map, Maybe, - Set, + Sequence, }; /** @@ -114,7 +114,6 @@ private function __construct(Definition $definition) ->toList(), ...$entities ->values() - ->toSet() ->flatMap(static fn($table) => $table->columns()) ->toList(), ); @@ -161,9 +160,9 @@ public function primaryKey(): Table\Column } /** - * @return Set + * @return Sequence */ - public function columnsDefinition(MapType $mapType): Set + public function columnsDefinition(MapType $mapType): Sequence { return $this ->definition @@ -212,11 +211,11 @@ public function count(Specification $specification = null): Select /** * @internal * - * @param Set $properties + * @param Sequence $properties */ public function insert( Id $id, - Set $properties, + Sequence $properties, ): Query { $table = $this->name->name(); @@ -276,11 +275,11 @@ public function delete(): Delete } /** - * @return Set + * @return Sequence */ - public function entities(): Set + public function entities(): Sequence { - return $this->entities->values()->toSet(); + return $this->entities->values(); } /** @@ -294,11 +293,11 @@ public function entity(string $name): Maybe } /** - * @return Set + * @return Sequence */ - public function optionals(): Set + public function optionals(): Sequence { - return $this->optionals->values()->toSet(); + return $this->optionals->values(); } /** @@ -312,11 +311,11 @@ public function optional(string $name): Maybe } /** - * @return Set + * @return Sequence */ - public function collections(): Set + public function collections(): Sequence { - return $this->collections->values()->toSet(); + return $this->collections->values(); } /** diff --git a/src/Adapter/SQL/OptionalTable.php b/src/Adapter/SQL/OptionalTable.php index 67ee571..f475a4d 100644 --- a/src/Adapter/SQL/OptionalTable.php +++ b/src/Adapter/SQL/OptionalTable.php @@ -20,10 +20,7 @@ Row, }; use Innmind\Specification\Sign; -use Innmind\Immutable\{ - Set, - Sequence, -}; +use Innmind\Immutable\Sequence; /** * @psalm-immutable @@ -34,8 +31,8 @@ final class OptionalTable /** @var Definition */ private Definition $definition; private Table\Name\Aliased $name; - /** @var Set */ - private Set $columns; + /** @var Sequence */ + private Sequence $columns; private Select $select; /** @@ -85,9 +82,9 @@ public function primaryKey(): Table\Column } /** - * @return Set + * @return Sequence */ - public function columnsDefinition(MapType $mapType): Set + public function columnsDefinition(MapType $mapType): Sequence { return $this ->definition @@ -104,9 +101,9 @@ public function name(): Table\Name\Aliased } /** - * @return Set + * @return Sequence */ - public function columns(): Set + public function columns(): Sequence { return $this->columns; } @@ -126,9 +123,9 @@ public function select(Id $id): Select /** * @internal * - * @param Set $properties + * @param Sequence $properties */ - public function insert(Id $id, Set $properties): Query + public function insert(Id $id, Sequence $properties): Query { $table = $this->name->name(); diff --git a/src/Adapter/SQL/Update.php b/src/Adapter/SQL/Update.php index d890e1b..8da0519 100644 --- a/src/Adapter/SQL/Update.php +++ b/src/Adapter/SQL/Update.php @@ -45,8 +45,7 @@ public function __invoke(Diff $data): Sequence ) ->toSequence(), ) - ->toSequence() - ->toSet(), + ->toSequence(), ); $optionals = $data ->optionals() @@ -58,8 +57,7 @@ public function __invoke(Diff $data): Sequence $data->id(), $optional, )) - ->toSequence() - ->toSet(), + ->toSequence(), ); $collections = $data ->collections() @@ -74,16 +72,14 @@ public function __invoke(Diff $data): Sequence static fn($entity) => $entity->reference(), ), )) - ->toSequence() - ->toSet(), + ->toSequence(), ); - return Sequence::of( - $main, - ...$entities->toList(), - ...$optionals->toList(), - ...$collections->toList(), - )->flatMap(static fn($queries) => $queries); + return Sequence::of($main) + ->append($entities) + ->append($optionals) + ->append($collections) + ->flatMap(static fn($queries) => $queries); } /** diff --git a/src/Definition/Aggregate.php b/src/Definition/Aggregate.php index 341ee13..e8c30c5 100644 --- a/src/Definition/Aggregate.php +++ b/src/Definition/Aggregate.php @@ -7,7 +7,7 @@ use Innmind\Reflection\ReflectionClass; use Innmind\Immutable\{ Str, - Set, + Sequence, Monoid\Concat, }; @@ -21,30 +21,30 @@ final class Aggregate private string $class; /** @var Aggregate\Identity */ private Aggregate\Identity $id; - /** @var Set> */ - private Set $properties; - /** @var Set */ - private Set $entities; - /** @var Set */ - private Set $optionals; - /** @var Set */ - private Set $collections; + /** @var Sequence> */ + private Sequence $properties; + /** @var Sequence */ + private Sequence $entities; + /** @var Sequence */ + private Sequence $optionals; + /** @var Sequence */ + private Sequence $collections; /** * @param class-string $class * @param Aggregate\Identity $id - * @param Set> $properties - * @param Set $entities - * @param Set $optionals - * @param Set $collections + * @param Sequence> $properties + * @param Sequence $entities + * @param Sequence $optionals + * @param Sequence $collections */ private function __construct( string $class, Aggregate\Identity $id, - Set $properties, - Set $entities, - Set $optionals, - Set $collections, + Sequence $properties, + Sequence $entities, + Sequence $optionals, + Sequence $collections, ) { $this->class = $class; $this->id = $id; @@ -116,33 +116,33 @@ public function id(): Aggregate\Identity } /** - * @return Set> + * @return Sequence> */ - public function properties(): Set + public function properties(): Sequence { return $this->properties; } /** - * @return Set + * @return Sequence */ - public function entities(): Set + public function entities(): Sequence { return $this->entities; } /** - * @return Set + * @return Sequence */ - public function optionals(): Set + public function optionals(): Sequence { return $this->optionals; } /** - * @return Set + * @return Sequence */ - public function collections(): Set + public function collections(): Sequence { return $this->collections; } diff --git a/src/Definition/Aggregate/Collection.php b/src/Definition/Aggregate/Collection.php index da1c76b..6d64e4c 100644 --- a/src/Definition/Aggregate/Collection.php +++ b/src/Definition/Aggregate/Collection.php @@ -3,7 +3,7 @@ namespace Formal\ORM\Definition\Aggregate; -use Innmind\Immutable\Set; +use Innmind\Immutable\Sequence; /** * @psalm-immutable @@ -15,18 +15,18 @@ final class Collection private string $class; /** @var non-empty-string */ private string $name; - /** @var Set> */ - private Set $properties; + /** @var Sequence> */ + private Sequence $properties; /** * @param class-string $class * @param non-empty-string $name - * @param Set> $properties + * @param Sequence> $properties */ private function __construct( string $class, string $name, - Set $properties, + Sequence $properties, ) { $this->class = $class; $this->name = $name; @@ -40,14 +40,14 @@ private function __construct( * * @param class-string $class * @param non-empty-string $name - * @param Set> $properties + * @param Sequence> $properties * * @return self */ public static function of( string $class, string $name, - Set $properties, + Sequence $properties, ): self { return new self($class, $name, $properties); } @@ -69,9 +69,9 @@ public function name(): string } /** - * @return Set> + * @return Sequence> */ - public function properties(): Set + public function properties(): Sequence { return $this->properties; } diff --git a/src/Definition/Aggregate/Entity.php b/src/Definition/Aggregate/Entity.php index 475a290..c2f6ade 100644 --- a/src/Definition/Aggregate/Entity.php +++ b/src/Definition/Aggregate/Entity.php @@ -3,7 +3,7 @@ namespace Formal\ORM\Definition\Aggregate; -use Innmind\Immutable\Set; +use Innmind\Immutable\Sequence; /** * @psalm-immutable @@ -15,18 +15,18 @@ final class Entity private string $class; /** @var non-empty-string */ private string $name; - /** @var Set> */ - private Set $properties; + /** @var Sequence> */ + private Sequence $properties; /** * @param class-string $class * @param non-empty-string $name - * @param Set> $properties + * @param Sequence> $properties */ private function __construct( string $class, string $name, - Set $properties, + Sequence $properties, ) { $this->class = $class; $this->name = $name; @@ -40,14 +40,14 @@ private function __construct( * * @param class-string $class * @param non-empty-string $name - * @param Set> $properties + * @param Sequence> $properties * * @return self */ public static function of( string $class, string $name, - Set $properties, + Sequence $properties, ): self { return new self($class, $name, $properties); } @@ -69,9 +69,9 @@ public function name(): string } /** - * @return Set> + * @return Sequence> */ - public function properties(): Set + public function properties(): Sequence { return $this->properties; } diff --git a/src/Definition/Aggregate/Optional.php b/src/Definition/Aggregate/Optional.php index 6732375..aa8ab95 100644 --- a/src/Definition/Aggregate/Optional.php +++ b/src/Definition/Aggregate/Optional.php @@ -3,7 +3,7 @@ namespace Formal\ORM\Definition\Aggregate; -use Innmind\Immutable\Set; +use Innmind\Immutable\Sequence; /** * @psalm-immutable @@ -15,18 +15,18 @@ final class Optional private string $class; /** @var non-empty-string */ private string $name; - /** @var Set> */ - private Set $properties; + /** @var Sequence> */ + private Sequence $properties; /** * @param class-string $class * @param non-empty-string $name - * @param Set> $properties + * @param Sequence> $properties */ private function __construct( string $class, string $name, - Set $properties, + Sequence $properties, ) { $this->class = $class; $this->name = $name; @@ -40,14 +40,14 @@ private function __construct( * * @param class-string $class * @param non-empty-string $name - * @param Set> $properties + * @param Sequence> $properties * * @return self */ public static function of( string $class, string $name, - Set $properties, + Sequence $properties, ): self { return new self($class, $name, $properties); } @@ -69,9 +69,9 @@ public function name(): string } /** - * @return Set> + * @return Sequence> */ - public function properties(): Set + public function properties(): Sequence { return $this->properties; } diff --git a/src/Definition/Aggregate/Parsing.php b/src/Definition/Aggregate/Parsing.php index 46e0571..a008a55 100644 --- a/src/Definition/Aggregate/Parsing.php +++ b/src/Definition/Aggregate/Parsing.php @@ -16,6 +16,7 @@ use Innmind\Immutable\{ Maybe, Set, + Sequence, Predicate\Instance, }; @@ -29,30 +30,30 @@ final class Parsing private string $class; /** @var Maybe> */ private Maybe $id; - /** @var Set> */ - private Set $properties; - /** @var Set */ - private Set $entities; - /** @var Set */ - private Set $optionals; - /** @var Set */ - private Set $collections; + /** @var Sequence> */ + private Sequence $properties; + /** @var Sequence */ + private Sequence $entities; + /** @var Sequence */ + private Sequence $optionals; + /** @var Sequence */ + private Sequence $collections; /** * @param class-string $class * @param Maybe> $id - * @param Set> $properties - * @param Set $entities - * @param Set $optionals - * @param Set $collections + * @param Sequence> $properties + * @param Sequence $entities + * @param Sequence $optionals + * @param Sequence $collections */ private function __construct( string $class, Maybe $id, - Set $properties, - Set $entities, - Set $optionals, - Set $collections, + Sequence $properties, + Sequence $entities, + Sequence $optionals, + Sequence $collections, ) { $this->class = $class; $this->id = $id; @@ -75,7 +76,7 @@ public static function of(string $class): self /** @var Maybe> */ $id = Maybe::nothing(); - return new self($class, $id, Set::of(), Set::of(), Set::of(), Set::of()); + return new self($class, $id, Sequence::of(), Sequence::of(), Sequence::of(), Sequence::of()); } /** @@ -143,33 +144,33 @@ public function id(): Maybe } /** - * @return Set> + * @return Sequence> */ - public function properties(): Set + public function properties(): Sequence { return $this->properties; } /** - * @return Set + * @return Sequence */ - public function entities(): Set + public function entities(): Sequence { return $this->entities; } /** - * @return Set + * @return Sequence */ - public function optionals(): Set + public function optionals(): Sequence { return $this->optionals; } /** - * @return Set + * @return Sequence */ - public function collections(): Set + public function collections(): Sequence { return $this->collections; } @@ -253,16 +254,19 @@ private function parseEntity(ReflectionProperty $property, Types $types): Maybe ->map(fn($property) => Entity::of( $property->type()->toString(), $property->name(), - ReflectionClass::of($property->type()->toString()) - ->properties() + Sequence::of( + ...ReflectionClass::of($property->type()->toString()) + ->properties() + ->toList(), + ) ->flatMap( - fn($innerProperty) => $this->parseProperty( - $property->type()->toString(), - $innerProperty, - $types, - ) - ->toSequence() - ->toSet(), + fn($innerProperty) => $this + ->parseProperty( + $property->type()->toString(), + $innerProperty, + $types, + ) + ->toSequence(), ), )); } @@ -290,16 +294,19 @@ private function parseOptional(ReflectionProperty $property, Types $types): Mayb ->map(fn($contains) => Optional::of( $contains->type()->toString(), $property->name(), - ReflectionClass::of($contains->type()->toString()) - ->properties() + Sequence::of( + ...ReflectionClass::of($contains->type()->toString()) + ->properties() + ->toList(), + ) ->flatMap( - fn($innerProperty) => $this->parseProperty( - $property->type()->toString(), - $innerProperty, - $types, - ) - ->toSequence() - ->toSet(), + fn($innerProperty) => $this + ->parseProperty( + $property->type()->toString(), + $innerProperty, + $types, + ) + ->toSequence(), ), )), ); @@ -328,16 +335,19 @@ private function parseCollection(ReflectionProperty $property, Types $types): Ma ->map(fn($contains) => Collection::of( $contains->type()->toString(), $property->name(), - ReflectionClass::of($contains->type()->toString()) - ->properties() + Sequence::of( + ...ReflectionClass::of($contains->type()->toString()) + ->properties() + ->toList(), + ) ->flatMap( - fn($innerProperty) => $this->parseProperty( - $property->type()->toString(), - $innerProperty, - $types, - ) - ->toSequence() - ->toSet(), + fn($innerProperty) => $this + ->parseProperty( + $property->type()->toString(), + $innerProperty, + $types, + ) + ->toSequence(), ), )), ); diff --git a/src/Raw/Aggregate.php b/src/Raw/Aggregate.php index b5207c5..6134e88 100644 --- a/src/Raw/Aggregate.php +++ b/src/Raw/Aggregate.php @@ -3,7 +3,7 @@ namespace Formal\ORM\Raw; -use Innmind\Immutable\Set; +use Innmind\Immutable\Sequence; /** * @psalm-immutable @@ -11,27 +11,27 @@ final class Aggregate { private Aggregate\Id $id; - /** @var Set */ - private Set $properties; - /** @var Set */ - private Set $entities; - /** @var Set */ - private Set $optionals; - /** @var Set */ - private Set $collections; + /** @var Sequence */ + private Sequence $properties; + /** @var Sequence */ + private Sequence $entities; + /** @var Sequence */ + private Sequence $optionals; + /** @var Sequence */ + private Sequence $collections; /** - * @param Set $properties - * @param Set $entities - * @param Set $optionals - * @param Set $collections + * @param Sequence $properties + * @param Sequence $entities + * @param Sequence $optionals + * @param Sequence $collections */ private function __construct( Aggregate\Id $id, - Set $properties, - Set $entities, - Set $optionals, - Set $collections, + Sequence $properties, + Sequence $entities, + Sequence $optionals, + Sequence $collections, ) { $this->id = $id; $this->properties = $properties; @@ -43,17 +43,17 @@ private function __construct( /** * @psalm-pure * - * @param Set $properties - * @param Set $entities - * @param Set $optionals - * @param Set $collections + * @param Sequence $properties + * @param Sequence $entities + * @param Sequence $optionals + * @param Sequence $collections */ public static function of( Aggregate\Id $id, - Set $properties, - Set $entities, - Set $optionals, - Set $collections, + Sequence $properties, + Sequence $entities, + Sequence $optionals, + Sequence $collections, ): self { return new self($id, $properties, $entities, $optionals, $collections); } @@ -64,33 +64,33 @@ public function id(): Aggregate\Id } /** - * @return Set + * @return Sequence */ - public function properties(): Set + public function properties(): Sequence { return $this->properties; } /** - * @return Set + * @return Sequence */ - public function entities(): Set + public function entities(): Sequence { return $this->entities; } /** - * @return Set + * @return Sequence */ - public function optionals(): Set + public function optionals(): Sequence { return $this->optionals; } /** - * @return Set + * @return Sequence */ - public function collections(): Set + public function collections(): Sequence { return $this->collections; } diff --git a/src/Raw/Aggregate/Collection/Entity.php b/src/Raw/Aggregate/Collection/Entity.php index fb8585f..4410db4 100644 --- a/src/Raw/Aggregate/Collection/Entity.php +++ b/src/Raw/Aggregate/Collection/Entity.php @@ -7,7 +7,7 @@ Property, Collection\Entity\Reference, }; -use Innmind\Immutable\Set; +use Innmind\Immutable\Sequence; /** * @psalm-immutable @@ -15,13 +15,13 @@ final class Entity { private Reference $reference; - /** @var Set */ - private Set $properties; + /** @var Sequence */ + private Sequence $properties; /** - * @param Set $properties + * @param Sequence $properties */ - private function __construct(Reference $reference, Set $properties) + private function __construct(Reference $reference, Sequence $properties) { $this->reference = $reference; $this->properties = $properties; @@ -30,9 +30,9 @@ private function __construct(Reference $reference, Set $properties) /** * @psalm-pure * - * @param Set $properties + * @param Sequence $properties */ - public static function of(Reference $reference, Set $properties): self + public static function of(Reference $reference, Sequence $properties): self { return new self($reference, $properties); } @@ -43,9 +43,9 @@ public function reference(): Reference } /** - * @return Set + * @return Sequence */ - public function properties(): Set + public function properties(): Sequence { return $this->properties; } diff --git a/src/Raw/Aggregate/Entity.php b/src/Raw/Aggregate/Entity.php index 7bce2d4..21cb748 100644 --- a/src/Raw/Aggregate/Entity.php +++ b/src/Raw/Aggregate/Entity.php @@ -3,7 +3,7 @@ namespace Formal\ORM\Raw\Aggregate; -use Innmind\Immutable\Set; +use Innmind\Immutable\Sequence; /** * @psalm-immutable @@ -12,14 +12,14 @@ final class Entity { /** @var non-empty-string */ private string $name; - /** @var Set */ - private Set $properties; + /** @var Sequence */ + private Sequence $properties; /** * @param non-empty-string $name - * @param Set $properties + * @param Sequence $properties */ - private function __construct(string $name, Set $properties) + private function __construct(string $name, Sequence $properties) { $this->name = $name; $this->properties = $properties; @@ -29,9 +29,9 @@ private function __construct(string $name, Set $properties) * @psalm-pure * * @param non-empty-string $name - * @param Set $properties + * @param Sequence $properties */ - public static function of(string $name, Set $properties): self + public static function of(string $name, Sequence $properties): self { return new self($name, $properties); } @@ -45,9 +45,9 @@ public function name(): string } /** - * @return Set + * @return Sequence */ - public function properties(): Set + public function properties(): Sequence { return $this->properties; } diff --git a/src/Raw/Aggregate/Optional.php b/src/Raw/Aggregate/Optional.php index 86d313c..08015f0 100644 --- a/src/Raw/Aggregate/Optional.php +++ b/src/Raw/Aggregate/Optional.php @@ -4,7 +4,7 @@ namespace Formal\ORM\Raw\Aggregate; use Innmind\Immutable\{ - Set, + Sequence, Maybe, }; @@ -15,12 +15,12 @@ final class Optional { /** @var non-empty-string */ private string $name; - /** @var Maybe> */ + /** @var Maybe> */ private Maybe $properties; /** * @param non-empty-string $name - * @param Maybe> $properties + * @param Maybe> $properties */ private function __construct(string $name, Maybe $properties) { @@ -32,7 +32,7 @@ private function __construct(string $name, Maybe $properties) * @psalm-pure * * @param non-empty-string $name - * @param Maybe> $properties + * @param Maybe> $properties */ public static function of(string $name, Maybe $properties): self { @@ -48,7 +48,7 @@ public function name(): string } /** - * @return Maybe> + * @return Maybe> */ public function properties(): Maybe { diff --git a/src/Raw/Aggregate/Optional/BrandNew.php b/src/Raw/Aggregate/Optional/BrandNew.php index 0017108..d3f477c 100644 --- a/src/Raw/Aggregate/Optional/BrandNew.php +++ b/src/Raw/Aggregate/Optional/BrandNew.php @@ -9,7 +9,7 @@ }; use Innmind\Immutable\{ Maybe, - Set, + Sequence, }; /** @@ -45,7 +45,7 @@ public function name(): string } /** - * @return Maybe> + * @return Maybe> */ public function properties(): Maybe { diff --git a/src/Raw/Diff.php b/src/Raw/Diff.php index 1821ad0..21a48b5 100644 --- a/src/Raw/Diff.php +++ b/src/Raw/Diff.php @@ -3,7 +3,7 @@ namespace Formal\ORM\Raw; -use Innmind\Immutable\Set; +use Innmind\Immutable\Sequence; /** * @psalm-immutable @@ -11,27 +11,27 @@ final class Diff { private Aggregate\Id $id; - /** @var Set */ - private Set $properties; - /** @var Set */ - private Set $entities; - /** @var Set */ - private Set $optionals; - /** @var Set */ - private Set $collections; + /** @var Sequence */ + private Sequence $properties; + /** @var Sequence */ + private Sequence $entities; + /** @var Sequence */ + private Sequence $optionals; + /** @var Sequence */ + private Sequence $collections; /** - * @param Set $properties - * @param Set $entities - * @param Set $optionals - * @param Set $collections + * @param Sequence $properties + * @param Sequence $entities + * @param Sequence $optionals + * @param Sequence $collections */ private function __construct( Aggregate\Id $id, - Set $properties, - Set $entities, - Set $optionals, - Set $collections, + Sequence $properties, + Sequence $entities, + Sequence $optionals, + Sequence $collections, ) { $this->id = $id; $this->properties = $properties; @@ -44,17 +44,17 @@ private function __construct( * @internal * @psalm-pure * - * @param Set $properties - * @param Set $entities - * @param Set $optionals - * @param Set $collections + * @param Sequence $properties + * @param Sequence $entities + * @param Sequence $optionals + * @param Sequence $collections */ public static function of( Aggregate\Id $id, - Set $properties, - Set $entities, - Set $optionals, - Set $collections, + Sequence $properties, + Sequence $entities, + Sequence $optionals, + Sequence $collections, ): self { return new self($id, $properties, $entities, $optionals, $collections); } @@ -65,33 +65,33 @@ public function id(): Aggregate\Id } /** - * @return Set + * @return Sequence */ - public function properties(): Set + public function properties(): Sequence { return $this->properties; } /** - * @return Set + * @return Sequence */ - public function entities(): Set + public function entities(): Sequence { return $this->entities; } /** - * @return Set + * @return Sequence */ - public function optionals(): Set + public function optionals(): Sequence { return $this->optionals; } /** - * @return Set + * @return Sequence */ - public function collections(): Set + public function collections(): Sequence { return $this->collections; } diff --git a/src/Repository/Denormalize.php b/src/Repository/Denormalize.php index d2de6f2..a6a2cb5 100644 --- a/src/Repository/Denormalize.php +++ b/src/Repository/Denormalize.php @@ -130,8 +130,7 @@ private function properties(Id $id, Aggregate $data): Map ->get($property->name()) ->map(static fn($definition): mixed => $definition->type()->denormalize($property->value())) ->map(static fn($value) => [$property->name(), $value]) - ->toSequence() - ->toSet(), + ->toSequence(), ) ->toList(), ...$data @@ -142,8 +141,7 @@ private function properties(Id $id, Aggregate $data): Map ->get($entity->name()) ->map(static fn($denormalize): object => $denormalize($entity)) ->map(static fn($value) => [$entity->name(), $value]) - ->toSequence() - ->toSet(), + ->toSequence(), ) ->toList(), ...$data @@ -154,8 +152,7 @@ private function properties(Id $id, Aggregate $data): Map ->get($optional->name()) ->map(static fn($denormalize): Maybe => $denormalize($optional)) ->map(static fn($value) => [$optional->name(), $value]) - ->toSequence() - ->toSet(), + ->toSequence(), ) ->toList(), ...$data @@ -166,8 +163,7 @@ private function properties(Id $id, Aggregate $data): Map ->get($collection->name()) ->map(static fn($denormalize): Set => $denormalize($id, $collection)) ->map(static fn($value) => [$collection->name(), $value]) - ->toSequence() - ->toSet(), + ->toSequence(), ) ->toList(), ); diff --git a/src/Repository/Denormalize/Collection.php b/src/Repository/Denormalize/Collection.php index 2a43bb3..40c1a9d 100644 --- a/src/Repository/Denormalize/Collection.php +++ b/src/Repository/Denormalize/Collection.php @@ -75,8 +75,7 @@ public function __invoke(Id $id, Raw $collection): Set ->get($property->name()) ->map(static fn($definition): mixed => $definition->type()->denormalize($property->value())) ->map(static fn($value) => [$property->name(), $value]) - ->toSequence() - ->toSet(), + ->toSequence(), ) ->toList(), ); diff --git a/src/Repository/Denormalize/Entity.php b/src/Repository/Denormalize/Entity.php index 6f2a07d..bab6ec0 100644 --- a/src/Repository/Denormalize/Entity.php +++ b/src/Repository/Denormalize/Entity.php @@ -52,8 +52,7 @@ public function __invoke(Raw $entity): object ->get($property->name()) ->map(static fn($definition): mixed => $definition->type()->denormalize($property->value())) ->map(static fn($value) => [$property->name(), $value]) - ->toSequence() - ->toSet(), + ->toSequence(), ) ->toList(), ); diff --git a/src/Repository/Denormalize/Optional.php b/src/Repository/Denormalize/Optional.php index d11aa7a..f978148 100644 --- a/src/Repository/Denormalize/Optional.php +++ b/src/Repository/Denormalize/Optional.php @@ -59,8 +59,7 @@ public function __invoke(Raw $optional): Maybe ->get($property->name()) ->map(static fn($definition): mixed => $definition->type()->denormalize($property->value())) ->map(static fn($value) => [$property->name(), $value]) - ->toSequence() - ->toSet(), + ->toSequence(), ) ->toList(), ); diff --git a/src/Repository/Diff.php b/src/Repository/Diff.php index d37234e..20eea76 100644 --- a/src/Repository/Diff.php +++ b/src/Repository/Diff.php @@ -12,6 +12,7 @@ use Innmind\Immutable\{ Map, Set, + Sequence, }; /** @@ -120,8 +121,7 @@ public function __invoke(Denormalized $then, Denormalized $now): Raw\Diff $property->name(), $property->type()->normalize($value->now()), )) - ->values() - ->toSet(); + ->values(); /** @psalm-suppress MixedArgument */ $entities = $diff ->flatMap( @@ -137,8 +137,7 @@ public function __invoke(Denormalized $then, Denormalized $now): Raw\Diff static fn() => Map::of(), ), ) - ->values() - ->toSet(); + ->values(); /** @psalm-suppress MixedArgument */ $optionals = $diff ->flatMap( @@ -154,8 +153,7 @@ public function __invoke(Denormalized $then, Denormalized $now): Raw\Diff static fn() => Map::of(), ), ) - ->values() - ->toSet(); + ->values(); /** @psalm-suppress MixedArgument */ $collections = $diff ->flatMap( @@ -173,8 +171,7 @@ public function __invoke(Denormalized $then, Denormalized $now): Raw\Diff static fn() => Map::of(), ), ) - ->values() - ->toSet(); + ->values(); return Raw\Diff::of( $normalizedId, @@ -275,12 +272,12 @@ private static function diffCollections( /** * @psalm-pure * - * @param Set $then - * @param Set $now + * @param Sequence $then + * @param Sequence $now * - * @return Set + * @return Sequence */ - private static function diffProperties(Set $then, Set $now): Set + private static function diffProperties(Sequence $then, Sequence $now): Sequence { $nowProperties = Map::of( ...$now @@ -292,8 +289,7 @@ private static function diffProperties(Set $then, Set $now): Set static fn($then) => $nowProperties ->get($then->name()) ->filter(static fn($now) => $then->value() !== $now->value()) - ->toSequence() - ->toSet(), + ->toSequence(), ); } } diff --git a/src/Repository/Extract.php b/src/Repository/Extract.php index f12c769..31f45ae 100644 --- a/src/Repository/Extract.php +++ b/src/Repository/Extract.php @@ -9,10 +9,7 @@ Id, }; use Innmind\Reflection; -use Innmind\Immutable\{ - Set, - Map, -}; +use Innmind\Immutable\Set; /** * @internal @@ -38,21 +35,22 @@ private function __construct(Definition $definition) $this->allProperties = $definition ->properties() ->map(static fn($property) => $property->name()) - ->merge( + ->append( $definition ->entities() ->map(static fn($entity) => $entity->name()), ) - ->merge( + ->append( $definition ->optionals() ->map(static fn($optional) => $optional->name()), ) - ->merge( + ->append( $definition ->collections() ->map(static fn($collection) => $collection->name()), - ); + ) + ->toSet(); /** * @psalm-suppress InvalidArgument * @var \Closure(T): Id diff --git a/src/Repository/Normalize.php b/src/Repository/Normalize.php index 628e55a..a04ff89 100644 --- a/src/Repository/Normalize.php +++ b/src/Repository/Normalize.php @@ -8,10 +8,7 @@ Raw\Aggregate, }; use Innmind\Reflection\Extract; -use Innmind\Immutable\{ - Set, - Map, -}; +use Innmind\Immutable\Map; /** * @internal @@ -88,8 +85,7 @@ public function __invoke(Denormalized $denormalized): Aggregate $property->name(), $property->type()->normalize($value), )) - ->toSequence() - ->toSet(), + ->toSequence(), ), $this ->definition @@ -103,8 +99,7 @@ public function __invoke(Denormalized $denormalized): Aggregate ->get($entity->name()) ->map($normalize), ) - ->toSequence() - ->toSet(), + ->toSequence(), ), $this ->definition @@ -118,8 +113,7 @@ public function __invoke(Denormalized $denormalized): Aggregate ->get($optional->name()) ->map($normalize), ) - ->toSequence() - ->toSet(), + ->toSequence(), ), $this ->definition @@ -133,8 +127,7 @@ public function __invoke(Denormalized $denormalized): Aggregate ->get($collection->name()) ->map(static fn($object) => $normalize($denormalized->id(), $object)), ) - ->toSequence() - ->toSet(), + ->toSequence(), ), ); } diff --git a/src/Repository/Normalize/Collection.php b/src/Repository/Normalize/Collection.php index df8e106..fd358a0 100644 --- a/src/Repository/Normalize/Collection.php +++ b/src/Repository/Normalize/Collection.php @@ -42,7 +42,8 @@ private function __construct( $this->knowCollectionEntity = $knownCollectionEntity; $this->properties = $definition ->properties() - ->map(static fn($property) => $property->name()); + ->map(static fn($property) => $property->name()) + ->toSet(); } /** @@ -84,8 +85,7 @@ public function __invoke(Id $id, Set $collection): Raw $property->name(), $property->type()->normalize($value), )) - ->toSequence() - ->toSet(), + ->toSequence(), ), ) ->map(Raw\Entity::of(...)) diff --git a/src/Repository/Normalize/Entity.php b/src/Repository/Normalize/Entity.php index cc3fc43..744c473 100644 --- a/src/Repository/Normalize/Entity.php +++ b/src/Repository/Normalize/Entity.php @@ -32,7 +32,8 @@ private function __construct(Definition $definition, Extract $extract) $this->extract = $extract; $this->properties = $definition ->properties() - ->map(static fn($property) => $property->name()); + ->map(static fn($property) => $property->name()) + ->toSet(); } /** @@ -58,8 +59,7 @@ public function __invoke(object $entity): Raw $property->name(), $property->type()->normalize($value), )) - ->toSequence() - ->toSet(), + ->toSequence(), ), ); } diff --git a/src/Repository/Normalize/Optional.php b/src/Repository/Normalize/Optional.php index 404613f..5bf3b73 100644 --- a/src/Repository/Normalize/Optional.php +++ b/src/Repository/Normalize/Optional.php @@ -35,7 +35,8 @@ private function __construct(Definition $definition, Extract $extract) $this->extract = $extract; $this->properties = $definition ->properties() - ->map(static fn($property) => $property->name()); + ->map(static fn($property) => $property->name()) + ->toSet(); } /** @@ -64,8 +65,7 @@ public function __invoke(Maybe $optional): Raw $property->name(), $property->type()->normalize($value), )) - ->toSequence() - ->toSet(), + ->toSequence(), ), ), );