Skip to content

[FIX] deprecated function use #250

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

Closed
wants to merge 1 commit into from
Closed
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
34 changes: 18 additions & 16 deletions src/MenuStyle.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace PhpSchool\CliMenu;

use PhpSchool\CliMenu\Exception\CannotShrinkMenuException;
Expand Down Expand Up @@ -300,11 +302,11 @@ public function getDisabledItemText(string $text) : string
/**
* Get the ansi escape sequence for the foreground colour.
*
* @param bool $bright Whether to modify to the ansi bright variation
* @param bool|null $bright Whether to modify to the ansi bright variation
*
* @return string
*/
private function getForegroundColourCode(bool $bright = false) : string
private function getForegroundColourCode(?bool $bright = false) : string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this changed? It doesn't seem related

{
if (!ctype_digit($this->fg)) {
$fgCode = (int)self::$availableForegroundColors[$this->fg];
Expand All @@ -319,11 +321,11 @@ private function getForegroundColourCode(bool $bright = false) : string
/**
* Get the ansi escape sequence for the background colour.
*
* @param bool $bright Whether to modify to the ansi bright variation
* @param bool|null $bright Whether to modify to the ansi bright variation
*
* @return string
*/
private function getBackgroundColourCode(bool $bright = false) : string
private function getBackgroundColourCode(?bool $bright = false) : string
{
if (!ctype_digit($this->bg)) {
$bgCode = (int)self::$availableBackgroundColors[$this->bg];
Expand Down Expand Up @@ -488,15 +490,15 @@ private function generatePaddingTopBottomRows() : void

$paddingRow = sprintf(
"%s%s%s%s%s%s%s%s%s%s\n",
$this->debugMode ? $this->getDebugString($this->margin) : str_repeat(' ', $this->margin),
$this->debugMode ? $this->getDebugString($this->margin) : str_repeat(' ', $this->margin ?? 0),
$borderColour,
str_repeat(' ', $this->borderLeftWidth),
str_repeat(' ', $this->borderLeftWidth ?? 0),
$this->getColoursSetCode(),
str_repeat(' ', $this->paddingLeftRight),
str_repeat(' ', $this->contentWidth),
str_repeat(' ', $this->paddingLeftRight),
str_repeat(' ', $this->paddingLeftRight ?? 0),
str_repeat(' ', $this->contentWidth ?? 0),
str_repeat(' ', $this->paddingLeftRight ?? 0),
$borderColour,
str_repeat(' ', $this->borderRightWidth),
str_repeat(' ', $this->borderRightWidth ?? 0),
$this->coloursResetCode
);

Expand All @@ -509,8 +511,8 @@ private function generatePaddingTopBottomRows() : void
);
}

$this->paddingTopBottom = $this->paddingTopBottom >= 0 ? $this->paddingTopBottom : 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused how this even becomes null

$this->paddingTopBottomRows = array_fill(0, $this->paddingTopBottom, $paddingRow);
$this->paddingTopBottom = max($this->paddingTopBottom, 0);
$this->paddingTopBottomRows = array_fill(0, $this->paddingTopBottom ?? 0, $paddingRow);
}

/**
Expand Down Expand Up @@ -664,12 +666,12 @@ private function generateBorderRows() : void
);
}

$this->borderTopWidth = $this->borderTopWidth >= 0 ? $this->borderTopWidth : 0;
$this->borderBottomWidth = $this->borderBottomWidth >= 0 ? $this->borderBottomWidth : 0;
$this->borderTopWidth = max($this->borderTopWidth, 0);
$this->borderBottomWidth = max($this->borderBottomWidth, 0);


$this->borderTopRows = array_fill(0, $this->borderTopWidth, $borderRow);
$this->borderBottomRows = array_fill(0, $this->borderBottomWidth, $borderRow);
$this->borderTopRows = array_fill(0, $this->borderTopWidth ?? 0, $borderRow);
$this->borderBottomRows = array_fill(0, $this->borderBottomWidth ?? 0, $borderRow);
}

/**
Expand Down