From 2c115945661ab121269459b2c900ed153ef2b919 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Fri, 13 Dec 2024 15:57:28 +0100 Subject: [PATCH] Add missing iterable value types (#60) --- lib/Adapter/Elastica/ElasticaAdapter.php | 1 + lib/Core/Pagerfanta.php | 3 +++ lib/Core/Tests/Adapter/FixedAdapterTest.php | 3 +++ lib/Core/Tests/View/OptionableViewTest.php | 3 +++ phpstan.neon | 3 --- 5 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/Adapter/Elastica/ElasticaAdapter.php b/lib/Adapter/Elastica/ElasticaAdapter.php index 9fed08bb..d95baeb6 100644 --- a/lib/Adapter/Elastica/ElasticaAdapter.php +++ b/lib/Adapter/Elastica/ElasticaAdapter.php @@ -24,6 +24,7 @@ class ElasticaAdapter implements AdapterInterface private ?ResultSet $resultSet = null; /** + * @param array $options * @param int|null $maxResults Limit the number of totalHits returned by ElasticSearch; see https://github.com/whiteoctober/Pagerfanta/pull/213#issue-87631892 * * @throws NotValidResultCountException if the maximum number of results is less than zero diff --git a/lib/Core/Pagerfanta.php b/lib/Core/Pagerfanta.php index 7ec1c41a..11bed46c 100644 --- a/lib/Core/Pagerfanta.php +++ b/lib/Core/Pagerfanta.php @@ -441,6 +441,9 @@ public function getIterator(): \Traversable throw new InvalidArgumentException(\sprintf('Cannot create iterator with page results of type "%s".', get_debug_type($results))); } + /** + * @return T[] + */ public function jsonSerialize(): array { $results = $this->getCurrentPageResults(); diff --git a/lib/Core/Tests/Adapter/FixedAdapterTest.php b/lib/Core/Tests/Adapter/FixedAdapterTest.php index 5652ff45..be614cf4 100644 --- a/lib/Core/Tests/Adapter/FixedAdapterTest.php +++ b/lib/Core/Tests/Adapter/FixedAdapterTest.php @@ -29,6 +29,9 @@ public static function dataGetSlice(): \Generator yield 'from iterable object' => [new \ArrayObject()]; } + /** + * @param iterable $results + */ #[DataProvider('dataGetSlice')] public function testGetSlice(iterable $results): void { diff --git a/lib/Core/Tests/View/OptionableViewTest.php b/lib/Core/Tests/View/OptionableViewTest.php index 2cc69a68..298b3d99 100644 --- a/lib/Core/Tests/View/OptionableViewTest.php +++ b/lib/Core/Tests/View/OptionableViewTest.php @@ -51,6 +51,9 @@ public function testRenderShouldMergeOptions(): void $this->assertSame(self::RENDERED_VIEW, (new OptionableView($this->createViewMock([...$defaultOptions, ...$options]), $defaultOptions))->render($this->pagerfanta, $this->routeGenerator, $options)); } + /** + * @param array $expectedOptions + */ private function createViewMock(array $expectedOptions): MockObject&ViewInterface { /** @var MockObject&ViewInterface $view */ diff --git a/phpstan.neon b/phpstan.neon index 88903973..de9bffda 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -5,6 +5,3 @@ parameters: paths: - %currentWorkingDirectory%/lib treatPhpDocTypesAsCertain: false - ignoreErrors: - - - identifier: missingType.iterableValue