1 | <?php |
||
26 | class Importer implements EventSubscriberInterface |
||
27 | { |
||
28 | /** |
||
29 | * @var Import |
||
30 | */ |
||
31 | protected $import; |
||
32 | |||
33 | /** |
||
34 | * @var HandlerInterface |
||
35 | */ |
||
36 | protected $handler; |
||
37 | |||
38 | /** |
||
39 | * @var EventDispatcherInterface |
||
40 | */ |
||
41 | protected $eventDispatcher; |
||
42 | |||
43 | /** |
||
44 | * @var ImportResult |
||
45 | */ |
||
46 | protected $result; |
||
47 | |||
48 | /** |
||
49 | * @var int |
||
50 | */ |
||
51 | protected $batchSize = 20; |
||
52 | |||
53 | /** |
||
54 | * @param Import $import |
||
55 | * @param HandlerInterface $handler |
||
56 | * @param EventDispatcherInterface $dispatcher |
||
57 | * @param int $batchSize |
||
58 | 6 | */ |
|
59 | public function __construct(Import $import, HandlerInterface $handler, EventDispatcherInterface $dispatcher, $batchSize = 20) |
||
69 | |||
70 | /** |
||
71 | * @return Import |
||
72 | 4 | */ |
|
73 | public function getImport() |
||
77 | |||
78 | /** |
||
79 | * @return ImportResult |
||
80 | 4 | */ |
|
81 | public function getResult() |
||
85 | |||
86 | /** |
||
87 | * @inheritdoc |
||
88 | 4 | */ |
|
89 | public static function getSubscribedEvents() |
||
97 | |||
98 | /** |
||
99 | * @return EventDispatcherInterface |
||
100 | */ |
||
101 | public function getEventDispatcher() |
||
105 | |||
106 | /** |
||
107 | * @param int $size |
||
108 | * |
||
109 | * @throws \InvalidArgumentException When size is not a positive number |
||
110 | 6 | */ |
|
111 | public function setBatchSize($size) |
||
121 | |||
122 | /** |
||
123 | * Dispatched when item is filtered from the feed. |
||
124 | * |
||
125 | * @param ItemNotModifiedEvent $event |
||
126 | 4 | */ |
|
127 | public function onItemFiltered(ItemNotModifiedEvent $event) |
||
131 | |||
132 | /** |
||
133 | * Dispatched when item failed during modification. |
||
134 | * |
||
135 | * @param ItemNotModifiedEvent $event |
||
136 | */ |
||
137 | public function onItemFailed(ItemNotModifiedEvent $event) |
||
141 | |||
142 | /** |
||
143 | * Dispatched when item is processed but found invalid. |
||
144 | * |
||
145 | * @param InvalidItemEvent $event |
||
146 | */ |
||
147 | public function onItemInvalid(InvalidItemEvent $event) |
||
151 | |||
152 | /** |
||
153 | * @param string $name |
||
154 | * @param Event $event |
||
155 | 4 | */ |
|
156 | public function dispatchEvent($name, Event $event) |
||
160 | |||
161 | /** |
||
162 | * Runs the import. |
||
163 | * |
||
164 | * @param Feed $feed |
||
165 | 4 | */ |
|
166 | public function run(Feed $feed) |
||
195 | |||
196 | /** |
||
197 | * Returns the next item in the feed, or null if no more items are left. |
||
198 | * Use this when iterating over the feed. |
||
199 | * |
||
200 | * @param Feed $feed |
||
201 | * |
||
202 | 4 | * @return FeedItemBag|null |
|
203 | */ |
||
204 | protected function getNextItem(Feed $feed) |
||
214 | |||
215 | /** |
||
216 | * @param FeedItemBag $item |
||
217 | * |
||
218 | * @return SourceInterface |
||
219 | 4 | */ |
|
220 | protected function handleItem(FeedItemBag $item) |
||
235 | 4 | ||
236 | /** |
||
237 | 4 | * Dispatches an event indicating a successfully handled item. |
|
238 | 4 | * |
|
239 | 4 | * @param FeedItemBag $item |
|
240 | * @param SourceInterface $result |
||
241 | */ |
||
242 | protected function successItem(FeedItemBag $item, SourceInterface $result) |
||
249 | 4 | ||
250 | /** |
||
251 | 4 | * Dispatches an event indicating a skipped item. |
|
252 | 4 | * |
|
253 | 4 | * @param FeedItemBag $item |
|
254 | * @param string $reason |
||
255 | */ |
||
256 | protected function skipItem(FeedItemBag $item, $reason = '') |
||
263 | |||
264 | /** |
||
265 | * Dispatches an event indicating a failed item. |
||
266 | * |
||
267 | * @param FeedItemBag $item |
||
268 | 4 | * @param string $reason |
|
269 | */ |
||
270 | 4 | protected function failItem(FeedItemBag $item, $reason) |
|
277 | |||
278 | /** |
||
279 | * Dispatches exception event. |
||
280 | * |
||
281 | * @param \Exception $exception |
||
282 | */ |
||
283 | protected function handleException(\Exception $exception) |
||
287 | |||
288 | /** |
||
289 | * Flushes outstanding changes. |
||
290 | */ |
||
291 | protected function flush() |
||
295 | |||
296 | protected function clear() |
||
300 | } |
||
301 |
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.
Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.