diff --git a/CHANGELOG.md b/CHANGELOG.md index a6bf46c..6e8d098 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ * test: update fixtures to include enum in sort field * chore: various demo polishing * chore: rector clean up +* deps: DBAL 4.0 compatibility # 0.16.1 diff --git a/composer.json b/composer.json index e802cb6..20e1f32 100644 --- a/composer.json +++ b/composer.json @@ -1,41 +1,20 @@ { "name": "rekalogika/rekapager", - "homepage": "https://rekalogika.dev/rekapager", + "description": "Pagination library for PHP, supporting both offset-based and keyset-based pagination.", "license": "MIT", "type": "library", - "description": "Pagination library for PHP, supporting both offset-based and keyset-based pagination.", "authors": [ { "name": "Priyadi Iman Nurcahyo", "email": "priyadi@rekalogika.com" } ], - "autoload": { - "psr-4": { - "Rekalogika\\Contracts\\Rekapager\\": "packages/rekapager-contracts/src/", - "Rekalogika\\Rekapager\\": "packages/rekapager-core/src/", - "Rekalogika\\Rekapager\\Adapter\\Common\\": "packages/rekapager-adapter-common/src/", - "Rekalogika\\Rekapager\\ApiPlatform\\": "packages/rekapager-api-platform/src/", - "Rekalogika\\Rekapager\\Bundle\\": "packages/rekapager-bundle/src/", - "Rekalogika\\Rekapager\\Doctrine\\Collections\\": "packages/rekapager-doctrine-collections-adapter/src/", - "Rekalogika\\Rekapager\\Doctrine\\DBAL\\": "packages/rekapager-doctrine-dbal-adapter/src/", - "Rekalogika\\Rekapager\\Doctrine\\ORM\\": "packages/rekapager-doctrine-orm-adapter/src/", - "Rekalogika\\Rekapager\\Keyset\\": "packages/rekapager-keyset-pagination/src/", - "Rekalogika\\Rekapager\\Offset\\": "packages/rekapager-offset-pagination/src/", - "Rekalogika\\Rekapager\\Pagerfanta\\": "packages/rekapager-pagerfanta-adapter/src/", - "Rekalogika\\Rekapager\\Symfony\\": "packages/rekapager-symfony-bridge/src/" - } - }, - "autoload-dev": { - "psr-4": { - "Rekalogika\\Rekapager\\Tests\\": "tests/src/" - } - }, + "homepage": "https://rekalogika.dev/rekapager", "require": { "php": "^8.2", "api-platform/core": "^3.2", "doctrine/collections": "^2.2", - "doctrine/dbal": "^3.8", + "doctrine/dbal": "^3.8 || ^4.0", "doctrine/orm": "^2.19 || ^3.0", "pagerfanta/core": "^4.0", "pagerfanta/doctrine-collections-adapter": "^4.0", @@ -90,13 +69,6 @@ "vimeo/psalm": "^5.15", "zenstruck/foundry": "1.37.*" }, - "config": { - "sort-packages": true, - "allow-plugins": { - "symfony/runtime": true, - "symfony/flex": false - } - }, "replace": { "rekalogika/rekapager-adapter-common": "0.16.1", "rekalogika/rekapager-api-platform": "0.16.1", @@ -110,5 +82,33 @@ "rekalogika/rekapager-offset-pagination": "0.16.1", "rekalogika/rekapager-pagerfanta-adapter": "0.16.1", "rekalogika/rekapager-symfony-bridge": "0.16.1" + }, + "autoload": { + "psr-4": { + "Rekalogika\\Contracts\\Rekapager\\": "packages/rekapager-contracts/src/", + "Rekalogika\\Rekapager\\": "packages/rekapager-core/src/", + "Rekalogika\\Rekapager\\Adapter\\Common\\": "packages/rekapager-adapter-common/src/", + "Rekalogika\\Rekapager\\ApiPlatform\\": "packages/rekapager-api-platform/src/", + "Rekalogika\\Rekapager\\Bundle\\": "packages/rekapager-bundle/src/", + "Rekalogika\\Rekapager\\Doctrine\\Collections\\": "packages/rekapager-doctrine-collections-adapter/src/", + "Rekalogika\\Rekapager\\Doctrine\\DBAL\\": "packages/rekapager-doctrine-dbal-adapter/src/", + "Rekalogika\\Rekapager\\Doctrine\\ORM\\": "packages/rekapager-doctrine-orm-adapter/src/", + "Rekalogika\\Rekapager\\Keyset\\": "packages/rekapager-keyset-pagination/src/", + "Rekalogika\\Rekapager\\Offset\\": "packages/rekapager-offset-pagination/src/", + "Rekalogika\\Rekapager\\Pagerfanta\\": "packages/rekapager-pagerfanta-adapter/src/", + "Rekalogika\\Rekapager\\Symfony\\": "packages/rekapager-symfony-bridge/src/" + } + }, + "autoload-dev": { + "psr-4": { + "Rekalogika\\Rekapager\\Tests\\": "tests/src/" + } + }, + "config": { + "sort-packages": true, + "allow-plugins": { + "symfony/runtime": true, + "symfony/flex": false + } } } diff --git a/packages/rekapager-doctrine-dbal-adapter/composer.json b/packages/rekapager-doctrine-dbal-adapter/composer.json index aef0357..4f419ff 100644 --- a/packages/rekapager-doctrine-dbal-adapter/composer.json +++ b/packages/rekapager-doctrine-dbal-adapter/composer.json @@ -28,7 +28,7 @@ }, "require": { "php": "^8.2", - "doctrine/dbal": "^3.8", + "doctrine/dbal": "^3.8 || ^4.0", "doctrine/collections": "^2.2", "rekalogika/rekapager-adapter-common": "^0.16.1", "rekalogika/rekapager-keyset-pagination": "^0.16.1", diff --git a/packages/rekapager-doctrine-dbal-adapter/src/Internal/QueryParameter.php b/packages/rekapager-doctrine-dbal-adapter/src/Internal/QueryParameter.php index 3d1c40d..d3847e4 100644 --- a/packages/rekapager-doctrine-dbal-adapter/src/Internal/QueryParameter.php +++ b/packages/rekapager-doctrine-dbal-adapter/src/Internal/QueryParameter.php @@ -13,6 +13,8 @@ namespace Rekalogika\Rekapager\Doctrine\DBAL\Internal; +use Doctrine\DBAL\ArrayParameterType; +use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Types\Type; /** @@ -22,7 +24,7 @@ { public function __construct( private mixed $value, - private int|string|Type|null $type = null + private string|ParameterType|Type|ArrayParameterType $type = ParameterType::STRING ) { } @@ -31,7 +33,7 @@ public function getValue(): mixed return $this->value; } - public function getType(): int|string|Type|null + public function getType(): string|ParameterType|Type|ArrayParameterType { return $this->type; } diff --git a/packages/rekapager-doctrine-dbal-adapter/src/QueryBuilderAdapter.php b/packages/rekapager-doctrine-dbal-adapter/src/QueryBuilderAdapter.php index 5c97217..09cba7e 100644 --- a/packages/rekapager-doctrine-dbal-adapter/src/QueryBuilderAdapter.php +++ b/packages/rekapager-doctrine-dbal-adapter/src/QueryBuilderAdapter.php @@ -79,7 +79,7 @@ private function getQueryBuilder( /** @var mixed $value */ foreach ($boundaryValues ?? [] as $property => $value) { - $newBoundaryValues[$property] = new QueryParameter($value, null); + $newBoundaryValues[$property] = new QueryParameter($value); } $boundaryValues = $newBoundaryValues; @@ -408,7 +408,7 @@ private function doCount( * @psalm-suppress RedundantCondition * @phpstan-ignore-next-line */ - if (\is_callable($queryBuilder->resetQueryPart(...))) { + if (\is_callable([$queryBuilder, 'resetQueryPart'])) { return $this->doCountWithSubquery($queryBuilder); } @@ -442,12 +442,15 @@ private function doCountWithSubquery(QueryBuilder $queryBuilder): int $queryBuilder = (clone $queryBuilder); $sql = $queryBuilder->getSQL(); + if (\is_callable([$queryBuilder, 'resetQueryPart'])) { + $queryBuilder->resetQueryPart('from'); + } + /** * @psalm-suppress DeprecatedMethod * @phpstan-ignore-next-line */ $queryBuilder - ->resetQueryPart('from') ->resetGroupBy() ->resetHaving() ->resetOrderBy() diff --git a/packages/rekapager-doctrine-orm-adapter/composer.json b/packages/rekapager-doctrine-orm-adapter/composer.json index 7ea0ab2..7a5d66a 100644 --- a/packages/rekapager-doctrine-orm-adapter/composer.json +++ b/packages/rekapager-doctrine-orm-adapter/composer.json @@ -28,7 +28,7 @@ }, "require": { "php": "^8.2", - "doctrine/dbal": "^3.8", + "doctrine/dbal": "^3.8 || ^4.0", "doctrine/orm": "^2.19 || ^3.0", "doctrine/collections": "^2.2", "rekalogika/rekapager-adapter-common": "^0.16.1",