Skip to content

Commit

Permalink
Suppress the each() function's deprecation error
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Feb 5, 2017
1 parent ee54bd6 commit 20c70e0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Util/Getopt.php
Expand Up @@ -34,7 +34,7 @@ public static function getopt(array $args, $short_options, $long_options = null)

reset($args);

while (list($i, $arg) = each($args)) {
while (list($i, $arg) = @each($args)) {

This comment has been minimized.

Copy link
@staabm

staabm Feb 5, 2017

Contributor

Just foreach instead?

This comment has been minimized.

Copy link
@sebastianbergmann

sebastianbergmann Feb 6, 2017

Author Owner

Unfortunately it's not that simple as the array pointer is advanced inside the loop using another each().

if ($arg == '') {
continue;
}
Expand Down Expand Up @@ -91,7 +91,7 @@ protected static function parseShortOption($arg, $short_options, &$opts, &$args)
if ($i + 1 < $argLen) {
$opts[] = [$opt, substr($arg, $i + 1)];
break;
} elseif (list(, $opt_arg) = each($args)) {
} elseif (list(, $opt_arg) = @each($args)) {
} else {
throw new PHPUnit_Framework_Exception(
"option requires an argument -- $opt"
Expand Down Expand Up @@ -136,7 +136,7 @@ protected static function parseLongOption($arg, $long_options, &$opts, &$args)

if (substr($long_opt, -1) == '=') {
if (substr($long_opt, -2) != '==') {
if (!strlen($opt_arg) && !(list(, $opt_arg) = each($args))) {
if (!strlen($opt_arg) && !(list(, $opt_arg) = @each($args))) {
throw new PHPUnit_Framework_Exception(
"option --$opt requires an argument"
);
Expand Down

0 comments on commit 20c70e0

Please sign in to comment.