Skip to content

Commit 554883f

Browse files
committed
Upgrade phpstan and fix issues
1 parent 1316f37 commit 554883f

File tree

7 files changed

+29
-11
lines changed

7 files changed

+29
-11
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"require-dev": {
1717
"phpunit/phpunit": "^8.0",
1818
"squizlabs/php_codesniffer": "^3.2",
19-
"phpstan/phpstan": "^0.11"
19+
"phpstan/phpstan": "^0.12"
2020
},
2121
"require": {
2222
"php" : ">=7.1",

phpstan.neon

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
parameters:
2+
checkMissingIterableValueType: false

src/Builder/CliMenuBuilder.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,11 @@ public function setTitleSeparator(string $separator) : self
412412
return $this;
413413
}
414414

415+
/**
416+
* @param int|string|null $right
417+
* @param int|string|null $bottom
418+
* @param int|string|null $left
419+
*/
415420
public function setBorder(int $top, $right = null, $bottom = null, $left = null, string $colour = null) : self
416421
{
417422
$this->style->setBorder($top, $right, $bottom, $left, $colour);
@@ -447,7 +452,7 @@ public function setBorderLeftWidth(int $width) : self
447452
return $this;
448453
}
449454

450-
public function setBorderColour(string $colour, $fallback = null) : self
455+
public function setBorderColour(string $colour, string $fallback = null) : self
451456
{
452457
$this->style->setBorderColour($colour, $fallback);
453458

@@ -575,7 +580,7 @@ public function modifySelectableStyle(callable $itemCallable) : self
575580
* Pass styles from current menu to sub-menu
576581
* only if sub-menu style has not be customized
577582
*/
578-
private function propagateStyles(CliMenu $menu, array $items = [])
583+
private function propagateStyles(CliMenu $menu, array $items = []) : void
579584
{
580585
$currentItems = !empty($items) ? $items : $menu->getItems();
581586

src/CliMenu.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ public function askPassword(MenuStyle $style = null) : Password
757757
return new Password(new InputIO($this, $this->terminal), $style);
758758
}
759759

760-
private function guardSingleLine($text) : void
760+
private function guardSingleLine(string $text) : void
761761
{
762762
if (strpos($text, "\n") !== false) {
763763
throw new \InvalidArgumentException;

src/Exception/InvalidShortcutException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ class InvalidShortcutException extends \RuntimeException
99
{
1010
public static function fromShortcut(string $shortcut) : self
1111
{
12-
return new static(sprintf('Shortcut key must be only one character. Got: "%s"', $shortcut));
12+
return new self(sprintf('Shortcut key must be only one character. Got: "%s"', $shortcut));
1313
}
1414
}

src/Input/InputIO.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public function registerControlCallback(string $control, callable $callback) : v
9999
$this->callbacks[$control][] = $callback;
100100
}
101101

102-
private function getInputWidth(array $lines)
102+
private function getInputWidth(array $lines) : int
103103
{
104104
return max(
105105
array_map(

src/MenuStyle.php

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ protected function calculateContentWidth() : void
324324
}
325325
}
326326

327-
public function getFg()
327+
public function getFg() : string
328328
{
329329
return $this->fg;
330330
}
@@ -341,7 +341,7 @@ public function setFg(string $fg, string $fallback = null) : self
341341
return $this;
342342
}
343343

344-
public function getBg()
344+
public function getBg() : string
345345
{
346346
return $this->bg;
347347
}
@@ -420,6 +420,9 @@ private function generatePaddingTopBottomRows() : void
420420
$this->paddingTopBottomRows = array_fill(0, $this->paddingTopBottom, $paddingRow);
421421
}
422422

423+
/**
424+
* @return array
425+
*/
423426
public function getPaddingTopBottomRows() : array
424427
{
425428
return $this->paddingTopBottomRows;
@@ -559,17 +562,27 @@ private function generateBorderRows() : void
559562
$this->borderBottomRows = array_fill(0, $this->borderBottomWidth, $borderRow);
560563
}
561564

565+
/**
566+
* @return array
567+
*/
562568
public function getBorderTopRows() : array
563569
{
564570
return $this->borderTopRows;
565571
}
566572

573+
/**
574+
* @return array
575+
*/
567576
public function getBorderBottomRows() : array
568577
{
569578
return $this->borderBottomRows;
570579
}
571580

572581
/**
582+
* @param int|string|null $rightWidth
583+
* @param int|string|null $bottomWidth
584+
* @param int|string|null $leftWidth
585+
*
573586
* Shorthand function to set all borders values at once
574587
*/
575588
public function setBorder(
@@ -598,8 +611,6 @@ public function setBorder(
598611

599612
if (is_string($colour)) {
600613
$this->setBorderColour($colour);
601-
} elseif ($colour !== null) {
602-
throw new \InvalidArgumentException('Invalid colour');
603614
}
604615

605616
$this->calculateContentWidth();
@@ -647,7 +658,7 @@ public function setBorderLeftWidth(int $width) : self
647658
return $this;
648659
}
649660

650-
public function setBorderColour(string $colour, $fallback = null) : self
661+
public function setBorderColour(string $colour, string $fallback = null) : self
651662
{
652663
$this->borderColour = ColourUtil::validateColour(
653664
$this->terminal,

0 commit comments

Comments
 (0)