Issues (8)

src/Pagerfanta/CallableDecoratorAdapter.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Damax\Common\Pagerfanta;
6
7
use Pagerfanta\Adapter\AdapterInterface;
8
use Traversable;
9
10
final class CallableDecoratorAdapter implements AdapterInterface
11
{
12
    private $adapter;
13
    private $callback;
14
15
    public function __construct(AdapterInterface $adapter, callable $callback)
16
    {
17
        $this->adapter = $adapter;
18
        $this->callback = $callback;
19
    }
20
21
    public function getNbResults(): int
22
    {
23
        return $this->adapter->getNbResults();
24
    }
25
26
    public function getSlice($offset, $length): array
27
    {
28
        $items = $this->adapter->getSlice($offset, $length);
29
        $items = $items instanceof Traversable ? iterator_to_array($items, false) : $items;
30
31
        return array_values(array_map($this->callback, $items));
0 ignored issues
show
It seems like $items can also be of type iterable; however, parameter $array of array_map() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

31
        return array_values(array_map($this->callback, /** @scrutinizer ignore-type */ $items));
Loading history...
32
    }
33
}
34