From 5d6ede7e3f9a913b3d88cb60f1623d88b4a8ffd9 Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Mon, 22 Sep 2025 09:40:56 +0200 Subject: [PATCH 1/2] use int ranges to be more explicit --- src/Adapter/Elasticsearch/Repository.php | 10 +++++----- src/Adapter/Repository.php | 6 +++--- src/Adapter/Repository/CrossAggregateMatching.php | 4 ++-- src/Adapter/SQL/Repository.php | 2 +- src/Matching.php | 12 ++++++------ src/Repository.php | 2 +- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Adapter/Elasticsearch/Repository.php b/src/Adapter/Elasticsearch/Repository.php index 113013b..79bda77 100644 --- a/src/Adapter/Elasticsearch/Repository.php +++ b/src/Adapter/Elasticsearch/Repository.php @@ -53,7 +53,7 @@ final class Repository implements RepositoryInterface, Effectful private Decode $decode; private Painless $script; private Query $query; - /** @var Constraint */ + /** @var Constraint> */ private Constraint $pluckCount; /** @var Constraint> */ private Constraint $pluckHits; @@ -76,7 +76,7 @@ private function __construct( $this->script = Painless::new(); /** * @psalm-suppress MixedReturnStatement - * @var Constraint + * @var Constraint> */ $this->pluckCount = Is::shape( 'count', @@ -406,7 +406,7 @@ private static function url( } /** - * @param 0|positive-int $drop + * @param int<0, max> $drop * @return Sequence */ private function stream(int $drop, ?array $sort, ?array $query): Sequence @@ -463,8 +463,8 @@ private function stream(int $drop, ?array $sort, ?array $query): Sequence /** * @param callable(mixed): Maybe $decode * @param Constraint> $pluckHits - * @param 0|positive-int $drop - * @param positive-int $take + * @param int<0, max> $drop + * @param int<1, max> $take * * @return Sequence */ diff --git a/src/Adapter/Repository.php b/src/Adapter/Repository.php index ab1bc6a..de078c3 100644 --- a/src/Adapter/Repository.php +++ b/src/Adapter/Repository.php @@ -48,8 +48,8 @@ public function remove(Aggregate\Id $id): Attempt; public function removeAll(Specification $specification): Attempt; /** - * @param ?positive-int $drop - * @param ?positive-int $take + * @param ?int<1, max> $drop + * @param ?int<1, max> $take * * @return Sequence */ @@ -61,7 +61,7 @@ public function fetch( ): Sequence; /** - * @return 0|positive-int + * @return int<0, max> */ public function size(?Specification $specification = null): int; diff --git a/src/Adapter/Repository/CrossAggregateMatching.php b/src/Adapter/Repository/CrossAggregateMatching.php index 720be21..e124b5f 100644 --- a/src/Adapter/Repository/CrossAggregateMatching.php +++ b/src/Adapter/Repository/CrossAggregateMatching.php @@ -12,8 +12,8 @@ interface CrossAggregateMatching /** * @psalm-mutation-free * - * @param ?positive-int $drop - * @param ?positive-int $take + * @param ?int<1, max> $drop + * @param ?int<1, max> $take * * @return Maybe */ diff --git a/src/Adapter/SQL/Repository.php b/src/Adapter/SQL/Repository.php index d164eaf..614b294 100644 --- a/src/Adapter/SQL/Repository.php +++ b/src/Adapter/SQL/Repository.php @@ -230,7 +230,7 @@ public function size(?Specification $specification = null): int { $count = $this->mainTable->count($specification); - /** @var 0|positive-int SQL count() should never return a negative value */ + /** @var int<0, max> SQL count() should never return a negative value */ return ($this->connection)($count) ->first() ->flatMap(static fn($row) => $row->column('count')) diff --git a/src/Matching.php b/src/Matching.php index c8aae7a..0cef396 100644 --- a/src/Matching.php +++ b/src/Matching.php @@ -46,9 +46,9 @@ final class Matching private Sort $sort; private ?Specification $specification; private null|SortedBy\Property|SortedBy\Entity $sorted; - /** @var ?positive-int */ + /** @var ?int<1, max> */ private ?int $drop; - /** @var null|0|positive-int */ + /** @var ?int<0, max> */ private ?int $take; /** @@ -60,8 +60,8 @@ final class Matching * @param ?Normalize $normalizeSpecification * @param Loaded $loaded * @param Sort $sort - * @param ?positive-int $drop - * @param null|0|positive-int $take + * @param ?int<1, max> $drop + * @param ?int<0, max> $take */ private function __construct( Repository $repository, @@ -181,7 +181,7 @@ public static function all( /** * @psalm-mutation-free * - * @param positive-int $size + * @param int<1, max> $size * * @return self */ @@ -214,7 +214,7 @@ public function take(int $size): self /** * @psalm-mutation-free * - * @param positive-int $size + * @param int<1, max> $size * * @return self */ diff --git a/src/Repository.php b/src/Repository.php index 00ac80d..9c8c911 100644 --- a/src/Repository.php +++ b/src/Repository.php @@ -245,7 +245,7 @@ public function matching(Specification $specification): Matching } /** - * @return 0|positive-int + * @return int<0, max> */ public function size(?Specification $specification = null): int { From da565092dfd15f2f66748317de568c62434cf17a Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Mon, 22 Sep 2025 10:09:00 +0200 Subject: [PATCH 2/2] use promoted properties --- src/Adapter/Elasticsearch.php | 20 +++---- src/Adapter/Elasticsearch/CreateIndex.php | 23 ++++----- src/Adapter/Elasticsearch/DropIndex.php | 13 ++--- src/Adapter/Elasticsearch/Mapping.php | 7 +-- src/Adapter/Elasticsearch/Refresh.php | 5 +- src/Adapter/Filesystem.php | 7 +-- src/Adapter/Filesystem/Decode.php | 6 +-- src/Adapter/Filesystem/Fold.php | 6 +-- src/Adapter/Repository/SubMatch.php | 5 +- src/Adapter/SQL/Encode.php | 6 +-- src/Adapter/SQL/ShowCreateTable.php | 13 ++--- src/Adapter/SQL/SubQuery.php | 10 +--- src/Adapter/SQL/Transaction.php | 5 +- src/Adapter/SQL/Update.php | 6 +-- src/Definition/Aggregate.php | 36 +++---------- src/Definition/Aggregate/Collection.php | 20 ++----- src/Definition/Aggregate/Entity.php | 16 ++---- src/Definition/Aggregate/Identity.php | 13 ++--- src/Definition/Aggregate/Optional.php | 16 ++---- src/Definition/Aggregate/Parsing.php | 31 +++-------- src/Definition/Aggregate/Property.php | 14 ++--- src/Definition/Aggregates.php | 16 +++--- src/Definition/Contains.php | 6 +-- src/Definition/Type/EnumType.php | 6 +-- src/Definition/Type/MaybeType.php | 6 +-- src/Definition/Type/NullableType.php | 6 +-- src/Definition/Type/PointInTimeType.php | 11 ++-- src/Definition/Type/Support.php | 12 ++--- src/Definition/Types.php | 16 +++--- src/Id.php | 10 ++-- src/Matching.php | 63 +++++------------------ src/Raw/Aggregate.php | 25 ++------- src/Raw/Aggregate/Collection.php | 11 +--- src/Raw/Aggregate/Collection/Entity.php | 6 +-- src/Raw/Aggregate/Entity.php | 13 ++--- src/Raw/Aggregate/Id.php | 13 ++--- src/Raw/Aggregate/Optional.php | 13 ++--- src/Raw/Aggregate/Optional/BrandNew.php | 5 +- src/Raw/Aggregate/Property.php | 12 ++--- src/Raw/Diff.php | 25 ++------- src/Repository/Denormalized.php | 13 ++--- src/Repository/Diff/Property.php | 15 ++---- src/Repository/Sort.php | 6 +-- src/Sort/Entity.php | 12 ++--- src/Sort/Property.php | 12 ++--- src/Specification/Child.php | 12 ++--- src/Specification/CrossMatch.php | 10 +--- src/Specification/Entity.php | 12 ++--- src/Specification/Has.php | 6 +-- src/Specification/Just.php | 12 ++--- src/Specification/Property.php | 15 ++---- 51 files changed, 178 insertions(+), 500 deletions(-) diff --git a/src/Adapter/Elasticsearch.php b/src/Adapter/Elasticsearch.php index e6468e8..f619f21 100644 --- a/src/Adapter/Elasticsearch.php +++ b/src/Adapter/Elasticsearch.php @@ -12,20 +12,20 @@ final class Elasticsearch implements Adapter { - private Transport $transport; - private Url $url; - private Elasticsearch\Transaction $transaction; - - private function __construct(Transport $transport, Url $url) - { - $this->transport = $transport; - $this->url = $url; - $this->transaction = Elasticsearch\Transaction::of(); + private function __construct( + private Transport $transport, + private Url $url, + private Elasticsearch\Transaction $transaction, + ) { } public static function of(Transport $transport, ?Url $url = null): self { - return new self($transport, $url ?? Url::of('http://localhost:9200/')); + return new self( + $transport, + $url ?? Url::of('http://localhost:9200/'), + Elasticsearch\Transaction::of(), + ); } #[\Override] diff --git a/src/Adapter/Elasticsearch/CreateIndex.php b/src/Adapter/Elasticsearch/CreateIndex.php index f8889ee..06c9467 100644 --- a/src/Adapter/Elasticsearch/CreateIndex.php +++ b/src/Adapter/Elasticsearch/CreateIndex.php @@ -26,20 +26,12 @@ final class CreateIndex { - private Transport $http; - private Aggregates $aggregates; - private Mapping $mapping; - private Url $url; - private function __construct( - Transport $http, - Aggregates $aggregates, - Url $url, + private Transport $http, + private Aggregates $aggregates, + private Mapping $mapping, + private Url $url, ) { - $this->http = $http; - $this->aggregates = $aggregates; - $this->mapping = Mapping::new(); - $this->url = $url; } /** @@ -73,6 +65,11 @@ public static function of( Aggregates $aggregates, Url $url, ): self { - return new self($transport, $aggregates, $url); + return new self( + $transport, + $aggregates, + Mapping::new(), + $url, + ); } } diff --git a/src/Adapter/Elasticsearch/DropIndex.php b/src/Adapter/Elasticsearch/DropIndex.php index bc55a7e..58773a9 100644 --- a/src/Adapter/Elasticsearch/DropIndex.php +++ b/src/Adapter/Elasticsearch/DropIndex.php @@ -22,18 +22,11 @@ final class DropIndex { - private Transport $http; - private Aggregates $aggregates; - private Url $url; - private function __construct( - Transport $http, - Aggregates $aggregates, - Url $url, + private Transport $http, + private Aggregates $aggregates, + private Url $url, ) { - $this->http = $http; - $this->aggregates = $aggregates; - $this->url = $url; } /** diff --git a/src/Adapter/Elasticsearch/Mapping.php b/src/Adapter/Elasticsearch/Mapping.php index b921bf7..a55904c 100644 --- a/src/Adapter/Elasticsearch/Mapping.php +++ b/src/Adapter/Elasticsearch/Mapping.php @@ -11,11 +11,8 @@ */ final class Mapping { - private MapType $mapType; - - private function __construct() + private function __construct(private MapType $mapType) { - $this->mapType = MapType::new(); } public function __invoke(Definition $definition): array @@ -61,7 +58,7 @@ public function __invoke(Definition $definition): array */ public static function new(): self { - return new self; + return new self(MapType::new()); } /** diff --git a/src/Adapter/Elasticsearch/Refresh.php b/src/Adapter/Elasticsearch/Refresh.php index bbeb425..97aae75 100644 --- a/src/Adapter/Elasticsearch/Refresh.php +++ b/src/Adapter/Elasticsearch/Refresh.php @@ -13,11 +13,8 @@ final class Refresh implements Transport { - private Transport $transport; - - private function __construct(Transport $transport) + private function __construct(private Transport $transport) { - $this->transport = $transport; } #[\Override] diff --git a/src/Adapter/Filesystem.php b/src/Adapter/Filesystem.php index fcc5263..c6be582 100644 --- a/src/Adapter/Filesystem.php +++ b/src/Adapter/Filesystem.php @@ -11,16 +11,13 @@ final class Filesystem implements Adapter { - private Filesystem\Transaction $transaction; - - private function __construct(Storage $adapter) + private function __construct(private Filesystem\Transaction $transaction) { - $this->transaction = Filesystem\Transaction::of($adapter); } public static function of(Storage $adapter): self { - return new self($adapter); + return new self(Filesystem\Transaction::of($adapter)); } #[\Override] diff --git a/src/Adapter/Filesystem/Decode.php b/src/Adapter/Filesystem/Decode.php index 4f4ca3c..a55eb78 100644 --- a/src/Adapter/Filesystem/Decode.php +++ b/src/Adapter/Filesystem/Decode.php @@ -25,15 +25,11 @@ */ final class Decode { - /** @var Definition */ - private Definition $definition; - /** * @param Definition $definition */ - private function __construct(Definition $definition) + private function __construct(private Definition $definition) { - $this->definition = $definition; } /** diff --git a/src/Adapter/Filesystem/Fold.php b/src/Adapter/Filesystem/Fold.php index 0fa0bb1..31f0b2a 100644 --- a/src/Adapter/Filesystem/Fold.php +++ b/src/Adapter/Filesystem/Fold.php @@ -29,15 +29,11 @@ */ final class Fold { - /** @var Definition */ - private Definition $definition; - /** * @param Definition $definition */ - private function __construct(Definition $definition) + private function __construct(private Definition $definition) { - $this->definition = $definition; } /** diff --git a/src/Adapter/Repository/SubMatch.php b/src/Adapter/Repository/SubMatch.php index 00e5f20..84aa06f 100644 --- a/src/Adapter/Repository/SubMatch.php +++ b/src/Adapter/Repository/SubMatch.php @@ -9,11 +9,8 @@ */ final class SubMatch { - private mixed $value; - - private function __construct(mixed $value) + private function __construct(private mixed $value) { - $this->value = $value; } /** diff --git a/src/Adapter/SQL/Encode.php b/src/Adapter/SQL/Encode.php index d48d919..4cc75c1 100644 --- a/src/Adapter/SQL/Encode.php +++ b/src/Adapter/SQL/Encode.php @@ -14,15 +14,11 @@ */ final class Encode { - /** @var MainTable */ - private MainTable $mainTable; - /** * @param MainTable $mainTable */ - private function __construct(MainTable $mainTable) + private function __construct(private MainTable $mainTable) { - $this->mainTable = $mainTable; } /** diff --git a/src/Adapter/SQL/ShowCreateTable.php b/src/Adapter/SQL/ShowCreateTable.php index 9fcbfa8..269195d 100644 --- a/src/Adapter/SQL/ShowCreateTable.php +++ b/src/Adapter/SQL/ShowCreateTable.php @@ -14,21 +14,14 @@ final class ShowCreateTable { - private Aggregates $aggregates; - private MapType $mapType; - private bool $ifNotExists; - /** * @psalm-mutation-free */ private function __construct( - Aggregates $aggregates, - MapType $mapType, - bool $ifNotExists, + private Aggregates $aggregates, + private MapType $mapType, + private bool $ifNotExists, ) { - $this->aggregates = $aggregates; - $this->mapType = $mapType; - $this->ifNotExists = $ifNotExists; } /** diff --git a/src/Adapter/SQL/SubQuery.php b/src/Adapter/SQL/SubQuery.php index 987ab24..14d8679 100644 --- a/src/Adapter/SQL/SubQuery.php +++ b/src/Adapter/SQL/SubQuery.php @@ -18,19 +18,13 @@ final class SubQuery implements Comparator { use Composable; - /** @var non-empty-string */ - private string $property; - private Query $query; - /** * @param non-empty-string $property */ private function __construct( - string $property, - Query $query, + private string $property, + private Query $query, ) { - $this->property = $property; - $this->query = $query; } /** diff --git a/src/Adapter/SQL/Transaction.php b/src/Adapter/SQL/Transaction.php index 2d35103..119971a 100644 --- a/src/Adapter/SQL/Transaction.php +++ b/src/Adapter/SQL/Transaction.php @@ -20,11 +20,8 @@ */ final class Transaction implements TransactionInterface { - private Connection $connection; - - private function __construct(Connection $connection) + private function __construct(private Connection $connection) { - $this->connection = $connection; } /** diff --git a/src/Adapter/SQL/Update.php b/src/Adapter/SQL/Update.php index fdeb0c4..4f6b0a1 100644 --- a/src/Adapter/SQL/Update.php +++ b/src/Adapter/SQL/Update.php @@ -14,15 +14,11 @@ */ final class Update { - /** @var MainTable */ - private MainTable $mainTable; - /** * @param MainTable $mainTable */ - private function __construct(MainTable $mainTable) + private function __construct(private MainTable $mainTable) { - $this->mainTable = $mainTable; } /** diff --git a/src/Definition/Aggregate.php b/src/Definition/Aggregate.php index 6f5ae35..d99e112 100644 --- a/src/Definition/Aggregate.php +++ b/src/Definition/Aggregate.php @@ -17,21 +17,6 @@ */ final class Aggregate { - /** @var class-string */ - private string $class; - /** @var non-empty-string */ - private string $name; - /** @var Aggregate\Identity */ - private Aggregate\Identity $id; - /** @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 non-empty-string $name @@ -42,21 +27,14 @@ final class Aggregate * @param Sequence $collections */ private function __construct( - string $class, - string $name, - Aggregate\Identity $id, - Sequence $properties, - Sequence $entities, - Sequence $optionals, - Sequence $collections, + private string $class, + private string $name, + private Aggregate\Identity $id, + private Sequence $properties, + private Sequence $entities, + private Sequence $optionals, + private Sequence $collections, ) { - $this->class = $class; - $this->name = $name; - $this->id = $id; - $this->properties = $properties; - $this->entities = $entities; - $this->optionals = $optionals; - $this->collections = $collections; } /** diff --git a/src/Definition/Aggregate/Collection.php b/src/Definition/Aggregate/Collection.php index d83d2e6..c7d28ab 100644 --- a/src/Definition/Aggregate/Collection.php +++ b/src/Definition/Aggregate/Collection.php @@ -12,29 +12,17 @@ */ final class Collection { - /** @var class-string */ - private string $class; - /** @var non-empty-string */ - private string $name; - /** @var Sequence> */ - private Sequence $properties; - private bool $enum; - /** * @param class-string $class * @param non-empty-string $name * @param Sequence> $properties */ private function __construct( - string $class, - string $name, - Sequence $properties, - bool $enum, + private string $class, + private string $name, + private Sequence $properties, + private bool $enum, ) { - $this->class = $class; - $this->name = $name; - $this->properties = $properties; - $this->enum = $enum; } /** diff --git a/src/Definition/Aggregate/Entity.php b/src/Definition/Aggregate/Entity.php index c2f6ade..2abd8e3 100644 --- a/src/Definition/Aggregate/Entity.php +++ b/src/Definition/Aggregate/Entity.php @@ -11,26 +11,16 @@ */ final class Entity { - /** @var class-string */ - private string $class; - /** @var non-empty-string */ - private string $name; - /** @var Sequence> */ - private Sequence $properties; - /** * @param class-string $class * @param non-empty-string $name * @param Sequence> $properties */ private function __construct( - string $class, - string $name, - Sequence $properties, + private string $class, + private string $name, + private Sequence $properties, ) { - $this->class = $class; - $this->name = $name; - $this->properties = $properties; } /** diff --git a/src/Definition/Aggregate/Identity.php b/src/Definition/Aggregate/Identity.php index f0519a3..c8ddf99 100644 --- a/src/Definition/Aggregate/Identity.php +++ b/src/Definition/Aggregate/Identity.php @@ -18,21 +18,16 @@ */ final class Identity { - /** @var non-empty-string */ - private string $property; - /** @var class-string */ - private string $class; - /** * @psalm-mutation-free * * @param non-empty-string $property * @param class-string $class */ - private function __construct(string $property, string $class) - { - $this->property = $property; - $this->class = $class; + private function __construct( + private string $property, + private string $class, + ) { } /** diff --git a/src/Definition/Aggregate/Optional.php b/src/Definition/Aggregate/Optional.php index aa8ab95..328db1e 100644 --- a/src/Definition/Aggregate/Optional.php +++ b/src/Definition/Aggregate/Optional.php @@ -11,26 +11,16 @@ */ final class Optional { - /** @var class-string */ - private string $class; - /** @var non-empty-string */ - private string $name; - /** @var Sequence> */ - private Sequence $properties; - /** * @param class-string $class * @param non-empty-string $name * @param Sequence> $properties */ private function __construct( - string $class, - string $name, - Sequence $properties, + private string $class, + private string $name, + private Sequence $properties, ) { - $this->class = $class; - $this->name = $name; - $this->properties = $properties; } /** diff --git a/src/Definition/Aggregate/Parsing.php b/src/Definition/Aggregate/Parsing.php index b4bd371..a47b282 100644 --- a/src/Definition/Aggregate/Parsing.php +++ b/src/Definition/Aggregate/Parsing.php @@ -26,19 +26,6 @@ */ final class Parsing { - /** @var class-string */ - private string $class; - /** @var Maybe> */ - private Maybe $id; - /** @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 @@ -48,19 +35,13 @@ final class Parsing * @param Sequence $collections */ private function __construct( - string $class, - Maybe $id, - Sequence $properties, - Sequence $entities, - Sequence $optionals, - Sequence $collections, + private string $class, + private Maybe $id, + private Sequence $properties, + private Sequence $entities, + private Sequence $optionals, + private Sequence $collections, ) { - $this->class = $class; - $this->id = $id; - $this->properties = $properties; - $this->entities = $entities; - $this->optionals = $optionals; - $this->collections = $collections; } /** diff --git a/src/Definition/Aggregate/Property.php b/src/Definition/Aggregate/Property.php index 0a39052..eb85861 100644 --- a/src/Definition/Aggregate/Property.php +++ b/src/Definition/Aggregate/Property.php @@ -12,20 +12,16 @@ */ final class Property { - /** @var non-empty-string */ - private string $name; - /** @var Type */ - private Type $type; - /** * @param class-string $class * @param non-empty-string $name * @param Type $type */ - private function __construct(string $class, string $name, Type $type) - { - $this->name = $name; - $this->type = $type; + private function __construct( + string $class, // only here for the template + private string $name, + private Type $type, + ) { } /** diff --git a/src/Definition/Aggregates.php b/src/Definition/Aggregates.php index 0ef0330..31724fa 100644 --- a/src/Definition/Aggregates.php +++ b/src/Definition/Aggregates.php @@ -5,17 +5,13 @@ final class Aggregates { - private Types $types; - /** @var ?callable(class-string): non-empty-string */ - private $mapName; - /** - * @param callable(class-string): non-empty-string $mapName + * @param ?\Closure(class-string): non-empty-string $mapName */ - private function __construct(Types $types, ?callable $mapName) - { - $this->types = $types; - $this->mapName = $mapName; + private function __construct( + private Types $types, + private ?\Closure $mapName, + ) { } public static function of(Types $types): self @@ -30,7 +26,7 @@ public static function of(Types $types): self */ public function mapName(callable $map): self { - return new self($this->types, $map); + return new self($this->types, \Closure::fromCallable($map)); } /** diff --git a/src/Definition/Contains.php b/src/Definition/Contains.php index 2a2af4c..81cec33 100644 --- a/src/Definition/Contains.php +++ b/src/Definition/Contains.php @@ -11,15 +11,11 @@ #[\Attribute(\Attribute::TARGET_PROPERTY)] final class Contains { - /** @var class-string */ - private string $type; - /** * @param class-string $type */ - public function __construct(string $type) + public function __construct(private string $type) { - $this->type = $type; } /** diff --git a/src/Definition/Type/EnumType.php b/src/Definition/Type/EnumType.php index c90da05..24491ac 100644 --- a/src/Definition/Type/EnumType.php +++ b/src/Definition/Type/EnumType.php @@ -23,15 +23,11 @@ */ final class EnumType implements Type { - /** @var class-string */ - private string $class; - /** * @param class-string $class */ - private function __construct(string $class) + private function __construct(private string $class) { - $this->class = $class; } /** diff --git a/src/Definition/Type/MaybeType.php b/src/Definition/Type/MaybeType.php index 95dc653..68440ee 100644 --- a/src/Definition/Type/MaybeType.php +++ b/src/Definition/Type/MaybeType.php @@ -21,15 +21,11 @@ */ final class MaybeType implements Type { - /** @var Type */ - private Type $inner; - /** * @param Type $inner */ - private function __construct(Type $inner) + private function __construct(private Type $inner) { - $this->inner = $inner; } /** diff --git a/src/Definition/Type/NullableType.php b/src/Definition/Type/NullableType.php index cec9f5c..6f6f359 100644 --- a/src/Definition/Type/NullableType.php +++ b/src/Definition/Type/NullableType.php @@ -23,15 +23,11 @@ */ final class NullableType implements Type { - /** @var Type */ - private Type $inner; - /** * @param Type $inner */ - private function __construct(Type $inner) + private function __construct(private Type $inner) { - $this->inner = $inner; } /** diff --git a/src/Definition/Type/PointInTimeType.php b/src/Definition/Type/PointInTimeType.php index 8f429c1..1984229 100644 --- a/src/Definition/Type/PointInTimeType.php +++ b/src/Definition/Type/PointInTimeType.php @@ -18,13 +18,10 @@ */ final class PointInTimeType implements Type { - private Clock $clock; - private Formats $format; - - private function __construct(Clock $clock, Formats $format) - { - $this->clock = $clock; - $this->format = $format; + private function __construct( + private Clock $clock, + private Formats $format, + ) { } /** diff --git a/src/Definition/Type/Support.php b/src/Definition/Type/Support.php index 7bf79ba..2dff3df 100644 --- a/src/Definition/Type/Support.php +++ b/src/Definition/Type/Support.php @@ -19,17 +19,13 @@ */ final class Support { - /** @var class-string */ - private string $class; - private Type $via; - /** * @param class-string $class */ - private function __construct(string $class, Type $via) - { - $this->class = $class; - $this->via = $via; + private function __construct( + private string $class, + private Type $via, + ) { } /** diff --git a/src/Definition/Types.php b/src/Definition/Types.php index bf4e10a..5d4ff7b 100644 --- a/src/Definition/Types.php +++ b/src/Definition/Types.php @@ -14,17 +14,13 @@ */ final class Types { - /** @var list> */ - private array $builders; - /** * @no-named-arguments * - * @param callable(self, Concrete, Contains|Contains\Primitive|null): Maybe $builders + * @param list> $builders */ - private function __construct(callable ...$builders) + private function __construct(private array $builders) { - $this->builders = $builders; } /** @@ -52,7 +48,7 @@ public function __invoke( */ public static function of(callable ...$builders): self { - return new self( + return new self([ Type\NullableType::of(...), Type\MaybeType::of(...), Type\StringType::of(...), @@ -65,7 +61,7 @@ public static function of(callable ...$builders): self Type\IdType::of(...), Type\EnumType::of(...), ...$builders, - ); + ]); } /** @@ -73,7 +69,7 @@ public static function of(callable ...$builders): self */ public static function default(): self { - return new self( + return new self([ Type\NullableType::of(...), Type\MaybeType::of(...), Type\StringType::of(...), @@ -85,6 +81,6 @@ public static function default(): self Type\BoolType::of(...), Type\IdType::of(...), Type\EnumType::of(...), - ); + ]); } } diff --git a/src/Id.php b/src/Id.php index 1fd0706..e23c335 100644 --- a/src/Id.php +++ b/src/Id.php @@ -11,16 +11,14 @@ */ final class Id { - /** @var non-empty-string */ - private string $value; - /** * @param class-string $class * @param non-empty-string $value */ - private function __construct(string $class, string $value) - { - $this->value = $value; + private function __construct( + string $class, // only here for the template + private string $value, + ) { } public function __clone() diff --git a/src/Matching.php b/src/Matching.php index 0cef396..83df7fc 100644 --- a/src/Matching.php +++ b/src/Matching.php @@ -27,30 +27,6 @@ */ final class Matching { - /** @var Repository */ - private Repository $repository; - /** @var Adapter\Repository */ - private Adapter\Repository $adapter; - /** @var Identity */ - private Identity $identity; - private Repository\Context $context; - /** @var Denormalize */ - private Denormalize $denormalize; - /** @var Instanciate */ - private Instanciate $instanciate; - /** @var ?Normalize */ - private ?Normalize $normalizeSpecification; - /** @var Loaded */ - private Loaded $loaded; - /** @var Sort */ - private Sort $sort; - private ?Specification $specification; - private null|SortedBy\Property|SortedBy\Entity $sorted; - /** @var ?int<1, max> */ - private ?int $drop; - /** @var ?int<0, max> */ - private ?int $take; - /** * @param Repository $repository * @param Adapter\Repository $adapter @@ -64,33 +40,20 @@ final class Matching * @param ?int<0, max> $take */ private function __construct( - Repository $repository, - Adapter\Repository $adapter, - Identity $identity, - Repository\Context $context, - Denormalize $denormalize, - Instanciate $instanciate, - ?Normalize $normalizeSpecification, - Loaded $loaded, - Sort $sort, - ?Specification $specification, - null|SortedBy\Property|SortedBy\Entity $sorted, - ?int $drop, - ?int $take, + private Repository $repository, + private Adapter\Repository $adapter, + private Identity $identity, + private Repository\Context $context, + private Denormalize $denormalize, + private Instanciate $instanciate, + private ?Normalize $normalizeSpecification, + private Loaded $loaded, + private Sort $sort, + private ?Specification $specification, + private null|SortedBy\Property|SortedBy\Entity $sorted, + private ?int $drop, + private ?int $take, ) { - $this->repository = $repository; - $this->adapter = $adapter; - $this->identity = $identity; - $this->context = $context; - $this->denormalize = $denormalize; - $this->instanciate = $instanciate; - $this->normalizeSpecification = $normalizeSpecification; - $this->loaded = $loaded; - $this->sort = $sort; - $this->specification = $specification; - $this->sorted = $sorted; - $this->drop = $drop; - $this->take = $take; } /** diff --git a/src/Raw/Aggregate.php b/src/Raw/Aggregate.php index 6134e88..3f5a734 100644 --- a/src/Raw/Aggregate.php +++ b/src/Raw/Aggregate.php @@ -10,16 +10,6 @@ */ final class Aggregate { - private Aggregate\Id $id; - /** @var Sequence */ - private Sequence $properties; - /** @var Sequence */ - private Sequence $entities; - /** @var Sequence */ - private Sequence $optionals; - /** @var Sequence */ - private Sequence $collections; - /** * @param Sequence $properties * @param Sequence $entities @@ -27,17 +17,12 @@ final class Aggregate * @param Sequence $collections */ private function __construct( - Aggregate\Id $id, - Sequence $properties, - Sequence $entities, - Sequence $optionals, - Sequence $collections, + private Aggregate\Id $id, + private Sequence $properties, + private Sequence $entities, + private Sequence $optionals, + private Sequence $collections, ) { - $this->id = $id; - $this->properties = $properties; - $this->entities = $entities; - $this->optionals = $optionals; - $this->collections = $collections; } /** diff --git a/src/Raw/Aggregate/Collection.php b/src/Raw/Aggregate/Collection.php index f7f66f5..2148904 100644 --- a/src/Raw/Aggregate/Collection.php +++ b/src/Raw/Aggregate/Collection.php @@ -11,21 +11,14 @@ */ final class Collection { - /** @var non-empty-string */ - private string $name; - /** @var Set */ - private Set $entities; - /** * @param non-empty-string $name * @param Set $entities */ private function __construct( - string $name, - Set $entities, + private string $name, + private Set $entities, ) { - $this->name = $name; - $this->entities = $entities; } /** diff --git a/src/Raw/Aggregate/Collection/Entity.php b/src/Raw/Aggregate/Collection/Entity.php index 53517a7..f419a82 100644 --- a/src/Raw/Aggregate/Collection/Entity.php +++ b/src/Raw/Aggregate/Collection/Entity.php @@ -11,15 +11,11 @@ */ final class Entity { - /** @var Sequence */ - private Sequence $properties; - /** * @param Sequence $properties */ - private function __construct(Sequence $properties) + private function __construct(private Sequence $properties) { - $this->properties = $properties; } /** diff --git a/src/Raw/Aggregate/Entity.php b/src/Raw/Aggregate/Entity.php index 7840ab1..d7f4e5b 100644 --- a/src/Raw/Aggregate/Entity.php +++ b/src/Raw/Aggregate/Entity.php @@ -10,19 +10,14 @@ */ final class Entity { - /** @var non-empty-string */ - private string $name; - /** @var Sequence */ - private Sequence $properties; - /** * @param non-empty-string $name * @param Sequence $properties */ - private function __construct(string $name, Sequence $properties) - { - $this->name = $name; - $this->properties = $properties; + private function __construct( + private string $name, + private Sequence $properties, + ) { } /** diff --git a/src/Raw/Aggregate/Id.php b/src/Raw/Aggregate/Id.php index a2c9b7f..dc3eb71 100644 --- a/src/Raw/Aggregate/Id.php +++ b/src/Raw/Aggregate/Id.php @@ -8,19 +8,14 @@ */ final class Id { - /** @var non-empty-string */ - private string $name; - /** @var non-empty-string */ - private string $value; - /** * @param non-empty-string $name * @param non-empty-string $value */ - private function __construct(string $name, string $value) - { - $this->name = $name; - $this->value = $value; + private function __construct( + private string $name, + private string $value, + ) { } /** diff --git a/src/Raw/Aggregate/Optional.php b/src/Raw/Aggregate/Optional.php index a3f3eb3..8e931cb 100644 --- a/src/Raw/Aggregate/Optional.php +++ b/src/Raw/Aggregate/Optional.php @@ -13,19 +13,14 @@ */ final class Optional { - /** @var non-empty-string */ - private string $name; - /** @var Maybe> */ - private Maybe $properties; - /** * @param non-empty-string $name * @param Maybe> $properties */ - private function __construct(string $name, Maybe $properties) - { - $this->name = $name; - $this->properties = $properties; + private function __construct( + private string $name, + private Maybe $properties, + ) { } /** diff --git a/src/Raw/Aggregate/Optional/BrandNew.php b/src/Raw/Aggregate/Optional/BrandNew.php index d3f477c..98dbda9 100644 --- a/src/Raw/Aggregate/Optional/BrandNew.php +++ b/src/Raw/Aggregate/Optional/BrandNew.php @@ -20,11 +20,8 @@ */ final class BrandNew { - private Optional $optional; - - private function __construct(Optional $optional) + private function __construct(private Optional $optional) { - $this->optional = $optional; } /** diff --git a/src/Raw/Aggregate/Property.php b/src/Raw/Aggregate/Property.php index 975fe6b..291cf07 100644 --- a/src/Raw/Aggregate/Property.php +++ b/src/Raw/Aggregate/Property.php @@ -8,17 +8,13 @@ */ final class Property { - /** @var non-empty-string */ - private string $name; - private null|string|int|float|bool $value; - /** * @param non-empty-string $name */ - private function __construct(string $name, null|string|int|float|bool $value) - { - $this->name = $name; - $this->value = $value; + private function __construct( + private string $name, + private null|string|int|float|bool $value, + ) { } /** diff --git a/src/Raw/Diff.php b/src/Raw/Diff.php index 21a48b5..175130e 100644 --- a/src/Raw/Diff.php +++ b/src/Raw/Diff.php @@ -10,16 +10,6 @@ */ final class Diff { - private Aggregate\Id $id; - /** @var Sequence */ - private Sequence $properties; - /** @var Sequence */ - private Sequence $entities; - /** @var Sequence */ - private Sequence $optionals; - /** @var Sequence */ - private Sequence $collections; - /** * @param Sequence $properties * @param Sequence $entities @@ -27,17 +17,12 @@ final class Diff * @param Sequence $collections */ private function __construct( - Aggregate\Id $id, - Sequence $properties, - Sequence $entities, - Sequence $optionals, - Sequence $collections, + private Aggregate\Id $id, + private Sequence $properties, + private Sequence $entities, + private Sequence $optionals, + private Sequence $collections, ) { - $this->id = $id; - $this->properties = $properties; - $this->entities = $entities; - $this->optionals = $optionals; - $this->collections = $collections; } /** diff --git a/src/Repository/Denormalized.php b/src/Repository/Denormalized.php index 1955e6a..867e12e 100644 --- a/src/Repository/Denormalized.php +++ b/src/Repository/Denormalized.php @@ -13,19 +13,14 @@ */ final class Denormalized { - /** @var Id */ - private Id $id; - /** @var Map */ - private Map $properties; - /** * @param Id $id * @param Map $properties */ - private function __construct(Id $id, Map $properties) - { - $this->id = $id; - $this->properties = $properties; + private function __construct( + private Id $id, + private Map $properties, + ) { } /** diff --git a/src/Repository/Diff/Property.php b/src/Repository/Diff/Property.php index cf5ca02..03c2dad 100644 --- a/src/Repository/Diff/Property.php +++ b/src/Repository/Diff/Property.php @@ -8,19 +8,14 @@ */ final class Property { - /** @var non-empty-string */ - private string $name; - private mixed $then; - private mixed $now; - /** * @param non-empty-string $name */ - private function __construct(string $name, mixed $then, mixed $now) - { - $this->name = $name; - $this->then = $then; - $this->now = $now; + private function __construct( + private string $name, + private mixed $then, + private mixed $now, + ) { } /** diff --git a/src/Repository/Sort.php b/src/Repository/Sort.php index 6ef938b..09af7bf 100644 --- a/src/Repository/Sort.php +++ b/src/Repository/Sort.php @@ -21,15 +21,11 @@ */ final class Sort { - /** @var Definition */ - private Definition $definition; - /** * @param Definition $definition */ - private function __construct(Definition $definition) + private function __construct(private Definition $definition) { - $this->definition = $definition; } /** diff --git a/src/Sort/Entity.php b/src/Sort/Entity.php index a155413..1f1cab9 100644 --- a/src/Sort/Entity.php +++ b/src/Sort/Entity.php @@ -12,17 +12,13 @@ */ final class Entity { - /** @var non-empty-string */ - private string $name; - private Property $property; - /** * @param non-empty-string $name */ - private function __construct(string $name, Property $property) - { - $this->name = $name; - $this->property = $property; + private function __construct( + private string $name, + private Property $property, + ) { } /** diff --git a/src/Sort/Property.php b/src/Sort/Property.php index 4abfd4e..049cda4 100644 --- a/src/Sort/Property.php +++ b/src/Sort/Property.php @@ -10,17 +10,13 @@ */ final class Property { - /** @var non-empty-string */ - private string $name; - private Direction $direction; - /** * @param non-empty-string $name */ - private function __construct(string $name, Direction $direction) - { - $this->name = $name; - $this->direction = $direction; + private function __construct( + private string $name, + private Direction $direction, + ) { } /** diff --git a/src/Specification/Child.php b/src/Specification/Child.php index 95a02f5..da332c9 100644 --- a/src/Specification/Child.php +++ b/src/Specification/Child.php @@ -15,17 +15,13 @@ final class Child implements Specification { use Composable; - /** @var non-empty-string */ - private string $collection; - private Specification $specification; - /** * @param non-empty-string $collection */ - private function __construct(string $collection, Specification $specification) - { - $this->collection = $collection; - $this->specification = $specification; + private function __construct( + private string $collection, + private Specification $specification, + ) { } /** diff --git a/src/Specification/CrossMatch.php b/src/Specification/CrossMatch.php index 4f9ea38..87170b4 100644 --- a/src/Specification/CrossMatch.php +++ b/src/Specification/CrossMatch.php @@ -18,19 +18,13 @@ final class CrossMatch implements Comparator { use Composable; - /** @var non-empty-string */ - private string $property; - private SubMatch $value; - /** * @param non-empty-string $property */ private function __construct( - string $property, - SubMatch $value, + private string $property, + private SubMatch $value, ) { - $this->property = $property; - $this->value = $value; } /** diff --git a/src/Specification/Entity.php b/src/Specification/Entity.php index 54e30a1..ffe656e 100644 --- a/src/Specification/Entity.php +++ b/src/Specification/Entity.php @@ -15,17 +15,13 @@ final class Entity implements Specification { use Composable; - /** @var non-empty-string */ - private string $entity; - private Specification $specification; - /** * @param non-empty-string $entity */ - private function __construct(string $entity, Specification $specification) - { - $this->entity = $entity; - $this->specification = $specification; + private function __construct( + private string $entity, + private Specification $specification, + ) { } /** diff --git a/src/Specification/Has.php b/src/Specification/Has.php index 8eee082..38be773 100644 --- a/src/Specification/Has.php +++ b/src/Specification/Has.php @@ -15,15 +15,11 @@ final class Has implements Specification { use Composable; - /** @var non-empty-string */ - private string $optional; - /** * @param non-empty-string $optional */ - private function __construct(string $optional) + private function __construct(private string $optional) { - $this->optional = $optional; } /** diff --git a/src/Specification/Just.php b/src/Specification/Just.php index 7c48f55..94738a2 100644 --- a/src/Specification/Just.php +++ b/src/Specification/Just.php @@ -15,17 +15,13 @@ final class Just implements Specification { use Composable; - /** @var non-empty-string */ - private string $optional; - private Specification $specification; - /** * @param non-empty-string $optional */ - private function __construct(string $optional, Specification $specification) - { - $this->optional = $optional; - $this->specification = $specification; + private function __construct( + private string $optional, + private Specification $specification, + ) { } /** diff --git a/src/Specification/Property.php b/src/Specification/Property.php index 05a973a..58295e2 100644 --- a/src/Specification/Property.php +++ b/src/Specification/Property.php @@ -19,24 +19,15 @@ final class Property implements Comparator { use Composable; - /** @var non-empty-string */ - private string $property; - private Sign $sign; - /** @var null|string|int|float|bool|list */ - private null|string|int|float|bool|array $value; - /** * @param non-empty-string $property * @param null|string|int|float|bool|list $value */ private function __construct( - string $property, - Sign $sign, - null|string|int|float|bool|array $value, + private string $property, + private Sign $sign, + private null|string|int|float|bool|array $value, ) { - $this->property = $property; - $this->sign = $sign; - $this->value = $value; } /**