diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
index 64b80e5..b97c5fb 100644
--- a/.github/workflows/build.yaml
+++ b/.github/workflows/build.yaml
@@ -19,7 +19,10 @@ jobs:
strategy:
matrix:
php-version:
- - "7.4"
+ - "8.2"
+ - "8.3"
+ - "8.4"
+ - "8.5"
dependencies:
- "highest"
@@ -57,10 +60,10 @@ jobs:
strategy:
matrix:
php-version:
- - "7.4"
- - "8.0"
- - "8.1"
- "8.2"
+ - "8.3"
+ - "8.4"
+ - "8.5"
dependencies:
- "highest"
@@ -96,10 +99,10 @@ jobs:
strategy:
matrix:
php-version:
- - "7.4"
- - "8.0"
- - "8.1"
- "8.2"
+ - "8.3"
+ - "8.4"
+ - "8.5"
dependencies:
- "highest"
@@ -131,10 +134,10 @@ jobs:
strategy:
matrix:
php-version:
- - "7.4"
- - "8.0"
- - "8.1"
- "8.2"
+ - "8.3"
+ - "8.4"
+ - "8.5"
dependencies:
- "lowest"
@@ -167,8 +170,10 @@ jobs:
strategy:
matrix:
php-version:
- - "7.4"
- - "8.0"
+ - "8.2"
+ - "8.3"
+ - "8.4"
+ - "8.5"
dependencies:
- "highest"
diff --git a/composer.json b/composer.json
index 781d914..ad95ed0 100644
--- a/composer.json
+++ b/composer.json
@@ -10,11 +10,11 @@
}
],
"require": {
- "php": ">=7.4",
+ "php": ">=8.2",
"doctrine/collections": "^1.6 || ^2.0",
"doctrine/orm": "^2.8 || ^3.0",
"doctrine/persistence": "^1.3 || ^2.1 || ^3.0",
- "symfony/property-access": "^5.4 || ^6.0",
+ "symfony/property-access": "^5.4 || ^6.4 || ^7.4 || ^8.0",
"webmozart/assert": "^1.10"
},
"require-dev": {
@@ -23,7 +23,8 @@
"phpunit/phpunit": "^9.5.10",
"psalm/plugin-phpunit": "^0.19.0",
"setono/code-quality-pack": "^2.1.3",
- "symfony/cache": "^5.4 || ^6.0",
+ "symfony/cache": "^5.4 || ^6.4 || ^7.4 || ^8.0",
+ "symfony/var-exporter": "^5.4 || ^6.4 || ^7.4",
"weirdan/doctrine-psalm-plugin": "^2.0"
},
"autoload": {
diff --git a/psalm.xml b/psalm.xml
index 65e9d8c..4213f6e 100644
--- a/psalm.xml
+++ b/psalm.xml
@@ -16,4 +16,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Batch/Batch.php b/src/Batch/Batch.php
index c77ef46..0fdcfd3 100644
--- a/src/Batch/Batch.php
+++ b/src/Batch/Batch.php
@@ -27,16 +27,19 @@ public function __construct(QueryBuilder $qb)
$this->parameters = $qb->getParameters()->toArray();
}
+ #[\Override]
public function getClass(): string
{
return $this->class;
}
+ #[\Override]
public function getDql(): string
{
return $this->dql;
}
+ #[\Override]
public function getParameters(): array
{
return $this->parameters;
diff --git a/src/Batch/CollectionBatch.php b/src/Batch/CollectionBatch.php
index 7ee5f02..c2d4f17 100644
--- a/src/Batch/CollectionBatch.php
+++ b/src/Batch/CollectionBatch.php
@@ -22,6 +22,7 @@ public function __construct(array $collection, QueryBuilder $qb)
parent::__construct($qb);
}
+ #[\Override]
public function getCollection(): array
{
return $this->collection;
diff --git a/src/Batch/RangeBatch.php b/src/Batch/RangeBatch.php
index cd94c7f..0546ab3 100644
--- a/src/Batch/RangeBatch.php
+++ b/src/Batch/RangeBatch.php
@@ -33,11 +33,13 @@ public function __construct(int $lowerBound, int $upperBound, QueryBuilder $qb)
parent::__construct($qb);
}
+ #[\Override]
public function getLowerBound(): int
{
return $this->lowerBound;
}
+ #[\Override]
public function getUpperBound(): int
{
return $this->upperBound;
diff --git a/src/Batcher/Batcher.php b/src/Batcher/Batcher.php
index 1c84c61..01a3e06 100644
--- a/src/Batcher/Batcher.php
+++ b/src/Batcher/Batcher.php
@@ -54,6 +54,7 @@ public function __construct(QueryBuilder $qb, string $identifier = 'id', bool $c
;
}
+ #[\Override]
public function getBatchCount(int $batchSize = 100): int
{
return (int) ceil($this->getCount() / $batchSize);
diff --git a/src/Batcher/Collection/CollectionBatcher.php b/src/Batcher/Collection/CollectionBatcher.php
index cd6ca28..d70e79f 100644
--- a/src/Batcher/Collection/CollectionBatcher.php
+++ b/src/Batcher/Collection/CollectionBatcher.php
@@ -10,6 +10,7 @@
abstract class CollectionBatcher extends Batcher implements CollectionBatcherInterface
{
+ #[\Override]
protected function getBatchableQueryBuilder(): QueryBuilder
{
$qb = $this->getQueryBuilder();
diff --git a/src/Batcher/Collection/CollectionBatcherInterface.php b/src/Batcher/Collection/CollectionBatcherInterface.php
index c883748..369c929 100644
--- a/src/Batcher/Collection/CollectionBatcherInterface.php
+++ b/src/Batcher/Collection/CollectionBatcherInterface.php
@@ -12,5 +12,6 @@ interface CollectionBatcherInterface extends BatcherInterface
/**
* @return iterable
*/
+ #[\Override]
public function getBatches(int $batchSize = 100): iterable;
}
diff --git a/src/Batcher/Collection/IdCollectionBatcher.php b/src/Batcher/Collection/IdCollectionBatcher.php
index 2bc5c23..6d7d63e 100644
--- a/src/Batcher/Collection/IdCollectionBatcher.php
+++ b/src/Batcher/Collection/IdCollectionBatcher.php
@@ -12,6 +12,7 @@ final class IdCollectionBatcher extends CollectionBatcher
/**
* @return iterable
*/
+ #[\Override]
public function getBatches(int $batchSize = 100): iterable
{
$result = $this->getResult(sprintf('%s.%s', $this->alias, $this->identifier), $batchSize);
diff --git a/src/Batcher/Collection/ObjectCollectionBatcher.php b/src/Batcher/Collection/ObjectCollectionBatcher.php
index 745dd0e..dcfee28 100644
--- a/src/Batcher/Collection/ObjectCollectionBatcher.php
+++ b/src/Batcher/Collection/ObjectCollectionBatcher.php
@@ -12,6 +12,7 @@ final class ObjectCollectionBatcher extends CollectionBatcher
/**
* @return iterable
*/
+ #[\Override]
public function getBatches(int $batchSize = 100): iterable
{
$result = $this->getResult(null, $batchSize);
diff --git a/src/Batcher/Range/IdRangeBatcher.php b/src/Batcher/Range/IdRangeBatcher.php
index 3b6cb6b..79ffd6d 100644
--- a/src/Batcher/Range/IdRangeBatcher.php
+++ b/src/Batcher/Range/IdRangeBatcher.php
@@ -12,6 +12,7 @@ final class IdRangeBatcher extends RangeBatcher
/**
* @return iterable
*/
+ #[\Override]
public function getBatches(int $batchSize = 100): iterable
{
$result = $this->getResult(sprintf('%s.%s', $this->alias, $this->identifier), $batchSize);
diff --git a/src/Batcher/Range/NaiveIdRangeBatcher.php b/src/Batcher/Range/NaiveIdRangeBatcher.php
index 4c51417..13bb0a5 100644
--- a/src/Batcher/Range/NaiveIdRangeBatcher.php
+++ b/src/Batcher/Range/NaiveIdRangeBatcher.php
@@ -10,11 +10,10 @@
final class NaiveIdRangeBatcher extends RangeBatcher implements NaiveIdRangeBatcherInterface
{
- private int $count;
-
/**
* @return iterable
*/
+ #[\Override]
public function getBatches(int $batchSize = 100): iterable
{
try {
@@ -40,14 +39,15 @@ public function getBatches(int $batchSize = 100): iterable
* If the lowest id is 30 and the highest id is 190 the maximum number of rows is (190 - 30) + 1 = 161
* If the number of rows is 145, then the sparseness is (161 - 145) / 161 * 100 = 9.94% and this method will return 10 in that case.
*/
+ #[\Override]
public function getSparseness(): int
{
try {
$bestPossibleCount = ($this->getMax() - $this->getMin()) + 1;
- } catch (NoResultException $e) {
+ } catch (NoResultException) {
return 0;
}
- return (int) round(($bestPossibleCount - $this->getCount()) / $bestPossibleCount * 100);
+ return (int) round((float) ($bestPossibleCount - $this->getCount()) / (float) $bestPossibleCount * 100.0);
}
}
diff --git a/src/Batcher/Range/RangeBatcher.php b/src/Batcher/Range/RangeBatcher.php
index 1a074d3..2a2c473 100644
--- a/src/Batcher/Range/RangeBatcher.php
+++ b/src/Batcher/Range/RangeBatcher.php
@@ -10,6 +10,7 @@
abstract class RangeBatcher extends Batcher implements RangeBatcherInterface
{
+ #[\Override]
protected function getBatchableQueryBuilder(): QueryBuilder
{
$qb = $this->getQueryBuilder();
diff --git a/src/Batcher/Range/RangeBatcherInterface.php b/src/Batcher/Range/RangeBatcherInterface.php
index bbed902..144b7b2 100644
--- a/src/Batcher/Range/RangeBatcherInterface.php
+++ b/src/Batcher/Range/RangeBatcherInterface.php
@@ -12,5 +12,6 @@ interface RangeBatcherInterface extends BatcherInterface
/**
* @return iterable
*/
+ #[\Override]
public function getBatches(int $batchSize = 100): iterable;
}
diff --git a/src/Factory/BatcherFactory.php b/src/Factory/BatcherFactory.php
index 42b9efe..c884d16 100644
--- a/src/Factory/BatcherFactory.php
+++ b/src/Factory/BatcherFactory.php
@@ -23,7 +23,7 @@ public function __construct(
string $objectCollectionBatcherClass,
string $idCollectionBatcherClass,
string $naiveIdRangeBatcherClass,
- string $idRangeBatcherClass
+ string $idRangeBatcherClass,
) {
$this->objectCollectionBatcherClass = $objectCollectionBatcherClass;
$this->idCollectionBatcherClass = $idCollectionBatcherClass;
@@ -31,27 +31,30 @@ public function __construct(
$this->idRangeBatcherClass = $idRangeBatcherClass;
}
+ #[\Override]
public function createObjectCollectionBatcher(
QueryBuilder $qb,
string $identifier = 'id',
- bool $clearOnBatch = true
+ bool $clearOnBatch = true,
): CollectionBatcherInterface {
return new $this->objectCollectionBatcherClass($qb, $identifier, $clearOnBatch);
}
+ #[\Override]
public function createIdCollectionBatcher(
QueryBuilder $qb,
string $identifier = 'id',
- bool $clearOnBatch = true
+ bool $clearOnBatch = true,
): CollectionBatcherInterface {
return new $this->idCollectionBatcherClass($qb, $identifier, $clearOnBatch);
}
+ #[\Override]
public function createIdRangeBatcher(
QueryBuilder $qb,
string $identifier = 'id',
bool $clearOnBatch = true,
- int $sparsenessThreshold = 5
+ int $sparsenessThreshold = 5,
): RangeBatcherInterface {
/** @var NaiveIdRangeBatcherInterface $naiveIdBatcher */
$naiveIdBatcher = new $this->naiveIdRangeBatcherClass($qb, $identifier, $clearOnBatch);
diff --git a/src/Query/QueryRebuilder.php b/src/Query/QueryRebuilder.php
index c6f677d..056e2c7 100644
--- a/src/Query/QueryRebuilder.php
+++ b/src/Query/QueryRebuilder.php
@@ -20,6 +20,7 @@ public function __construct(ManagerRegistry $managerRegistry)
$this->managerRegistry = $managerRegistry;
}
+ #[\Override]
public function rebuild(BatchInterface $batch): Query
{
$manager = $this->getManager($batch->getClass());
diff --git a/tests/Batcher/Collection/IdCollectionBatcherTest.php b/tests/Batcher/Collection/IdCollectionBatcherTest.php
index e032913..fbead5d 100644
--- a/tests/Batcher/Collection/IdCollectionBatcherTest.php
+++ b/tests/Batcher/Collection/IdCollectionBatcherTest.php
@@ -57,7 +57,7 @@ public function it_works(): void
$batches = $batcher->getBatches(10);
- foreach ($batches as $idx => $batch) {
+ foreach ($batches as $batch) {
foreach ($batch->getCollection() as $id) {
$this->assertArrayHasKey($id, $expectedIds);
diff --git a/tests/Batcher/Collection/ObjectCollectionBatcherTest.php b/tests/Batcher/Collection/ObjectCollectionBatcherTest.php
index 864ecac..54c5fa1 100644
--- a/tests/Batcher/Collection/ObjectCollectionBatcherTest.php
+++ b/tests/Batcher/Collection/ObjectCollectionBatcherTest.php
@@ -57,7 +57,7 @@ public function it_works(): void
$batches = $batcher->getBatches(10);
- foreach ($batches as $idx => $batch) {
+ foreach ($batches as $batch) {
/** @var Entity $entity */
foreach ($batch->getCollection() as $entity) {
$this->assertArrayHasKey($entity->getId(), $expectedIds);
diff --git a/tests/EntityManagerAwareTestCase.php b/tests/EntityManagerAwareTestCase.php
index 3fc6d0d..2e1b6e6 100644
--- a/tests/EntityManagerAwareTestCase.php
+++ b/tests/EntityManagerAwareTestCase.php
@@ -19,6 +19,7 @@ abstract class EntityManagerAwareTestCase extends TestCase
protected ORMPurger $purger;
+ #[\Override]
public function setUp(): void
{
parent::setUp();
diff --git a/tests/Factory/BatcherFactoryTest.php b/tests/Factory/BatcherFactoryTest.php
index 533ec20..78a3268 100644
--- a/tests/Factory/BatcherFactoryTest.php
+++ b/tests/Factory/BatcherFactoryTest.php
@@ -21,16 +21,19 @@ public function will_use_naive_id_batcher(): void
$qb = $this->createQb();
$cls = new class() implements NaiveIdRangeBatcherInterface {
+ #[\Override]
public function getSparseness(): int
{
return 1;
}
+ #[\Override]
public function getBatches(int $batchSize = 100): iterable
{
return [];
}
+ #[\Override]
public function getBatchCount(int $batchSize = 100): int
{
return 0;
@@ -52,16 +55,19 @@ public function will_use_id_batcher(): void
$qb = $this->createQb();
$naiveIdBatcher = new class() implements NaiveIdRangeBatcherInterface {
+ #[\Override]
public function getSparseness(): int
{
return 6;
}
+ #[\Override]
public function getBatches(int $batchSize = 100): iterable
{
return [];
}
+ #[\Override]
public function getBatchCount(int $batchSize = 100): int
{
return 0;
@@ -74,11 +80,13 @@ public function getSparseness(): int
return 6;
}
+ #[\Override]
public function getBatches(int $batchSize = 100): iterable
{
return [];
}
+ #[\Override]
public function getBatchCount(int $batchSize = 100): int
{
return 0;