Permalink
Browse files

uses PHP 7.1 features

  • Loading branch information...
dg committed Feb 5, 2019
1 parent 3ba10c9 commit d6c99cce9ea10207560ec1a8b25d190067c80800
Showing with 4 additions and 4 deletions.
  1. +4 −4 src/CommandLine/Parser.php
@@ -13,7 +13,7 @@
*/
class Parser
{
const
public const
ARGUMENT = 'argument',
OPTIONAL = 'optional',
REPEATABLE = 'repeatable',
@@ -47,13 +47,13 @@ public function __construct($help, array $defaults = [])
}
$name = end($m[1]);
$opts = isset($this->options[$name]) ? $this->options[$name] : [];
$opts = $this->options[$name] ?? [];
$this->options[$name] = $opts + [
self::ARGUMENT => (bool) end($m[2]),
self::OPTIONAL => isset($line[2]) || (substr(end($m[2]), 0, 1) === '[') || isset($opts[self::VALUE]),
self::REPEATABLE => (bool) end($m[3]),
self::ENUM => count($enums = explode('|', trim(end($m[2]), '<[]>'))) > 1 ? $enums : null,
self::VALUE => isset($line[2]) ? $line[2] : null,
self::VALUE => $line[2] ?? null,
];
if ($name !== $m[1][0]) {
$this->aliases[$m[1][0]] = $name;
@@ -93,7 +93,7 @@ public function parse(array $args = null)
continue;
}
list($name, $arg) = strpos($arg, '=') ? explode('=', $arg, 2) : [$arg, true];
[$name, $arg] = strpos($arg, '=') ? explode('=', $arg, 2) : [$arg, true];
if (isset($this->aliases[$name])) {
$name = $this->aliases[$name];

0 comments on commit d6c99cc

Please sign in to comment.