@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | */ |
162 | 162 | public function restoreOriginalConfiguration() : void |
163 | 163 | { |
164 | - exec('stty ' . $this->getOriginalConfiguration()); |
|
164 | + exec('stty '.$this->getOriginalConfiguration()); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | public function read(int $bytes): string |
270 | 270 | { |
271 | 271 | $buffer = ''; |
272 | - $this->input->read($bytes, function ($data) use (&$buffer) { |
|
272 | + $this->input->read($bytes, function($data) use (&$buffer) { |
|
273 | 273 | $buffer .= $data; |
274 | 274 | }); |
275 | 275 | return $buffer; |
@@ -39,7 +39,7 @@ |
||
39 | 39 | $inputStream = new ResourceInputStream($stream); |
40 | 40 | |
41 | 41 | $input = ''; |
42 | - $inputStream->read(4, function ($buffer) use (&$input) { |
|
42 | + $inputStream->read(4, function($buffer) use (&$input) { |
|
43 | 43 | $input .= $buffer; |
44 | 44 | }); |
45 | 45 |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | { |
110 | 110 | return max( |
111 | 111 | array_map( |
112 | - function (string $line) { |
|
112 | + function(string $line) { |
|
113 | 113 | return mb_strlen($line); |
114 | 114 | }, |
115 | 115 | $lines |
@@ -121,14 +121,14 @@ discard block |
||
121 | 121 | { |
122 | 122 | $lines = 5; //1. empty 2. prompt text 3. empty 4. input 5. empty |
123 | 123 | |
124 | - return (int) (ceil($this->parentMenu->getCurrentFrame()->count() / 2) - ceil($lines /2) + 1); |
|
124 | + return (int) (ceil($this->parentMenu->getCurrentFrame()->count() / 2) - ceil($lines / 2) + 1); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | private function calculateYPositionWithError() : int |
128 | 128 | { |
129 | 129 | $lines = 7; //1. empty 2. prompt text 3. empty 4. input 5. empty 6. error 7. empty |
130 | 130 | |
131 | - return (int) (ceil($this->parentMenu->getCurrentFrame()->count() / 2) - ceil($lines /2) + 1); |
|
131 | + return (int) (ceil($this->parentMenu->getCurrentFrame()->count() / 2) - ceil($lines / 2) + 1); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | private function calculateXPosition(Input $input, string $userInput) : int |
@@ -97,11 +97,11 @@ |
||
97 | 97 | |
98 | 98 | public function ask() : InputResult |
99 | 99 | { |
100 | - $this->inputIO->registerControlCallback(InputCharacter::UP, function (string $input) { |
|
100 | + $this->inputIO->registerControlCallback(InputCharacter::UP, function(string $input) { |
|
101 | 101 | return $this->validate($input) ? (int) $input + 1 : $input; |
102 | 102 | }); |
103 | 103 | |
104 | - $this->inputIO->registerControlCallback(InputCharacter::DOWN, function (string $input) { |
|
104 | + $this->inputIO->registerControlCallback(InputCharacter::DOWN, function(string $input) { |
|
105 | 105 | return $this->validate($input) ? (int) $input - 1 : $input; |
106 | 106 | }); |
107 | 107 |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | */ |
131 | 131 | protected function configureTerminal() : void |
132 | 132 | { |
133 | - if(!$this->terminal->isInteractive()){ |
|
133 | + if (!$this->terminal->isInteractive()) { |
|
134 | 134 | sleep(1); |
135 | 135 | exit(3); |
136 | 136 | } |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | : $this->selectedItem++; |
354 | 354 | |
355 | 355 | if ($this->selectedItem !== null && !array_key_exists($this->selectedItem, $this->items)) { |
356 | - $this->selectedItem = $direction === 'UP' |
|
356 | + $this->selectedItem = $direction === 'UP' |
|
357 | 357 | ? (int) end($itemKeys) |
358 | 358 | : (int) reset($itemKeys); |
359 | 359 | } |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | $frame->addRows($this->drawMenuItem(new LineBreakItem($this->style->getTitleSeparator()))); |
524 | 524 | } |
525 | 525 | |
526 | - array_map(function ($item, $index) use ($frame) { |
|
526 | + array_map(function($item, $index) use ($frame) { |
|
527 | 527 | $frame->addRows($this->drawMenuItem($item, $index === $this->selectedItem)); |
528 | 528 | }, $this->items, array_keys($this->items)); |
529 | 529 | |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | $borderColour = ''; |
575 | 575 | } |
576 | 576 | |
577 | - return array_map(function ($row) use ($invertedColoursSetCode, $invertedColoursUnsetCode, $borderColour) { |
|
577 | + return array_map(function($row) use ($invertedColoursSetCode, $invertedColoursUnsetCode, $borderColour) { |
|
578 | 578 | return sprintf( |
579 | 579 | "%s%s%s%s%s%s%s%s%s%s%s%s\n", |
580 | 580 | str_repeat(' ', $this->style->getMargin()), |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | |
253 | 253 | private function processItemShortcut(MenuItemInterface $item) : void |
254 | 254 | { |
255 | - $this->processIndividualShortcut($item, function (CliMenu $menu) use ($item) { |
|
255 | + $this->processIndividualShortcut($item, function(CliMenu $menu) use ($item) { |
|
256 | 256 | $menu->executeAsSelected($item); |
257 | 257 | }); |
258 | 258 | } |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | private function processSplitItemShortcuts(SplitItem $splitItem) : void |
261 | 261 | { |
262 | 262 | foreach ($splitItem->getItems() as $item) { |
263 | - $this->processIndividualShortcut($item, function (CliMenu $menu) use ($splitItem, $item) { |
|
263 | + $this->processIndividualShortcut($item, function(CliMenu $menu) use ($splitItem, $item) { |
|
264 | 264 | $current = $splitItem->getSelectedItemIndex(); |
265 | 265 | |
266 | 266 | $splitItem->setSelectedItemIndex( |
@@ -503,7 +503,7 @@ discard block |
||
503 | 503 | |
504 | 504 | private function itemsHaveExtra(array $items) : bool |
505 | 505 | { |
506 | - return !empty(array_filter($items, function (MenuItemInterface $item) { |
|
506 | + return !empty(array_filter($items, function(MenuItemInterface $item) { |
|
507 | 507 | return $item->showsItemExtra(); |
508 | 508 | })); |
509 | 509 | } |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | $missingLength = $style->getContentWidth() % $numberOfItems; |
137 | 137 | |
138 | 138 | return $this->buildRows( |
139 | - mapWithKeys($this->items, function (int $index, MenuItemInterface $item) use ($selected, $length, $style) { |
|
139 | + mapWithKeys($this->items, function(int $index, MenuItemInterface $item) use ($selected, $length, $style) { |
|
140 | 140 | $isSelected = $selected && $index === $this->selectedItemIndex; |
141 | 141 | |
142 | 142 | if ($item instanceof CheckboxItem || $item instanceof RadioItem) { |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | $extraPadLength = $largestItemExtra > 0 ? 2 + $largestItemExtra : 0; |
185 | 185 | |
186 | 186 | return array_map( |
187 | - function ($i) use ($cells, $length, $missingLength, $extraPadLength) { |
|
187 | + function($i) use ($cells, $length, $missingLength, $extraPadLength) { |
|
188 | 188 | return $this->buildRow($cells, $i, $length, $missingLength, $extraPadLength); |
189 | 189 | }, |
190 | 190 | range(0, max(array_map('count', $cells)) - 1) |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | implode( |
199 | 199 | '', |
200 | 200 | array_map( |
201 | - function ($cell) use ($index, $length, $extraPadLength) { |
|
201 | + function($cell) use ($index, $length, $extraPadLength) { |
|
202 | 202 | return $cell[$index] ?? str_repeat(' ', $length + $this->gutter + $extraPadLength); |
203 | 203 | }, |
204 | 204 | $cells |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | bool $isSelected, |
216 | 216 | string $itemExtra |
217 | 217 | ) : array { |
218 | - return array_map(function ($row, $index) use ($length, $style, $isSelected, $itemExtra) { |
|
218 | + return array_map(function($row, $index) use ($length, $style, $isSelected, $itemExtra) { |
|
219 | 219 | $invertedColoursSetCode = $isSelected |
220 | 220 | ? $style->getInvertedColoursSetCode() |
221 | 221 | : ''; |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | Assertion::inArray($position, [self::POSITION_CENTER, self::POSITION_RIGHT, self::POSITION_LEFT]); |
49 | 49 | |
50 | 50 | $this->setText($text); |
51 | - $this->position = $position; |
|
51 | + $this->position = $position; |
|
52 | 52 | $this->alternateText = $alt; |
53 | 53 | } |
54 | 54 | |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | |
65 | 65 | $padding = $style->getContentWidth() - $this->artLength; |
66 | 66 | |
67 | - return array_map(function ($row) use ($padding) { |
|
67 | + return array_map(function($row) use ($padding) { |
|
68 | 68 | switch ($this->position) { |
69 | 69 | case self::POSITION_LEFT: |
70 | 70 | break; |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function setText(string $text) : void |
113 | 113 | { |
114 | - $this->text = implode("\n", array_map(function (string $line) { |
|
114 | + $this->text = implode("\n", array_map(function(string $line) { |
|
115 | 115 | return rtrim($line, ' '); |
116 | 116 | }, explode("\n", $text))); |
117 | 117 |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | ) |
77 | 77 | ); |
78 | 78 | |
79 | - return mapWithKeys($rows, function (int $key, string $row) use ($style, $length) { |
|
79 | + return mapWithKeys($rows, function(int $key, string $row) use ($style, $length) { |
|
80 | 80 | $text = $this->disabled ? $style->getDisabledItemText($row) : $row; |
81 | 81 | |
82 | 82 | if ($key === 0) { |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | */ |
116 | 116 | public function getSelectAction() : ?callable |
117 | 117 | { |
118 | - return function (CliMenu $menu) { |
|
118 | + return function(CliMenu $menu) { |
|
119 | 119 | $this->showSubMenu($menu); |
120 | 120 | }; |
121 | 121 | } |