Skip to content

Commit

Permalink
Add missing iterable value types (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
stof authored Dec 13, 2024
1 parent 57b114f commit 2c11594
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/Adapter/Elastica/ElasticaAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class ElasticaAdapter implements AdapterInterface
private ?ResultSet $resultSet = null;

/**
* @param array<string, mixed> $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
Expand Down
3 changes: 3 additions & 0 deletions lib/Core/Pagerfanta.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 3 additions & 0 deletions lib/Core/Tests/Adapter/FixedAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public static function dataGetSlice(): \Generator
yield 'from iterable object' => [new \ArrayObject()];
}

/**
* @param iterable<mixed> $results
*/
#[DataProvider('dataGetSlice')]
public function testGetSlice(iterable $results): void
{
Expand Down
3 changes: 3 additions & 0 deletions lib/Core/Tests/View/OptionableViewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, mixed> $expectedOptions
*/
private function createViewMock(array $expectedOptions): MockObject&ViewInterface
{
/** @var MockObject&ViewInterface $view */
Expand Down
3 changes: 0 additions & 3 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,3 @@ parameters:
paths:
- %currentWorkingDirectory%/lib
treatPhpDocTypesAsCertain: false
ignoreErrors:
-
identifier: missingType.iterableValue

0 comments on commit 2c11594

Please sign in to comment.