@@ -361,7 +361,7 @@ |
||
361 | 361 | } |
362 | 362 | |
363 | 363 | /** |
364 | - * @return array |
|
364 | + * @return SelectableItem[] |
|
365 | 365 | */ |
366 | 366 | private function getDefaultItems() |
367 | 367 | { |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | */ |
392 | 392 | private function itemsHaveExtra(array $items) |
393 | 393 | { |
394 | - return !empty(array_filter($items, function (MenuItemInterface $item) { |
|
394 | + return !empty(array_filter($items, function(MenuItemInterface $item) { |
|
395 | 395 | return $item->showsItemExtra(); |
396 | 396 | })); |
397 | 397 | } |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | */ |
405 | 405 | private function getMenuStyle() |
406 | 406 | { |
407 | - $diff = array_udiff_assoc($this->style, $this->getStyleClassDefaults(), function ($current, $default) { |
|
407 | + $diff = array_udiff_assoc($this->style, $this->getStyleClassDefaults(), function($current, $default) { |
|
408 | 408 | if ($current instanceof TerminalInterface) { |
409 | 409 | return 0; |
410 | 410 | } |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | */ |
455 | 455 | private function buildSubMenus(array $items) |
456 | 456 | { |
457 | - return array_map(function ($item) { |
|
457 | + return array_map(function($item) { |
|
458 | 458 | if (!is_string($item)) { |
459 | 459 | return $item; |
460 | 460 | } |
@@ -3,9 +3,9 @@ discard block |
||
3 | 3 | use PhpSchool\CliMenu\CliMenu; |
4 | 4 | use PhpSchool\CliMenu\CliMenuBuilder; |
5 | 5 | |
6 | -require_once(__DIR__ . '/../vendor/autoload.php'); |
|
6 | +require_once(__DIR__.'/../vendor/autoload.php'); |
|
7 | 7 | |
8 | -$itemCallable = function (CliMenu $menu) { |
|
8 | +$itemCallable = function(CliMenu $menu) { |
|
9 | 9 | echo $menu->getSelectedItem()->getText(); |
10 | 10 | }; |
11 | 11 | |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | ->addItem('Second Item', $itemCallable) |
16 | 16 | ->addItem('Third Item', $itemCallable) |
17 | 17 | ->disableDefaultItems() |
18 | - ->addItem('CUSTOM CLOSE', function (CliMenu $menu) { |
|
18 | + ->addItem('CUSTOM CLOSE', function(CliMenu $menu) { |
|
19 | 19 | $menu->close(); |
20 | 20 | }) |
21 | 21 | ->build(); |
@@ -3,9 +3,9 @@ discard block |
||
3 | 3 | use PhpSchool\CliMenu\CliMenu; |
4 | 4 | use PhpSchool\CliMenu\CliMenuBuilder; |
5 | 5 | |
6 | -require_once(__DIR__ . '/../vendor/autoload.php'); |
|
6 | +require_once(__DIR__.'/../vendor/autoload.php'); |
|
7 | 7 | |
8 | -$itemCallable = function (CliMenu $menu) { |
|
8 | +$itemCallable = function(CliMenu $menu) { |
|
9 | 9 | echo $menu->getSelectedItem()->getText(); |
10 | 10 | }; |
11 | 11 | |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | ->addLineBreak('-') |
17 | 17 | ->addSubMenu('Options') |
18 | 18 | ->setTitle('CLI Menu > Options') |
19 | - ->addItem('First option', function (CliMenu $menu) { |
|
19 | + ->addItem('First option', function(CliMenu $menu) { |
|
20 | 20 | echo sprintf('Executing option: %s', $menu->getSelectedItem()->getText()); |
21 | 21 | }) |
22 | 22 | ->addLineBreak('-') |
@@ -4,9 +4,9 @@ |
||
4 | 4 | use PhpSchool\CliMenu\CliMenuBuilder; |
5 | 5 | use PhpSchool\CliMenu\MenuItem\MenuItem; |
6 | 6 | |
7 | -require_once(__DIR__ . '/../vendor/autoload.php'); |
|
7 | +require_once(__DIR__.'/../vendor/autoload.php'); |
|
8 | 8 | |
9 | -$itemCallable = function (CliMenu $menu) { |
|
9 | +$itemCallable = function(CliMenu $menu) { |
|
10 | 10 | echo $menu->getSelectedItem()->getText(); |
11 | 11 | }; |
12 | 12 |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | : $this->selectedItem++; |
217 | 217 | |
218 | 218 | if (!array_key_exists($this->selectedItem, $this->items)) { |
219 | - $this->selectedItem = $direction === 'up' |
|
219 | + $this->selectedItem = $direction === 'up' |
|
220 | 220 | ? end($itemKeys) |
221 | 221 | : reset($itemKeys); |
222 | 222 | } elseif ($this->getSelectedItem()->canSelect()) { |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | $this->drawMenuItem(new LineBreakItem($this->style->getTitleSeparator())); |
264 | 264 | } |
265 | 265 | |
266 | - array_map(function ($item, $index) { |
|
266 | + array_map(function($item, $index) { |
|
267 | 267 | $this->drawMenuItem($item, $index === $this->selectedItem); |
268 | 268 | }, $this->items, array_keys($this->items)); |
269 | 269 |
@@ -202,7 +202,7 @@ |
||
202 | 202 | /** |
203 | 203 | * Move the selection in a given direction, up / down |
204 | 204 | * |
205 | - * @param $direction |
|
205 | + * @param string $direction |
|
206 | 206 | */ |
207 | 207 | protected function moveSelection($direction) |
208 | 208 | { |
@@ -5,7 +5,6 @@ |
||
5 | 5 | use PhpSchool\CliMenu\Exception\InvalidInstantiationException; |
6 | 6 | use PhpSchool\CliMenu\Exception\InvalidTerminalException; |
7 | 7 | use PhpSchool\CliMenu\MenuItem\LineBreakItem; |
8 | -use PhpSchool\CliMenu\MenuItem\MenuItem; |
|
9 | 8 | use PhpSchool\CliMenu\MenuItem\MenuItemInterface; |
10 | 9 | use PhpSchool\CliMenu\MenuItem\StaticItem; |
11 | 10 | use PhpSchool\CliMenu\Terminal\TerminalFactory; |
@@ -53,7 +53,7 @@ |
||
53 | 53 | */ |
54 | 54 | public function getRows(MenuStyle $style, $selected = false) |
55 | 55 | { |
56 | - return array_map(function ($row) use ($style) { |
|
56 | + return array_map(function($row) use ($style) { |
|
57 | 57 | $length = mb_strlen($row); |
58 | 58 | |
59 | 59 | $padding = $style->getContentWidth() - $length; |
@@ -47,7 +47,7 @@ |
||
47 | 47 | ) |
48 | 48 | ); |
49 | 49 | |
50 | - return array_map(function ($row, $key) use ($style, $marker, $length) { |
|
50 | + return array_map(function($row, $key) use ($style, $marker, $length) { |
|
51 | 51 | if ($key === 0) { |
52 | 52 | return $this->showItemExtra |
53 | 53 | ? sprintf('%s%s %s', $row, str_repeat(' ', $length - mb_strlen($row)), $style->getItemExtra()) |
@@ -305,7 +305,7 @@ |
||
305 | 305 | */ |
306 | 306 | public function setWidth($width) |
307 | 307 | { |
308 | - $availableWidth = $this->terminal->getWidth() - ($this->margin * 2) - ($this->padding * 2); |
|
308 | + $availableWidth = $this->terminal->getWidth() - ($this->margin*2) - ($this->padding*2); |
|
309 | 309 | |
310 | 310 | if ($width >= $availableWidth) { |
311 | 311 | $width = $availableWidth; |
@@ -106,7 +106,7 @@ |
||
106 | 106 | exec('stty -icanon'); |
107 | 107 | $this->isCanonical = true; |
108 | 108 | } else { |
109 | - exec('stty ' . $this->getOriginalConfiguration()); |
|
109 | + exec('stty '.$this->getOriginalConfiguration()); |
|
110 | 110 | $this->isCanonical = false; |
111 | 111 | } |
112 | 112 | } |