|
14 | 14 | /** |
15 | 15 | * Return true if all cased characters in the string are uppercase and there is |
16 | 16 | * at least one cased character, false otherwise. |
17 | | - * Python method with no known equivalent in PHP. |
| 17 | + * Python method with no knowrn equivalent in PHP. |
18 | 18 | */ |
19 | 19 | function is_upper($string) |
20 | 20 | { |
@@ -385,7 +385,7 @@ public function __construct($children=null) |
385 | 385 | if (!$children) |
386 | 386 | $children = array(); |
387 | 387 | elseif ($children instanceof Pattern) |
388 | | - $children = array($children); |
| 388 | + $children = func_get_args(); |
389 | 389 |
|
390 | 390 | foreach ($children as $c) { |
391 | 391 | $this->children[] = $c; |
@@ -638,7 +638,7 @@ public function match($left, $collected=null) |
638 | 638 | { |
639 | 639 | if (!$collected) |
640 | 640 | $collected = array(); |
641 | | - |
| 641 | + |
642 | 642 | $outcomes = array(); |
643 | 643 | foreach ($this->children as $p) { |
644 | 644 | list ($matched, $dump1, $dump2) = $outcome = $p->match($left, $collected); |
@@ -713,12 +713,11 @@ function parse_long($tokens, \ArrayIterator $options) |
713 | 713 | throw new \UnexpectedValueExeption(); |
714 | 714 |
|
715 | 715 | if (!$value) $value = null; |
716 | | - |
717 | 716 |
|
718 | 717 | $similar = array_filter($options, function($o) use ($long) { return $o->long && $o->long == $long; }, true); |
719 | 718 | if ('ExitException' == $tokens->error && !$similar) |
720 | 719 | $similar = array_filter($options, function($o) use ($long) { return $o->long && strpos($o->long, $long)===0; }, true); |
721 | | - |
| 720 | + |
722 | 721 | if (count($similar) > 1) { |
723 | 722 | // might be simply specified ambiguously 2+ times? |
724 | 723 | $tokens->raiseException("$long is not a unique prefix: ".implode(', ', array_map(function($o) { return $o->long; }, $similar))); |
@@ -750,7 +749,6 @@ function parse_long($tokens, \ArrayIterator $options) |
750 | 749 | $o->value = $value !== null ? $value : true; |
751 | 750 | } |
752 | 751 | } |
753 | | - |
754 | 752 | return array($o); |
755 | 753 | } |
756 | 754 |
|
@@ -1048,7 +1046,7 @@ public function __construct($options=array()) |
1048 | 1046 | function handle($doc, $argv=null) |
1049 | 1047 | { |
1050 | 1048 | try { |
1051 | | - if (!$argv && isset($_SERVER['argv'])) |
| 1049 | + if ($argv === null && isset($_SERVER['argv'])) |
1052 | 1050 | $argv = array_slice($_SERVER['argv'], 1); |
1053 | 1051 |
|
1054 | 1052 | ExitException::$usage = printable_usage($doc); |
|
0 commit comments