Permalink
Browse files

added PHP 7.1 scalar and return type hints

  • Loading branch information...
dg committed Feb 5, 2019
1 parent d6c99cc commit bc2b262e9a841851cf72df6c6ae69e02eedfee00
Showing with 10 additions and 10 deletions.
  1. +5 −5 src/CommandLine/Console.php
  2. +5 −5 src/CommandLine/Parser.php
@@ -24,13 +24,13 @@ public function __construct()
}
public function useColors($state = true)
public function useColors(bool $state = true): void
{
$this->useColors = (bool) $state;
$this->useColors = $state;
}
public function color($color = null, $s = null)
public function color(?string $color, string $s = null): string
{
static $colors = [
'black' => '0;30', 'gray' => '1;30', 'silver' => '0;37', 'white' => '1;37',
@@ -40,13 +40,13 @@ public function color($color = null, $s = null)
null => '0',
];
if ($this->useColors) {
$c = explode('/', $color);
$c = explode('/', $color ?: '/');
return "\033["
. ($c[0] ? $colors[$c[0]] : '')
. (empty($c[1]) ? '' : ';4' . substr($colors[$c[1]], -1))
. 'm' . $s
. ($s === null ? '' : "\033[0m");
}
return $s;
return (string) $s;
}
}
@@ -34,7 +34,7 @@ class Parser
private $help;
public function __construct($help, array $defaults = [])
public function __construct(string $help, array $defaults = [])
{
$this->help = $help;
$this->options = $defaults;
@@ -68,7 +68,7 @@ public function __construct($help, array $defaults = [])
}
public function parse(array $args = null)
public function parse(array $args = null): array
{
if ($args === null) {
$args = isset($_SERVER['argv']) ? array_slice($_SERVER['argv'], 1) : [];
@@ -145,13 +145,13 @@ public function parse(array $args = null)
}
public function help()
public function help(): void
{
echo $this->help;
}
public function checkArg(array $opt, &$arg)
public function checkArg(array $opt, &$arg): void
{
if (!empty($opt[self::REALPATH])) {
$path = realpath($arg);
@@ -163,7 +163,7 @@ public function checkArg(array $opt, &$arg)
}
public function isEmpty()
public function isEmpty(): bool
{
return !isset($_SERVER['argv']) || count($_SERVER['argv']) < 2;
}

0 comments on commit bc2b262

Please sign in to comment.