Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/Adapter/Elasticsearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
23 changes: 10 additions & 13 deletions src/Adapter/Elasticsearch/CreateIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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,
);
}
}
13 changes: 3 additions & 10 deletions src/Adapter/Elasticsearch/DropIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
7 changes: 2 additions & 5 deletions src/Adapter/Elasticsearch/Mapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -61,7 +58,7 @@ public function __invoke(Definition $definition): array
*/
public static function new(): self
{
return new self;
return new self(MapType::new());
}

/**
Expand Down
5 changes: 1 addition & 4 deletions src/Adapter/Elasticsearch/Refresh.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
10 changes: 5 additions & 5 deletions src/Adapter/Elasticsearch/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ final class Repository implements RepositoryInterface, Effectful
private Decode $decode;
private Painless $script;
private Query $query;
/** @var Constraint<mixed, 0|positive-int> */
/** @var Constraint<mixed, int<0, max>> */
private Constraint $pluckCount;
/** @var Constraint<mixed, Sequence<array>> */
private Constraint $pluckHits;
Expand All @@ -76,7 +76,7 @@ private function __construct(
$this->script = Painless::new();
/**
* @psalm-suppress MixedReturnStatement
* @var Constraint<mixed, 0|positive-int>
* @var Constraint<mixed, int<0, max>>
*/
$this->pluckCount = Is::shape(
'count',
Expand Down Expand Up @@ -406,7 +406,7 @@ private static function url(
}

/**
* @param 0|positive-int $drop
* @param int<0, max> $drop
* @return Sequence<Aggregate>
*/
private function stream(int $drop, ?array $sort, ?array $query): Sequence
Expand Down Expand Up @@ -463,8 +463,8 @@ private function stream(int $drop, ?array $sort, ?array $query): Sequence
/**
* @param callable(mixed): Maybe<Aggregate> $decode
* @param Constraint<mixed, Sequence<array>> $pluckHits
* @param 0|positive-int $drop
* @param positive-int $take
* @param int<0, max> $drop
* @param int<1, max> $take
*
* @return Sequence<Aggregate>
*/
Expand Down
7 changes: 2 additions & 5 deletions src/Adapter/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
6 changes: 1 addition & 5 deletions src/Adapter/Filesystem/Decode.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,11 @@
*/
final class Decode
{
/** @var Definition<T> */
private Definition $definition;

/**
* @param Definition<T> $definition
*/
private function __construct(Definition $definition)
private function __construct(private Definition $definition)
{
$this->definition = $definition;
}

/**
Expand Down
6 changes: 1 addition & 5 deletions src/Adapter/Filesystem/Fold.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,11 @@
*/
final class Fold
{
/** @var Definition<T> */
private Definition $definition;

/**
* @param Definition<T> $definition
*/
private function __construct(Definition $definition)
private function __construct(private Definition $definition)
{
$this->definition = $definition;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Adapter/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<Aggregate>
*/
Expand All @@ -61,7 +61,7 @@ public function fetch(
): Sequence;

/**
* @return 0|positive-int
* @return int<0, max>
*/
public function size(?Specification $specification = null): int;

Expand Down
4 changes: 2 additions & 2 deletions src/Adapter/Repository/CrossAggregateMatching.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<SubMatch>
*/
Expand Down
5 changes: 1 addition & 4 deletions src/Adapter/Repository/SubMatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@
*/
final class SubMatch
{
private mixed $value;

private function __construct(mixed $value)
private function __construct(private mixed $value)
{
$this->value = $value;
}

/**
Expand Down
6 changes: 1 addition & 5 deletions src/Adapter/SQL/Encode.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,11 @@
*/
final class Encode
{
/** @var MainTable<T> */
private MainTable $mainTable;

/**
* @param MainTable<T> $mainTable
*/
private function __construct(MainTable $mainTable)
private function __construct(private MainTable $mainTable)
{
$this->mainTable = $mainTable;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Adapter/SQL/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand Down
13 changes: 3 additions & 10 deletions src/Adapter/SQL/ShowCreateTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
10 changes: 2 additions & 8 deletions src/Adapter/SQL/SubQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
5 changes: 1 addition & 4 deletions src/Adapter/SQL/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
6 changes: 1 addition & 5 deletions src/Adapter/SQL/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,11 @@
*/
final class Update
{
/** @var MainTable<T> */
private MainTable $mainTable;

/**
* @param MainTable<T> $mainTable
*/
private function __construct(MainTable $mainTable)
private function __construct(private MainTable $mainTable)
{
$this->mainTable = $mainTable;
}

/**
Expand Down
Loading