From 79bc7bfe278aed044a0ca029e9e7db1fbe8ace81 Mon Sep 17 00:00:00 2001 From: Patrick EUSTACHE-ROOLS Date: Fri, 25 Jul 2025 10:19:52 +0200 Subject: [PATCH 1/3] Fix missing return type --- Driver/ORM/Pager.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Driver/ORM/Pager.php b/Driver/ORM/Pager.php index e210475..e6aae90 100644 --- a/Driver/ORM/Pager.php +++ b/Driver/ORM/Pager.php @@ -58,7 +58,7 @@ public function paginate($target, $page = 1, $limit = 10) /** * {@inheritdoc} */ - public function getLastPage() + public function getLastPage(): int { return $this->lastPage; } @@ -66,7 +66,7 @@ public function getLastPage() /** * {@inheritdoc} */ - public function getPage() + public function getPage(): int { return $this->page; } @@ -74,7 +74,7 @@ public function getPage() /** * {@inheritdoc} */ - public function haveToPaginate() + public function haveToPaginate(): bool { return $this->getLastPage() > 1; } @@ -82,7 +82,7 @@ public function haveToPaginate() /** * {@inheritdoc} */ - public function getNbResults() + public function getNbResults(): int { return $this->nbResults; } @@ -90,7 +90,7 @@ public function getNbResults() /** * @param array $items items */ - public function setItems(array $items) + public function setItems(array $items): void { $this->items = $items; } From a3bc89171b0e94af65923e0b7644709cce007d17 Mon Sep 17 00:00:00 2001 From: Patrick EUSTACHE-ROOLS Date: Fri, 25 Jul 2025 13:01:19 +0200 Subject: [PATCH 2/3] Fix PHPStan errors --- Driver/ODM/Pager.php | 29 +++++++++++-------- .../Criteria/CriteriaCollection.php | 2 +- Driver/ORM/QueryBuilder/QueryBuilder.php | 7 +++++ Filter/DataHydrator/Locator/DoctrineORM.php | 2 +- composer.json | 2 +- 5 files changed, 27 insertions(+), 15 deletions(-) diff --git a/Driver/ODM/Pager.php b/Driver/ODM/Pager.php index 714d4e5..2b8e655 100644 --- a/Driver/ODM/Pager.php +++ b/Driver/ODM/Pager.php @@ -17,6 +17,11 @@ class Pager implements PagerInterface, \IteratorAggregate, \Countable, \ArrayAcc */ protected $lastPage; + /** + * @var integer + */ + protected $page; + /** * @var integer */ @@ -51,7 +56,7 @@ public function paginate($target, $page = 1, $limit = 10) /** * {@inheritdoc} */ - public function getLastPage() + public function getLastPage(): int { return $this->lastPage; } @@ -59,7 +64,7 @@ public function getLastPage() /** * {@inheritdoc} */ - public function getPage() + public function getPage(): int { return $this->page; } @@ -67,7 +72,7 @@ public function getPage() /** * {@inheritdoc} */ - public function haveToPaginate() + public function haveToPaginate(): bool { return $this->getLastPage() > 1; } @@ -75,7 +80,7 @@ public function haveToPaginate() /** * {@inheritdoc} */ - public function getNbResults() + public function getNbResults(): int { return $this->nbResults; } @@ -83,7 +88,7 @@ public function getNbResults() /** * @param array $items items */ - public function setItems(array $items) + public function setItems(array $items): void { $this->items = $items; } @@ -91,7 +96,7 @@ public function setItems(array $items) /** * @return \ArrayIterator */ - public function getIterator() + public function getIterator(): \Traversable { return new \ArrayIterator($this->items); } @@ -99,7 +104,7 @@ public function getIterator() /** * @return integer */ - public function count() + public function count(): int { return count($this->items); } @@ -108,7 +113,7 @@ public function count() * @param mixed $offset * @param mixed $value */ - public function offsetSet($offset, $value) + public function offsetSet(mixed $offset, mixed $value): void { if (is_null($offset)) { $this->items[] = $value; @@ -121,7 +126,7 @@ public function offsetSet($offset, $value) * @param mixed $offset * @return boolean */ - public function offsetExists($offset) + public function offsetExists(mixed $offset): bool { return isset($this->items[$offset]); } @@ -129,7 +134,7 @@ public function offsetExists($offset) /** * @param mixed $offset */ - public function offsetUnset($offset) + public function offsetUnset(mixed $offset): void { unset($this->items[$offset]); } @@ -138,8 +143,8 @@ public function offsetUnset($offset) * @param mixed $offset * @return mixed */ - public function offsetGet($offset) + public function offsetGet(mixed $offset): mixed { - return isset($this->items[$offset]) ? $this->items[$offset] : null; + return $this->items[$offset] ?? null; } } diff --git a/Driver/ORM/QueryBuilder/Criteria/CriteriaCollection.php b/Driver/ORM/QueryBuilder/Criteria/CriteriaCollection.php index 5257736..1d8fa5b 100644 --- a/Driver/ORM/QueryBuilder/Criteria/CriteriaCollection.php +++ b/Driver/ORM/QueryBuilder/Criteria/CriteriaCollection.php @@ -38,7 +38,7 @@ public function addFromAsserter(Asserter $asserter) /** * @return \ArrayIterator */ - public function getIterator() + public function getIterator(): \Traversable { return new \ArrayIterator($this->criterias); } diff --git a/Driver/ORM/QueryBuilder/QueryBuilder.php b/Driver/ORM/QueryBuilder/QueryBuilder.php index 636e9a0..b38c075 100644 --- a/Driver/ORM/QueryBuilder/QueryBuilder.php +++ b/Driver/ORM/QueryBuilder/QueryBuilder.php @@ -131,6 +131,13 @@ protected function filterCriterias($qb) $visitor = new OperatorVisitor(); } elseif ($this->criterias instanceof Asserter) { $visitor = new AsserterVisitor(); + } else { + throw new \InvalidArgumentException(sprintf( + 'Criterias must be an instance of %s or %s, %s given', + Operator::class, + Asserter::class, + get_class($this->criterias) + )); } $criteriaCollection = new CriteriaCollection(); diff --git a/Filter/DataHydrator/Locator/DoctrineORM.php b/Filter/DataHydrator/Locator/DoctrineORM.php index 9eb97ed..2e4d65e 100644 --- a/Filter/DataHydrator/Locator/DoctrineORM.php +++ b/Filter/DataHydrator/Locator/DoctrineORM.php @@ -60,7 +60,7 @@ public function locate($model, array $components) } if (count($fields) > 1) { - return $this->locateComposite($objectManager, $metadata, $model, $components, $oids, $fields); + $this->locateComposite($objectManager, $metadata, $model, $components, $oids, $fields); } $alias = 'r'; diff --git a/composer.json b/composer.json index 148311b..48e7190 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ "homepage": "https://github.com/stephpy/timeline-bundle/contributors" }], "require": { - "php": ">=8.3", + "php": ">=8.4", "stephpy/timeline": "^1.0", "symfony/framework-bundle": ">=5.4", "symfony/options-resolver": ">=5.4", From ff9657f59a28ccd3790327bfac55b311a890d0da Mon Sep 17 00:00:00 2001 From: Patrick EUSTACHE-ROOLS Date: Fri, 25 Jul 2025 13:05:10 +0200 Subject: [PATCH 3/3] Fix PHPStan errors --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 48e7190..148311b 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ "homepage": "https://github.com/stephpy/timeline-bundle/contributors" }], "require": { - "php": ">=8.4", + "php": ">=8.3", "stephpy/timeline": "^1.0", "symfony/framework-bundle": ">=5.4", "symfony/options-resolver": ">=5.4",