From 9a83a0b5b12663e2996bd74ed781b7cc90a17496 Mon Sep 17 00:00:00 2001 From: Nick Sagona Date: Wed, 16 Nov 2022 09:02:31 -0600 Subject: [PATCH] Update for PHP 8 --- src/Console.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Console.php b/src/Console.php index a93d43e..2fc5e1c 100644 --- a/src/Console.php +++ b/src/Console.php @@ -412,7 +412,7 @@ public function getCommandsFromRoutes(Match\Cli $routeMatch, $scriptName = null) foreach ($commands as $name => $command) { $commandName = implode(' ', $command); - $params = trim(substr($name, strlen($commandName))); + $params = trim(substr((string)$name, strlen((string)$commandName))); $params = (!empty($params)) ? $params : null; $help = (isset($commandRoutes[$name]) && isset($commandRoutes[$name]['help'])) ? $commandRoutes[$name]['help'] : null; @@ -504,9 +504,9 @@ public function prompt($prompt, array $options = null, $caseSensitive = false, $ if (null !== $options) { $length = 0; foreach ($options as $key => $value) { - $options[$key] = ($caseSensitive) ? $value : strtolower($value); - if (strlen($value) > $length) { - $length = strlen($value); + $options[$key] = ($caseSensitive) ? $value : strtolower((string)$value); + if (strlen((string)$value) > $length) { + $length = strlen((string)$value); } } @@ -515,14 +515,14 @@ public function prompt($prompt, array $options = null, $caseSensitive = false, $ echo $this->indent . $prompt; } $promptInput = fopen('php://stdin', 'r'); - $input = fgets($promptInput, strlen($prompt) . $length); + $input = fgets($promptInput, strlen((string)$prompt) . $length); $input = ($caseSensitive) ? rtrim($input) : strtolower(rtrim($input)); fclose($promptInput); } } else { while (null === $input) { $promptInput = fopen('php://stdin', 'r'); - $input = fgets($promptInput, strlen($prompt) + $length); + $input = fgets($promptInput, strlen((string)$prompt) + $length); $input = ($caseSensitive) ? rtrim($input) : strtolower(rtrim($input)); fclose($promptInput); } @@ -541,7 +541,7 @@ public function prompt($prompt, array $options = null, $caseSensitive = false, $ public function append($text = null, $newline = true) { if ($this->width != 0) { - $lines = (strlen($text) > $this->width) ? + $lines = (strlen((string)$text) > $this->width) ? explode(PHP_EOL, wordwrap($text, $this->width, PHP_EOL)) : [$text]; } else { $lines = [$text]; @@ -608,10 +608,10 @@ public function displayHelp() foreach ($this->commands as $key => $command) { $name = $command->getName(); $params = $command->getParams(); - $length = strlen($name); + $length = strlen((string)$name); if (count($this->helpColors) > 0) { - if (strpos($name, ' ') !== false) { + if (strpos((string)$name, ' ') !== false) { $name1 = substr($name, 0, strpos($name, ' ')); $name2 = substr($name, strpos($name, ' ') + 1); if (isset($this->helpColors[0])) { @@ -627,7 +627,7 @@ public function displayHelp() } if (null !== $params) { - $length += (strlen($params) + 1); + $length += (strlen((string)$params) + 1); $name .= ' ' . ((isset($this->helpColors[2])) ? $this->colorize($params, $this->helpColors[2]) : $params); }