Skip to content

Commit

Permalink
chore: cleanup typehints (#117)
Browse files Browse the repository at this point in the history
* chore: cleanup typehints

* fix
  • Loading branch information
priyadi authored Jul 9, 2024
1 parent 520af06 commit c7b450f
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 30 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* feat: repository now accept `ManagerRegistry` instead of `EntityManagerInterface`
* feat: default items per page
* feat: different default count strategies for full & minimal classes
* chore: cleanup typehints

## 0.8.0

Expand Down
5 changes: 1 addition & 4 deletions packages/collections-domain/src/CriteriaPageable.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@
use Doctrine\Common\Collections\Selectable;
use Rekalogika\Contracts\Collections\Exception\UnexpectedValueException;
use Rekalogika\Contracts\Collections\PageableRecollection;
use Rekalogika\Contracts\Rekapager\PageableInterface;
use Rekalogika\Domain\Collections\Common\Configuration;
use Rekalogika\Domain\Collections\Common\Count\CountStrategy;
use Rekalogika\Domain\Collections\Common\Internal\ParameterUtil;
use Rekalogika\Domain\Collections\Common\KeyTransformer\KeyTransformer;
use Rekalogika\Domain\Collections\Common\Trait\PageableTrait;
use Rekalogika\Domain\Collections\Common\Trait\RefreshCountTrait;
use Rekalogika\Domain\Collections\Trait\RecollectionPageableTrait;
Expand Down Expand Up @@ -107,8 +105,7 @@ final public static function create(
?string $indexBy = null,
int $itemsPerPage = 50,
?CountStrategy $count = null,
?KeyTransformer $keyTransformer = null,
): PageableInterface {
): static {
if (self::$instances === null) {
/** @var \WeakMap<object,array<string,self<array-key,mixed>>> */
$weakmap = new \WeakMap();
Expand Down
13 changes: 8 additions & 5 deletions packages/collections-domain/src/MinimalRecollectionDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use Doctrine\Common\Collections\Selectable;
use Rekalogika\Contracts\Collections\Exception\UnexpectedValueException;
use Rekalogika\Contracts\Collections\MinimalRecollection;
use Rekalogika\Contracts\Rekapager\PageableInterface;
use Rekalogika\Contracts\Collections\PageableRecollection;
use Rekalogika\Domain\Collections\Common\Configuration;
use Rekalogika\Domain\Collections\Common\Count\CountStrategy;
use Rekalogika\Domain\Collections\Common\Internal\ParameterUtil;
Expand Down Expand Up @@ -203,7 +203,7 @@ private function getUnderlyingCountable(): \Countable
/**
* @return MinimalCriteriaRecollection<TKey,T>
*/
final protected function createCriteriaCollection(
final protected function createCriteriaRecollection(
Criteria $criteria,
?string $instanceId = null,
?CountStrategy $count = null,
Expand All @@ -223,19 +223,22 @@ final protected function createCriteriaCollection(
}

/**
* @return PageableInterface<TKey,T>
* @return PageableRecollection<TKey,T>
*/
final protected function createCriteriaPageable(
Criteria $criteria,
?string $instanceId = null,
?CountStrategy $count = null,
): PageableInterface {
): PageableRecollection {
// if $criteria has no orderings, add the current ordering
if (\count($criteria->orderings()) === 0) {
$criteria = $criteria->orderBy($this->orderBy);
}

/** @var PageableInterface<TKey,T> */
/**
* @var PageableRecollection<TKey,T>
* @phpstan-ignore-next-line
*/
return CriteriaPageable::create(
collection: $this->collection,
criteria: $criteria,
Expand Down
9 changes: 4 additions & 5 deletions packages/collections-domain/src/Trait/RecollectionDxTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use Doctrine\Common\Collections\Criteria;
use Doctrine\Common\Collections\Order;
use Rekalogika\Contracts\Rekapager\PageableInterface;
use Rekalogika\Contracts\Collections\PageableRecollection;
use Rekalogika\Domain\Collections\Common\Count\CountStrategy;
use Rekalogika\Domain\Collections\CriteriaPageable;
use Rekalogika\Domain\Collections\CriteriaRecollection;
Expand All @@ -39,7 +39,7 @@ final protected function createCriteria(): Criteria
/**
* @return CriteriaRecollection<TKey,T>
*/
final protected function createCriteriaCollection(
final protected function createCriteriaRecollection(
Criteria $criteria,
?string $instanceId = null,
?CountStrategy $count = null,
Expand All @@ -61,19 +61,18 @@ final protected function createCriteriaCollection(
}

/**
* @return PageableInterface<TKey,T>
* @return PageableRecollection<TKey,T>
*/
final protected function createCriteriaPageable(
Criteria $criteria,
?string $instanceId = null,
?CountStrategy $count = null,
): PageableInterface {
): PageableRecollection {
// if $criteria has no orderings, add the current ordering
if (\count($criteria->orderings()) === 0) {
$criteria = $criteria->orderBy($this->getOrderBy());
}

/** @var PageableInterface<TKey,T> */
return CriteriaPageable::create(
collection: $this->collection,
criteria: $criteria,
Expand Down
9 changes: 4 additions & 5 deletions packages/collections-orm/src/QueryPageable.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Doctrine\ORM\QueryBuilder;
use Rekalogika\Collections\ORM\Trait\QueryBuilderPageableTrait;
use Rekalogika\Contracts\Collections\PageableRecollection;
use Rekalogika\Contracts\Rekapager\PageableInterface;
use Rekalogika\Domain\Collections\Common\Configuration;
use Rekalogika\Domain\Collections\Common\Count\CountStrategy;
use Rekalogika\Domain\Collections\Common\Internal\ParameterUtil;
Expand Down Expand Up @@ -78,7 +77,7 @@ final protected function getQueryBuilder(): QueryBuilder
/**
* @return self<TKey,T>
*/
final protected function createQueryCollection(
final protected function createQueryRecollection(
QueryBuilder $queryBuilder,
?string $indexBy = null,
?CountStrategy $count = null,
Expand All @@ -96,15 +95,15 @@ final protected function createQueryCollection(
}

/**
* @return PageableInterface<TKey,T>
* @return PageableRecollection<TKey,T>
*/
final protected function createQueryPageable(
QueryBuilder $queryBuilder,
?string $indexBy = null,
?CountStrategy $count = null,
): PageableInterface {
): PageableRecollection {
/**
* @var PageableInterface<TKey,T>
* @var PageableRecollection<TKey,T>
* @phpstan-ignore-next-line
*/
return new QueryPageable(
Expand Down
10 changes: 5 additions & 5 deletions packages/collections-orm/src/QueryRecollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

use Doctrine\ORM\QueryBuilder;
use Rekalogika\Collections\ORM\Trait\QueryBuilderPageableTrait;
use Rekalogika\Contracts\Collections\PageableRecollection;
use Rekalogika\Contracts\Collections\ReadableRecollection;
use Rekalogika\Contracts\Rekapager\PageableInterface;
use Rekalogika\Domain\Collections\Common\Configuration;
use Rekalogika\Domain\Collections\Common\Count\CountStrategy;
use Rekalogika\Domain\Collections\Common\Internal\ParameterUtil;
Expand Down Expand Up @@ -115,7 +115,7 @@ final protected function getQueryBuilder(): QueryBuilder
/**
* @return self<TKey,T>
*/
final protected function createQueryCollection(
final protected function createQueryRecollection(
QueryBuilder $queryBuilder,
?string $indexBy = null,
?CountStrategy $count = null,
Expand All @@ -132,15 +132,15 @@ final protected function createQueryCollection(
}

/**
* @return PageableInterface<TKey,T>
* @return PageableRecollection<TKey,T>
*/
final protected function createQueryPageable(
QueryBuilder $queryBuilder,
?string $indexBy = null,
?CountStrategy $count = null,
): PageableInterface {
): PageableRecollection {
/**
* @var PageableInterface<TKey,T>
* @var PageableRecollection<TKey,T>
* @phpstan-ignore-next-line
*/
return new QueryPageable(
Expand Down
12 changes: 6 additions & 6 deletions packages/collections-orm/src/Trait/RepositoryDxTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
use Rekalogika\Collections\ORM\QueryPageable;
use Rekalogika\Collections\ORM\QueryRecollection;
use Rekalogika\Contracts\Collections\Exception\InvalidArgumentException;
use Rekalogika\Contracts\Rekapager\PageableInterface;
use Rekalogika\Contracts\Collections\PageableRecollection;
use Rekalogika\Domain\Collections\Common\Count\CountStrategy;
use Rekalogika\Domain\Collections\CriteriaPageable;
use Rekalogika\Domain\Collections\CriteriaRecollection;
Expand Down Expand Up @@ -101,14 +101,14 @@ final protected function createCriteriaRecollection(
}

/**
* @return PageableInterface<TKey,T>
* @return PageableRecollection<TKey,T>
*/
final protected function createCriteriaPageable(
Criteria $criteria,
?string $instanceId = null,
?string $indexBy = null,
?CountStrategy $count = null,
): PageableInterface {
): PageableRecollection {
return CriteriaPageable::create(
collection: $this->getDoctrineRepository(),
criteria: $criteria,
Expand Down Expand Up @@ -139,15 +139,15 @@ final protected function createQueryRecollection(
}

/**
* @return PageableInterface<TKey,T>
* @return PageableRecollection<TKey,T>
*/
final protected function createQueryPageable(
QueryBuilder $queryBuilder,
?string $indexBy = null,
?CountStrategy $count = null,
): PageableInterface {
): PageableRecollection {
/**
* @var PageableInterface<TKey,T>
* @var PageableRecollection<TKey,T>
* @phpstan-ignore-next-line
*/
return new QueryPageable(
Expand Down

0 comments on commit c7b450f

Please sign in to comment.