From 237f70e1032b16d32ff3f65dcda68706911e1c74 Mon Sep 17 00:00:00 2001 From: Craig Duncan Date: Mon, 18 Nov 2024 09:09:55 +0000 Subject: [PATCH] Add support for PHP 8.4 --- .github/workflows/buildcheck.yml | 1 + CHANGELOG.md | 13 +++++++++++++ src/Argument/Manager.php | 6 +++--- src/Argument/Parser.php | 8 ++++---- src/CLImate.php | 2 +- src/Logger.php | 2 +- src/TerminalObject/Dynamic/Animation.php | 2 +- src/TerminalObject/Dynamic/Checkboxes.php | 2 +- src/TerminalObject/Dynamic/Confirm.php | 2 +- src/TerminalObject/Dynamic/Input.php | 2 +- src/TerminalObject/Dynamic/Progress.php | 2 +- src/TerminalObject/Router/Router.php | 2 +- src/Util/UtilFactory.php | 2 +- 13 files changed, 30 insertions(+), 16 deletions(-) diff --git a/.github/workflows/buildcheck.yml b/.github/workflows/buildcheck.yml index 07160511..26570e68 100644 --- a/.github/workflows/buildcheck.yml +++ b/.github/workflows/buildcheck.yml @@ -19,6 +19,7 @@ jobs: - "8.1" - "8.2" - "8.3" + - "8.4" composer: - "" - "--prefer-lowest" diff --git a/CHANGELOG.md b/CHANGELOG.md index 881f5e16..59c42c8c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,19 @@ Changelog ========= +Adds methods in Progress to return the current value and total value of the progress bar. (#206) +-------- + +## 3.10.0 - 2024-11-18 + +### Added + +* [Progress] Added methods to get the current and total values. [#206](https://github.com/thephpleague/climate/pull/206) + +### Changed + +* [Support] Added support for PHP 8.4. + -------- ## 3.9.0 - 2024-10-30 diff --git a/src/Argument/Manager.php b/src/Argument/Manager.php index 324c1742..29772576 100644 --- a/src/Argument/Manager.php +++ b/src/Argument/Manager.php @@ -142,7 +142,7 @@ public function all() * * @return bool */ - public function defined($name, array $argv = null) + public function defined($name, ?array $argv = null) { // The argument isn't defined if it's not defined by the calling code. if (!$this->exists($name)) { @@ -217,7 +217,7 @@ public function description($description) * @param CLImate $climate * @param array $argv */ - public function usage(CLImate $climate, array $argv = null) + public function usage(CLImate $climate, ?array $argv = null) { $this->summary ->setClimate($climate) @@ -232,7 +232,7 @@ public function usage(CLImate $climate, array $argv = null) * * @param array $argv */ - public function parse(array $argv = null) + public function parse(?array $argv = null) { $this->parser->setFilter($this->filter, $this->all()); diff --git a/src/Argument/Parser.php b/src/Argument/Parser.php index 242aeb99..66bd2097 100644 --- a/src/Argument/Parser.php +++ b/src/Argument/Parser.php @@ -68,7 +68,7 @@ public function setFilter($filter, $arguments) * @return void * @throws InvalidArgumentException if required arguments aren't defined. */ - public function parse(array $argv = null) + public function parse(?array $argv = null) { $cliArguments = $this->arguments($argv); @@ -103,7 +103,7 @@ public function parse(array $argv = null) * * @return string */ - public function command(array $argv = null) + public function command(?array $argv = null) { return $this->getCommandAndArguments($argv)['command']; } @@ -115,7 +115,7 @@ public function command(array $argv = null) * * @return array */ - public function arguments(array $argv = null) + public function arguments(?array $argv = null) { return $this->getCommandAndArguments($argv)['arguments']; } @@ -315,7 +315,7 @@ protected function findPrefixedArgument($name) * @param array $argv * @return array */ - protected function getCommandAndArguments(array $argv = null) + protected function getCommandAndArguments(?array $argv = null) { // If no $argv is provided then use the global PHP defined $argv. if (is_null($argv)) { diff --git a/src/CLImate.php b/src/CLImate.php index 5c7c0aac..706651a6 100644 --- a/src/CLImate.php +++ b/src/CLImate.php @@ -257,7 +257,7 @@ public function to($writer) * @param array $argv * @return void */ - public function usage(array $argv = null) + public function usage(?array $argv = null) { $this->arguments->usage($this, $argv); } diff --git a/src/Logger.php b/src/Logger.php index d91a9f63..e4359a04 100644 --- a/src/Logger.php +++ b/src/Logger.php @@ -46,7 +46,7 @@ class Logger extends AbstractLogger * @param string $level One of the LogLevel constants * @param CLImate $climate An existing CLImate instance to use for output */ - public function __construct($level = LogLevel::INFO, CLImate $climate = null) + public function __construct($level = LogLevel::INFO, ?CLImate $climate = null) { $this->level = $this->convertLevel($level); diff --git a/src/TerminalObject/Dynamic/Animation.php b/src/TerminalObject/Dynamic/Animation.php index aa8a63b1..1352685c 100644 --- a/src/TerminalObject/Dynamic/Animation.php +++ b/src/TerminalObject/Dynamic/Animation.php @@ -20,7 +20,7 @@ class Animation extends DynamicTerminalObject */ protected $keyframes; - public function __construct($art, Sleeper $sleeper = null, Keyframe $keyframes = null) + public function __construct($art, ?Sleeper $sleeper = null, ?Keyframe $keyframes = null) { // Add the default art directory $this->addDir(__DIR__ . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . 'ASCII'); diff --git a/src/TerminalObject/Dynamic/Checkboxes.php b/src/TerminalObject/Dynamic/Checkboxes.php index 1eec76e2..4ad89e8a 100644 --- a/src/TerminalObject/Dynamic/Checkboxes.php +++ b/src/TerminalObject/Dynamic/Checkboxes.php @@ -14,7 +14,7 @@ class Checkboxes extends InputAbstract */ protected $checkboxes; - public function __construct($prompt, array $options, ReaderInterface $reader = null) + public function __construct($prompt, array $options, ?ReaderInterface $reader = null) { $this->prompt = $prompt; $this->reader = $reader ?: new Stdin(); diff --git a/src/TerminalObject/Dynamic/Confirm.php b/src/TerminalObject/Dynamic/Confirm.php index 656ea1eb..003bcaf2 100644 --- a/src/TerminalObject/Dynamic/Confirm.php +++ b/src/TerminalObject/Dynamic/Confirm.php @@ -13,7 +13,7 @@ class Confirm extends Input /** * @inheritdoc */ - public function __construct($prompt, ReaderInterface $reader = null) + public function __construct($prompt, ?ReaderInterface $reader = null) { parent::__construct($prompt, $reader); diff --git a/src/TerminalObject/Dynamic/Input.php b/src/TerminalObject/Dynamic/Input.php index 9a9ab4ef..3f6d714d 100644 --- a/src/TerminalObject/Dynamic/Input.php +++ b/src/TerminalObject/Dynamic/Input.php @@ -45,7 +45,7 @@ class Input extends InputAbstract */ protected $default = ''; - public function __construct($prompt, ReaderInterface $reader = null) + public function __construct($prompt, ?ReaderInterface $reader = null) { $this->prompt = $prompt; $this->reader = $reader ?: new Stdin(); diff --git a/src/TerminalObject/Dynamic/Progress.php b/src/TerminalObject/Dynamic/Progress.php index 9fa19f62..23373938 100644 --- a/src/TerminalObject/Dynamic/Progress.php +++ b/src/TerminalObject/Dynamic/Progress.php @@ -169,7 +169,7 @@ public function forceRedraw($force = true) * @param iterable $items Array or any other iterable object * @param callable $callback A handler to run on each item */ - public function each($items, callable $callback = null) + public function each($items, ?callable $callback = null) { if ($items instanceof \Traversable) { $items = iterator_to_array($items); diff --git a/src/TerminalObject/Router/Router.php b/src/TerminalObject/Router/Router.php index 7632086e..c9cc8ff2 100644 --- a/src/TerminalObject/Router/Router.php +++ b/src/TerminalObject/Router/Router.php @@ -36,7 +36,7 @@ class Router */ protected $basic; - public function __construct(DynamicRouter $dynamic = null, BasicRouter $basic = null) + public function __construct(?DynamicRouter $dynamic = null, ?BasicRouter $basic = null) { $this->dynamic = $dynamic ?: new DynamicRouter(); $this->basic = $basic ?: new BasicRouter(); diff --git a/src/Util/UtilFactory.php b/src/Util/UtilFactory.php index 3584a6b4..1fb765e6 100644 --- a/src/Util/UtilFactory.php +++ b/src/Util/UtilFactory.php @@ -22,7 +22,7 @@ class UtilFactory */ public $cursor; - public function __construct(System $system = null, Cursor $cursor = null) + public function __construct(?System $system = null, ?Cursor $cursor = null) { $this->system = $system ?: SystemFactory::getInstance(); $this->cursor = $cursor ?: new Cursor();