Completed
Push — master ( 150386...c5452c )
by Michael
02:44
created
src/CliMenu.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
     protected $parent;
62 62
 
63 63
     /**
64
-     * @param $title
64
+     * @param string|false $title
65 65
      * @param array $items
66 66
      * @param TerminalInterface|null $terminal
67 67
      * @param MenuStyle|null $style
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
     /**
205 205
      * Move the selection ina  given direction, up / down
206 206
      *
207
-     * @param $direction
207
+     * @param string $direction
208 208
      */
209 209
     protected function moveSelection($direction)
210 210
     {
Please login to merge, or discard this patch.
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -2,11 +2,9 @@
 block discarded – undo
2 2
 
3 3
 namespace PhpSchool\CliMenu;
4 4
 
5
-use Assert\Assertion;
6 5
 use PhpSchool\CliMenu\Exception\InvalidInstantiationException;
7 6
 use PhpSchool\CliMenu\Exception\InvalidTerminalException;
8 7
 use PhpSchool\CliMenu\MenuItem\LineBreakItem;
9
-use PhpSchool\CliMenu\MenuItem\MenuItem;
10 8
 use PhpSchool\CliMenu\MenuItem\MenuItemInterface;
11 9
 use PhpSchool\CliMenu\MenuItem\StaticItem;
12 10
 use PhpSchool\CliMenu\Terminal\TerminalFactory;
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/CliMenuBuilder.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -361,7 +361,7 @@
 block discarded – undo
361 361
     }
362 362
 
363 363
     /**
364
-     * @return array
364
+     * @return SelectableItem[]
365 365
      */
366 366
     private function getDefaultItems()
367 367
     {
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
     {
368 368
         $actions = [];
369 369
         if ($this->parent) {
370
-            $actions[] = new SelectableItem($this->goBackButtonText, function (CliMenu $child) {
370
+            $actions[] = new SelectableItem($this->goBackButtonText, function(CliMenu $child) {
371 371
                 if ($parent = $child->getParent()) {
372 372
                     $child->closeThis();
373 373
                     $parent->open();
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
             });
376 376
         }
377 377
         
378
-        $actions[] = new SelectableItem($this->exitButtonText, function (CliMenu $menu) {
378
+        $actions[] = new SelectableItem($this->exitButtonText, function(CliMenu $menu) {
379 379
             $menu->close();
380 380
         });
381 381
         return $actions;
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
      */
398 398
     private function itemsHaveExtra(array $items)
399 399
     {
400
-        return !empty(array_filter($items, function (MenuItemInterface $item) {
400
+        return !empty(array_filter($items, function(MenuItemInterface $item) {
401 401
             return $item->showsItemExtra();
402 402
         }));
403 403
     }
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
      */
411 411
     private function getMenuStyle()
412 412
     {
413
-        $diff = array_udiff_assoc($this->style, $this->getStyleClassDefaults(), function ($current, $default) {
413
+        $diff = array_udiff_assoc($this->style, $this->getStyleClassDefaults(), function($current, $default) {
414 414
             if ($current instanceof TerminalInterface) {
415 415
                 return 0;
416 416
             }
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
      */
461 461
     private function buildSubMenus(array $items)
462 462
     {
463
-        return array_map(function ($item) {
463
+        return array_map(function($item) {
464 464
             if (!is_string($item)) {
465 465
                 return $item;
466 466
             }
Please login to merge, or discard this patch.
src/Terminal/WindowsTerminal.php 1 patch
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
     /**
54 54
      * Check if TTY is in raw mode
55 55
      *
56
-     * @return bool
56
+     * @return boolean|null
57 57
      */
58 58
     public function isRaw()
59 59
     {
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
     /**
64 64
      * Test whether terminal is valid TTY
65 65
      *
66
-     * @return bool
66
+     * @return boolean|null
67 67
      */
68 68
     public function isTTY()
69 69
     {
Please login to merge, or discard this patch.
examples/remove-defaults.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -3,9 +3,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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();
Please login to merge, or discard this patch.
examples/submenu.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -3,9 +3,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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('-')
Please login to merge, or discard this patch.
examples/useful-separation.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,9 +4,9 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/MenuItem/AsciiArtItem.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@
 block discarded – undo
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;
Please login to merge, or discard this patch.
src/MenuItem/SelectableTrait.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@
 block discarded – undo
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())
Please login to merge, or discard this patch.
src/MenuStyle.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -305,7 +305,7 @@
 block discarded – undo
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;
Please login to merge, or discard this patch.