Make WordPress Core

Ticket #40109: 40109.3.patch

File 40109.3.patch, 6.0 KB (added by desrosj, 8 years ago)

Removes all each() calls, including those in Text_diff, Snoopy and in unit tests.

  • src/wp-admin/includes/class-wp-upgrader.php

     
    358358                $_files = $wp_filesystem->dirlist( $remote_destination, true, true );
    359359
    360360                // Flatten the resulting array, iterate using each as we append to the array during iteration.
    361                 while ( $f = each( $_files ) ) {
    362                         $file = $f['value'];
    363                         $name = $f['key'];
     361                foreach ( $_files as $key => $value ) {
     362                        $file = $value;
     363                        $name = $key;
    364364
    365365                        if ( ! isset( $file['files'] ) ) {
    366366                                continue;
  • src/wp-includes/Text/Diff/Engine/native.php

     
    190190                }
    191191                $matches = $ymatches[$line];
    192192                reset($matches);
    193                 while (list(, $y) = each($matches)) {
     193                foreach ( $matches as $y ) {
    194194                    if (empty($this->in_seq[$y])) {
    195195                        $k = $this->_lcsPos($y);
    196196                        assert($k > 0);
     
    198198                        break;
    199199                    }
    200200                }
    201                 while (list(, $y) = each($matches)) {
     201                foreach ( $matches as $y ) {
    202202                    if ($y > $this->seq[$k - 1]) {
    203203                        assert($y <= $this->seq[$k]);
    204204                        /* Optimization: this is a common case: next match is
  • src/wp-includes/class-snoopy.php

     
    183183                                                $frameurls = $this->_frameurls;
    184184                                                $this->_frameurls = array();
    185185
    186                                                 while(list(,$frameurl) = each($frameurls))
    187                                                 {
     186                                                foreach ( $frameurls as $frameurl ) {
    188187                                                        if($this->_framedepth < $this->maxframes)
    189188                                                        {
    190189                                                                $this->fetch($frameurl);
     
    243242                                        $frameurls = $this->_frameurls;
    244243                                        $this->_frameurls = array();
    245244
    246                                         while(list(,$frameurl) = each($frameurls))
    247                                         {
     245                                        foreach ( $frameurls as $frameurl ) {
    248246                                                if($this->_framedepth < $this->maxframes)
    249247                                                {
    250248                                                        $this->fetch($frameurl);
     
    341339                                                $frameurls = $this->_frameurls;
    342340                                                $this->_frameurls = array();
    343341
    344                                                 while(list(,$frameurl) = each($frameurls))
    345                                                 {
     342                                                foreach ( $frameurls as $frameurl ) {
    346343                                                        if($this->_framedepth < $this->maxframes)
    347344                                                        {
    348345                                                                $this->fetch($frameurl);
     
    408405                                        $frameurls = $this->_frameurls;
    409406                                        $this->_frameurls = array();
    410407
    411                                         while(list(,$frameurl) = each($frameurls))
     408                                        foreach ( $frameurls as $frameurl ) {
    412409                                        {
    413410                                                if($this->_framedepth < $this->maxframes)
    414411                                                {
     
    629626
    630627                // catenate the non-empty matches from the conditional subpattern
    631628
    632                 while(list($key,$val) = each($links[2]))
    633                 {
     629                foreach ( $links[2] as $key => $val ) {
    634630                        if(!empty($val))
    635631                                $match[] = $val;
    636632                }
    637633
    638                 while(list($key,$val) = each($links[3]))
    639                 {
     634                foreach ( $links[3] as $key => $val ) {
    640635                        if(!empty($val))
    641636                                $match[] = $val;
    642637                }
     
    821816                {
    822817                        if(!is_array($this->rawheaders))
    823818                                $this->rawheaders = (array)$this->rawheaders;
    824                         while(list($headerKey,$headerVal) = each($this->rawheaders))
     819
     820                        foreach ( $this->rawheaders as $headerKey => $headerVal ) {
    825821                                $headers .= $headerKey.": ".$headerVal."\r\n";
     822                        }
    826823                }
    827824                if(!empty($content_type)) {
    828825                        $headers .= "Content-type: $content_type";
     
    985982                {
    986983                        if(!is_array($this->rawheaders))
    987984                                $this->rawheaders = (array)$this->rawheaders;
    988                         while(list($headerKey,$headerVal) = each($this->rawheaders))
     985                        foreach ( $this->rawheaders as $headerKey => $headerVal ) {
    989986                                $headers[] = $headerKey.": ".$headerVal;
     987                        }
    990988                }
    991989                if(!empty($content_type)) {
    992990                        if ($content_type == "multipart/form-data")
     
    12041202                switch ($this->_submit_type) {
    12051203                        case "application/x-www-form-urlencoded":
    12061204                                reset($formvars);
    1207                                 while(list($key,$val) = each($formvars)) {
     1205                                foreach ( $formvars as $key => $val ) {
    12081206                                        if (is_array($val) || is_object($val)) {
    1209                                                 while (list($cur_key, $cur_val) = each($val)) {
     1207                                                foreach ( $val as $cur_key => $cur_val ) {
    12101208                                                        $postdata .= urlencode($key)."[]=".urlencode($cur_val)."&";
    12111209                                                }
    12121210                                        } else
     
    12181216                                $this->_mime_boundary = "Snoopy".md5(uniqid(microtime()));
    12191217
    12201218                                reset($formvars);
    1221                                 while(list($key,$val) = each($formvars)) {
     1219                                foreach ( $formvars as $key => $val ) {
    12221220                                        if (is_array($val) || is_object($val)) {
    1223                                                 while (list($cur_key, $cur_val) = each($val)) {
     1221                                                foreach ( $val as $cur_key => $cur_val ) {
    12241222                                                        $postdata .= "--".$this->_mime_boundary."\r\n";
    12251223                                                        $postdata .= "Content-Disposition: form-data; name=\"$key\[\]\"\r\n\r\n";
    12261224                                                        $postdata .= "$cur_val\r\n";
     
    12331231                                }
    12341232
    12351233                                reset($formfiles);
    1236                                 while (list($field_name, $file_names) = each($formfiles)) {
     1234                                foreach ( $formfiles as $field_name => $file_names ) {
    12371235                                        settype($file_names, "array");
    1238                                         while (list(, $file_name) = each($file_names)) {
     1236                                        foreach ( $file_names as $file_name ) {
    12391237                                                if (!is_readable($file_name)) continue;
    12401238
    12411239                                                $fp = fopen($file_name, "r");
  • tests/phpunit/includes/bootstrap.php

     
    126126        function __construct( $argv ) {
    127127                array_shift( $argv );
    128128                $options = array();
    129                 while ( list( $i, $arg ) = each( $argv ) ) {
     129                foreach ( $argv as $i => $arg ) {
    130130                        try {
    131131                                if ( strlen( $arg ) > 1 && $arg[0] === '-' && $arg[1] === '-' ) {
    132132                                        PHPUnit_Util_Getopt::parseLongOption( substr( $arg, 2 ), $this->longOptions, $options, $argv );