1 | <?php |
||
23 | final class InPlacePagerPersister implements PagerPersisterInterface |
||
24 | { |
||
25 | public const NAME = 'in_place'; |
||
26 | |||
27 | /** |
||
28 | * @var PersisterRegistry |
||
29 | */ |
||
30 | private $registry; |
||
31 | |||
32 | /** |
||
33 | * @var EventDispatcherInterface |
||
34 | */ |
||
35 | private $dispatcher; |
||
36 | |||
37 | 12 | public function __construct(PersisterRegistry $registry, EventDispatcherInterface $dispatcher) |
|
42 | |||
43 | /** |
||
44 | * {@inheritdoc} |
||
45 | */ |
||
46 | 11 | public function insert(PagerInterface $pager, array $options = []) |
|
47 | { |
||
48 | 11 | $pager->setMaxPerPage(empty($options['max_per_page']) ? 100 : $options['max_per_page']); |
|
49 | |||
50 | 11 | $options = \array_replace([ |
|
51 | 11 | 'max_per_page' => $pager->getMaxPerPage(), |
|
52 | 11 | 'first_page' => $pager->getCurrentPage(), |
|
53 | 11 | 'last_page' => $pager->getNbPages(), |
|
54 | 11 | ], $options); |
|
55 | |||
56 | 11 | $pager->setCurrentPage($options['first_page']); |
|
57 | |||
58 | 11 | $objectPersister = $this->registry->getPersister($options['indexName']); |
|
59 | |||
60 | try { |
||
61 | 11 | $this->dispatcher->dispatch($event = new PrePersistEvent($pager, $objectPersister, $options)); |
|
|
|||
62 | 11 | $pager = $event->getPager(); |
|
63 | 11 | $options = $event->getOptions(); |
|
64 | |||
65 | 11 | $lastPage = \min($options['last_page'], $pager->getNbPages()); |
|
66 | 11 | $page = $pager->getCurrentPage(); |
|
67 | do { |
||
68 | 11 | $pager->setCurrentPage($page); |
|
69 | |||
70 | 11 | $this->insertPage($page, $pager, $objectPersister, $options); |
|
71 | |||
72 | 10 | ++$page; |
|
73 | 10 | } while ($page <= $lastPage); |
|
74 | 10 | } finally { |
|
75 | 11 | $this->dispatcher->dispatch(new PostPersistEvent($pager, $objectPersister, $options)); |
|
76 | } |
||
77 | 10 | } |
|
78 | |||
79 | /** |
||
80 | * @throws \Exception |
||
81 | */ |
||
82 | 11 | private function insertPage(int $page, PagerInterface $pager, ObjectPersisterInterface $objectPersister, array $options = []): void |
|
119 | } |
||
120 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: