Skip to content

Commit bc045d4

Browse files
committed
Scrutinizer fixes
1 parent a528751 commit bc045d4

File tree

6 files changed

+25
-29
lines changed

6 files changed

+25
-29
lines changed

src/Dialogue/Confirm.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function display(string $confirmText = 'OK') : void
4545
$this->style->getInvertedColoursSetCode(),
4646
$confirmText,
4747
$this->style->getInvertedColoursUnsetCode(),
48-
str_repeat(' ', ceil($promptWidth - $leftFill - mb_strlen($confirmText))),
48+
str_repeat(' ', (int) ceil($promptWidth - $leftFill - mb_strlen($confirmText))),
4949
$this->style->getColoursResetCode()
5050
));
5151

src/MenuItem/MenuMenuItem.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ public function __construct(string $text, CliMenu $subMenu, bool $disabled = fal
2929
*/
3030
public function getSelectAction() : ?callable
3131
{
32-
return [$this, 'showSubMenu'];
32+
return function (CliMenu $menu) {
33+
$this->showSubMenu($menu);
34+
};
3335
}
3436

3537
/**

src/MenuItem/SplitItem.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
namespace PhpSchool\CliMenu\MenuItem;
44

55
use Assert\Assertion;
6-
use PhpSchool\CliMenu\CliMenu;
7-
use PhpSchool\CliMenu\CliMenuBuilder;
86
use PhpSchool\CliMenu\MenuStyle;
97
use PhpSchool\CliMenu\Util\StringUtil;
108

src/MenuStyle.php

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace PhpSchool\CliMenu;
44

5-
use PhpSchool\CliMenu\Exception\InvalidInstantiationException;
65
use PhpSchool\CliMenu\Terminal\TerminalFactory;
76
use PhpSchool\CliMenu\Util\ColourUtil;
87
use PhpSchool\Terminal\Terminal;
@@ -219,25 +218,25 @@ public function __construct(Terminal $terminal = null)
219218
{
220219
$this->terminal = $terminal ?: TerminalFactory::fromSystem();
221220

222-
$this->fg = static::$defaultStyleValues['fg'];
223-
$this->bg = static::$defaultStyleValues['bg'];
221+
$this->fg = self::$defaultStyleValues['fg'];
222+
$this->bg = self::$defaultStyleValues['bg'];
224223

225224
$this->generateColoursSetCode();
226225

227-
$this->setWidth(static::$defaultStyleValues['width']);
228-
$this->setPaddingTopBottom(static::$defaultStyleValues['paddingTopBottom']);
229-
$this->setPaddingLeftRight(static::$defaultStyleValues['paddingLeftRight']);
230-
$this->setMargin(static::$defaultStyleValues['margin']);
231-
$this->setSelectedMarker(static::$defaultStyleValues['selectedMarker']);
232-
$this->setUnselectedMarker(static::$defaultStyleValues['unselectedMarker']);
233-
$this->setItemExtra(static::$defaultStyleValues['itemExtra']);
234-
$this->setDisplaysExtra(static::$defaultStyleValues['displaysExtra']);
235-
$this->setTitleSeparator(static::$defaultStyleValues['titleSeparator']);
236-
$this->setBorderTopWidth(static::$defaultStyleValues['borderTopWidth']);
237-
$this->setBorderRightWidth(static::$defaultStyleValues['borderRightWidth']);
238-
$this->setBorderBottomWidth(static::$defaultStyleValues['borderBottomWidth']);
239-
$this->setBorderLeftWidth(static::$defaultStyleValues['borderLeftWidth']);
240-
$this->setBorderColour(static::$defaultStyleValues['borderColour']);
226+
$this->setWidth(self::$defaultStyleValues['width']);
227+
$this->setPaddingTopBottom(self::$defaultStyleValues['paddingTopBottom']);
228+
$this->setPaddingLeftRight(self::$defaultStyleValues['paddingLeftRight']);
229+
$this->setMargin(self::$defaultStyleValues['margin']);
230+
$this->setSelectedMarker(self::$defaultStyleValues['selectedMarker']);
231+
$this->setUnselectedMarker(self::$defaultStyleValues['unselectedMarker']);
232+
$this->setItemExtra(self::$defaultStyleValues['itemExtra']);
233+
$this->setDisplaysExtra(self::$defaultStyleValues['displaysExtra']);
234+
$this->setTitleSeparator(self::$defaultStyleValues['titleSeparator']);
235+
$this->setBorderTopWidth(self::$defaultStyleValues['borderTopWidth']);
236+
$this->setBorderRightWidth(self::$defaultStyleValues['borderRightWidth']);
237+
$this->setBorderBottomWidth(self::$defaultStyleValues['borderBottomWidth']);
238+
$this->setBorderLeftWidth(self::$defaultStyleValues['borderLeftWidth']);
239+
$this->setBorderColour(self::$defaultStyleValues['borderColour']);
241240
}
242241

243242
public function hasChangedFromDefaults() : bool
@@ -262,7 +261,7 @@ public function hasChangedFromDefaults() : bool
262261
$this->marginAuto,
263262
];
264263

265-
return $currentValues !== array_values(static::$defaultStyleValues);
264+
return $currentValues !== array_values(self::$defaultStyleValues);
266265
}
267266

268267
public function getDisabledItemText(string $text) : string

src/Util/ColourUtil.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ class ColourUtil
286286

287287
public static function getDefaultColourNames() : array
288288
{
289-
return static::$defaultColoursNames;
289+
return self::$defaultColoursNames;
290290
}
291291

292292
/**
@@ -295,11 +295,11 @@ public static function getDefaultColourNames() : array
295295
*/
296296
public static function map256To8(int $colourCode) : string
297297
{
298-
if (!isset(static::$coloursMap[$colourCode])) {
298+
if (!isset(self::$coloursMap[$colourCode])) {
299299
throw new \InvalidArgumentException('Invalid colour code');
300300
}
301301

302-
return static::$coloursMap[$colourCode];
302+
return self::$coloursMap[$colourCode];
303303
}
304304

305305
/**

test/MenuItem/MenuMenuItemTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@ public function testGetSelectAction() : void
2828
$item = new MenuMenuItem('Item', $subMenu);
2929

3030
$action = $item->getSelectAction();
31-
$this->assertTrue(is_callable($action));
32-
$this->assertInternalType('array', $action);
33-
$this->assertSame($item, $action[0]);
34-
$this->assertSame('showSubMenu', $action[1]);
31+
$this->assertInternalType('callable', $action);
3532
}
3633

3734
public function testShowsItemExtra() : void

0 commit comments

Comments
 (0)