Skip to content

Commit

Permalink
Update for PHP 8
Browse files Browse the repository at this point in the history
  • Loading branch information
nicksagona committed Nov 16, 2022
1 parent 37bb286 commit 9a83a0b
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/Console.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}

Expand All @@ -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);
}
Expand All @@ -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];
Expand Down Expand Up @@ -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])) {
Expand All @@ -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);
}

Expand Down

0 comments on commit 9a83a0b

Please sign in to comment.