Skip to content

Fix 8.4 deprecations #284

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
Jul 29, 2025
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
14 changes: 7 additions & 7 deletions src/Builder/CliMenuBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class CliMenuBuilder
*/
private $subMenu = false;

public function __construct(Terminal $terminal = null)
public function __construct(?Terminal $terminal = null)
{
$this->terminal = $terminal ?? TerminalFactory::fromSystem();
$this->style = new MenuStyle($this->terminal);
Expand Down Expand Up @@ -249,7 +249,7 @@ public function addSubMenuFromBuilder(string $text, CliMenuBuilder $builder) : s
return $this;
}

public function enableAutoShortcuts(string $regex = null) : self
public function enableAutoShortcuts(?string $regex = null) : self
{
$this->autoShortcuts = true;

Expand Down Expand Up @@ -373,14 +373,14 @@ public function setExitButtonText(string $exitButtonText) : self
return $this;
}

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

return $this;
}

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

Expand All @@ -394,7 +394,7 @@ public function setWidth(int $width) : self
return $this;
}

public function setPadding(int $topBottom, int $leftRight = null) : self
public function setPadding(int $topBottom, ?int $leftRight = null) : self
{
$this->style->setPadding($topBottom, $leftRight);

Expand Down Expand Up @@ -452,7 +452,7 @@ public function setTitleSeparator(string $separator) : self
* @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
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 @@ -487,7 +487,7 @@ public function setBorderLeftWidth(int $width) : self
return $this;
}

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

Expand Down
2 changes: 1 addition & 1 deletion src/Builder/SplitItemBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public function setGutter(int $gutter) : self
return $this;
}

public function enableAutoShortcuts(string $regex = null) : self
public function enableAutoShortcuts(?string $regex = null) : self
{
$this->autoShortcuts = true;

Expand Down
16 changes: 8 additions & 8 deletions src/CliMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ class CliMenu
public function __construct(
?string $title,
array $items,
Terminal $terminal = null,
MenuStyle $style = null
?Terminal $terminal = null,
?MenuStyle $style = null
) {
$this->title = $title;
$this->items = $items;
Expand Down Expand Up @@ -696,7 +696,7 @@ public function getCurrentFrame() : Frame
return $this->currentFrame;
}

public function flash(string $text, MenuStyle $style = null) : Flash
public function flash(string $text, ?MenuStyle $style = null) : Flash
{
$this->guardSingleLine($text);

Expand All @@ -707,7 +707,7 @@ public function flash(string $text, MenuStyle $style = null) : Flash
return new Flash($this, $style, $this->terminal, $text);
}

public function confirm(string $text, MenuStyle $style = null) : Confirm
public function confirm(string $text, ?MenuStyle $style = null) : Confirm
{
$this->guardSingleLine($text);

Expand All @@ -718,7 +718,7 @@ public function confirm(string $text, MenuStyle $style = null) : Confirm
return new Confirm($this, $style, $this->terminal, $text);
}

public function cancellableConfirm(string $text, MenuStyle $style = null) : CancellableConfirm
public function cancellableConfirm(string $text, ?MenuStyle $style = null) : CancellableConfirm
{
$this->guardSingleLine($text);

Expand All @@ -729,7 +729,7 @@ public function cancellableConfirm(string $text, MenuStyle $style = null) : Canc
return new CancellableConfirm($this, $style, $this->terminal, $text);
}

public function askNumber(MenuStyle $style = null) : Number
public function askNumber(?MenuStyle $style = null) : Number
{
$this->assertOpen();

Expand All @@ -740,7 +740,7 @@ public function askNumber(MenuStyle $style = null) : Number
return new Number(new InputIO($this, $this->terminal), $style);
}

public function askText(MenuStyle $style = null) : Text
public function askText(?MenuStyle $style = null) : Text
{
$this->assertOpen();

Expand All @@ -751,7 +751,7 @@ public function askText(MenuStyle $style = null) : Text
return new Text(new InputIO($this, $this->terminal), $style);
}

public function askPassword(MenuStyle $style = null) : Password
public function askPassword(?MenuStyle $style = null) : Password
{
$this->assertOpen();

Expand Down
2 changes: 1 addition & 1 deletion src/Dialogue/Dialogue.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ protected function emptyRow() : void
/**
* Write some text at a particular column
*/
protected function write(string $text, int $column = null) : void
protected function write(string $text, ?int $column = null) : void
{
$this->terminal->moveCursorToColumn($column ?: $this->x);
$this->terminal->write($text);
Expand Down
12 changes: 6 additions & 6 deletions src/MenuStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ class MenuStyle
/**
* Initialise style
*/
public function __construct(Terminal $terminal = null)
public function __construct(?Terminal $terminal = null)
{
$this->terminal = $terminal ?: TerminalFactory::fromSystem();

Expand Down Expand Up @@ -401,7 +401,7 @@ public function getFg() : string
return $this->fg;
}

public function setFg(string $fg, string $fallback = null) : self
public function setFg(string $fg, ?string $fallback = null) : self
{
$this->fg = ColourUtil::validateColour(
$this->terminal,
Expand All @@ -418,7 +418,7 @@ public function getBg() : string
return $this->bg;
}

public function setBg(string $bg, string $fallback = null) : self
public function setBg(string $bg, ?string $fallback = null) : self
{
$this->bg = ColourUtil::validateColour(
$this->terminal,
Expand Down Expand Up @@ -522,7 +522,7 @@ public function getPaddingTopBottomRows() : array
return $this->paddingTopBottomRows;
}

public function setPadding(int $topBottom, int $leftRight = null) : self
public function setPadding(int $topBottom, ?int $leftRight = null) : self
{
if ($leftRight === null) {
$leftRight = $topBottom;
Expand Down Expand Up @@ -700,7 +700,7 @@ public function setBorder(
$rightWidth = null,
$bottomWidth = null,
$leftWidth = null,
string $colour = null
?string $colour = null
) : self {
if (!is_int($rightWidth)) {
$colour = $rightWidth;
Expand Down Expand Up @@ -768,7 +768,7 @@ public function setBorderLeftWidth(int $width) : self
return $this;
}

public function setBorderColour(string $colour, string $fallback = null) : self
public function setBorderColour(string $colour, ?string $fallback = null) : self
{
$this->borderColour = ColourUtil::validateColour(
$this->terminal,
Expand Down
2 changes: 1 addition & 1 deletion src/Util/ColourUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ public static function map256To8(int $colourCode) : string
* Check if $colour exists
* If it's a 256-colours code and $terminal doesn't support it, returns a fallback value
*/
public static function validateColour(Terminal $terminal, string $colour, string $fallback = null) : string
public static function validateColour(Terminal $terminal, string $colour, ?string $fallback = null) : string
{
if (!is_numeric($colour)) {
return self::validateColourName($colour);
Expand Down