Skip to content

Upgrade phpstan and fix issues #221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"require-dev": {
"phpunit/phpunit": "^8.0",
"squizlabs/php_codesniffer": "^3.2",
"phpstan/phpstan": "^0.11"
"phpstan/phpstan": "^0.12"
},
"require": {
"php" : ">=7.1",
Expand Down
2 changes: 2 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
parameters:
checkMissingIterableValueType: false
9 changes: 7 additions & 2 deletions src/Builder/CliMenuBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,11 @@ public function setTitleSeparator(string $separator) : self
return $this;
}

/**
* @param int|string|null $right
* @param int|string|null $bottom
* @param int|string|null $left
*/
public function setBorder(int $top, $right = null, $bottom = null, $left = null, string $colour = null) : self
{
$this->style->setBorder($top, $right, $bottom, $left, $colour);
Expand Down Expand Up @@ -447,7 +452,7 @@ public function setBorderLeftWidth(int $width) : self
return $this;
}

public function setBorderColour(string $colour, $fallback = null) : self
public function setBorderColour(string $colour, string $fallback = null) : self
{
$this->style->setBorderColour($colour, $fallback);

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

Expand Down
2 changes: 1 addition & 1 deletion src/CliMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ public function askPassword(MenuStyle $style = null) : Password
return new Password(new InputIO($this, $this->terminal), $style);
}

private function guardSingleLine($text) : void
private function guardSingleLine(string $text) : void
{
if (strpos($text, "\n") !== false) {
throw new \InvalidArgumentException;
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/InvalidShortcutException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ class InvalidShortcutException extends \RuntimeException
{
public static function fromShortcut(string $shortcut) : self
{
return new static(sprintf('Shortcut key must be only one character. Got: "%s"', $shortcut));
return new self(sprintf('Shortcut key must be only one character. Got: "%s"', $shortcut));
}
}
2 changes: 1 addition & 1 deletion src/Input/InputIO.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function registerControlCallback(string $control, callable $callback) : v
$this->callbacks[$control][] = $callback;
}

private function getInputWidth(array $lines)
private function getInputWidth(array $lines) : int
{
return max(
array_map(
Expand Down
21 changes: 16 additions & 5 deletions src/MenuStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ protected function calculateContentWidth() : void
}
}

public function getFg()
public function getFg() : string
{
return $this->fg;
}
Expand All @@ -341,7 +341,7 @@ public function setFg(string $fg, string $fallback = null) : self
return $this;
}

public function getBg()
public function getBg() : string
{
return $this->bg;
}
Expand Down Expand Up @@ -420,6 +420,9 @@ private function generatePaddingTopBottomRows() : void
$this->paddingTopBottomRows = array_fill(0, $this->paddingTopBottom, $paddingRow);
}

/**
* @return array
*/
public function getPaddingTopBottomRows() : array
{
return $this->paddingTopBottomRows;
Expand Down Expand Up @@ -559,17 +562,27 @@ private function generateBorderRows() : void
$this->borderBottomRows = array_fill(0, $this->borderBottomWidth, $borderRow);
}

/**
* @return array
*/
public function getBorderTopRows() : array
{
return $this->borderTopRows;
}

/**
* @return array
*/
public function getBorderBottomRows() : array
{
return $this->borderBottomRows;
}

/**
* @param int|string|null $rightWidth
* @param int|string|null $bottomWidth
* @param int|string|null $leftWidth
*
* Shorthand function to set all borders values at once
*/
public function setBorder(
Expand Down Expand Up @@ -598,8 +611,6 @@ public function setBorder(

if (is_string($colour)) {
$this->setBorderColour($colour);
} elseif ($colour !== null) {
throw new \InvalidArgumentException('Invalid colour');
}

$this->calculateContentWidth();
Expand Down Expand Up @@ -647,7 +658,7 @@ public function setBorderLeftWidth(int $width) : self
return $this;
}

public function setBorderColour(string $colour, $fallback = null) : self
public function setBorderColour(string $colour, string $fallback = null) : self
{
$this->borderColour = ColourUtil::validateColour(
$this->terminal,
Expand Down