Skip to content

Commit 9b16a29

Browse files
authored
Fix some phpstan findings (#180)
Fix some phpstan findings
2 parents 528484b + c30bb2a commit 9b16a29

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/CliMenu.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,8 @@ protected function moveSelectionVertically(string $direction) : void
312312

313313
if ($this->selectedItem !== null && !array_key_exists($this->selectedItem, $this->items)) {
314314
$this->selectedItem = $direction === 'UP'
315-
? end($itemKeys)
316-
: reset($itemKeys);
315+
? (int) end($itemKeys)
316+
: (int) reset($itemKeys);
317317
}
318318
} while (!$this->canSelect());
319319
}
@@ -332,15 +332,19 @@ protected function moveSelectionHorizontally(string $direction) : void
332332
$itemKeys = array_keys($item->getItems());
333333
$selectedItemIndex = $item->getSelectedItemIndex();
334334

335+
if (null === $selectedItemIndex) {
336+
$selectedItemIndex = 0;
337+
}
338+
335339
do {
336340
$direction === 'LEFT'
337341
? $selectedItemIndex--
338342
: $selectedItemIndex++;
339343

340344
if (!array_key_exists($selectedItemIndex, $item->getItems())) {
341345
$selectedItemIndex = $direction === 'LEFT'
342-
? end($itemKeys)
343-
: reset($itemKeys);
346+
? (int) end($itemKeys)
347+
: (int) reset($itemKeys);
344348
}
345349
} while (!$item->canSelectIndex($selectedItemIndex));
346350

0 commit comments

Comments
 (0)