Browse Source

Avoid array (but not argument) unpacking

Array unpacking requires PHP 7.4; array_merge is clearer in any case
master
J. King 2 years ago
parent
commit
c52ee8b537
  1. 6
      lib/Docopt.php

6
lib/Docopt.php

@ -152,12 +152,12 @@ class Docopt {
# groups.append(child.children + children) # groups.append(child.children + children)
if ($child instanceof Either) { if ($child instanceof Either) {
foreach ($child->children as $c) { foreach ($child->children as $c) {
$groups[] = [$c, ...$children]; $groups[] = array_merge([$c], $children);
} }
} elseif ($child instanceof OneOrMore) { } elseif ($child instanceof OneOrMore) {
$groups[] = [...$child->children, ...$child->children, ...$children]; $groups[] = array_merge($child->children, $child->children, $children);
} else { } else {
$groups[] = [...$child->children, ...$children]; $groups[] = array_merge($child->children, $children);
} }
} }
# else: # else:

Loading…
Cancel
Save