WordPress.org

Make WordPress Core


Ignore:
Timestamp:
05/01/2020 07:05:04 PM (7 months ago)
Author:
desrosj
Message:

General: Fix various issues flagged by the PHPCompatibilityWP PHPCS ruleset.

As part of the continued effort to improve PHP compatibility, the following improvments are being made:

  • Removing deprecated PHP safe_mode checks not found in bundled external libraries.
  • Change the remaining while loops using each() to foreach loops.
  • Prevent false positives from being flagged for the sodium_compat library being caused by loading this in a non-standard way.
  • Add inline comments to not flag deprecated PHP directives in the getID3 library.

Props desrosj, earnjam, dryanpress.
See #49922.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-snoopy.php

    r42201 r47735  
    184184                        $this->_frameurls = array();
    185185
    186                         while(list(,$frameurl) = each($frameurls))
     186                        foreach ( $frameurls as $frameurl )
    187187                        {
    188188                            if($this->_framedepth < $this->maxframes)
     
    244244                    $this->_frameurls = array();
    245245
    246                     while(list(,$frameurl) = each($frameurls))
     246                    foreach ( $frameurls as $frameurl )
    247247                    {
    248248                        if($this->_framedepth < $this->maxframes)
     
    342342                        $this->_frameurls = array();
    343343
    344                         while(list(,$frameurl) = each($frameurls))
     344                        foreach ( $frameurls as $frameurl )
    345345                        {
    346346                            if($this->_framedepth < $this->maxframes)
     
    409409                    $this->_frameurls = array();
    410410
    411                     while(list(,$frameurl) = each($frameurls))
     411                    foreach ( $frameurls as $frameurl )
    412412                    {
    413413                        if($this->_framedepth < $this->maxframes)
     
    630630        // catenate the non-empty matches from the conditional subpattern
    631631
    632         while(list($key,$val) = each($links[2]))
     632        foreach ( $links[2] as $key => $val )
    633633        {
    634634            if(!empty($val))
     
    636636        }
    637637
    638         while(list($key,$val) = each($links[3]))
     638        foreach ( $links[3] as $key => $val )
    639639        {
    640640            if(!empty($val))
     
    822822            if(!is_array($this->rawheaders))
    823823                $this->rawheaders = (array)$this->rawheaders;
    824             while(list($headerKey,$headerVal) = each($this->rawheaders))
     824            foreach ( $this->rawheaders as $headerKey => $headerVal )
    825825                $headers .= $headerKey.": ".$headerVal."\r\n";
    826826        }
     
    986986            if(!is_array($this->rawheaders))
    987987                $this->rawheaders = (array)$this->rawheaders;
    988             while(list($headerKey,$headerVal) = each($this->rawheaders))
     988            foreach ( $this->rawheaders as $headerKey => $headerVal )
    989989                $headers[] = $headerKey.": ".$headerVal;
    990990        }
     
    12051205            case "application/x-www-form-urlencoded":
    12061206                reset($formvars);
    1207                 while(list($key,$val) = each($formvars)) {
     1207                foreach ( $formvars as $key => $val ) {
    12081208                    if (is_array($val) || is_object($val)) {
    1209                         while (list($cur_key, $cur_val) = each($val)) {
     1209                        foreach ( $val as $cur_key => $cur_val ) {
    12101210                            $postdata .= urlencode($key)."[]=".urlencode($cur_val)."&";
    12111211                        }
     
    12191219
    12201220                reset($formvars);
    1221                 while(list($key,$val) = each($formvars)) {
     1221                foreach ( $formvars as $key => $val ) {
    12221222                    if (is_array($val) || is_object($val)) {
    1223                         while (list($cur_key, $cur_val) = each($val)) {
     1223                        foreach ( $val as $cur_key => $cur_val ) {
    12241224                            $postdata .= "--".$this->_mime_boundary."\r\n";
    12251225                            $postdata .= "Content-Disposition: form-data; name=\"$key\[\]\"\r\n\r\n";
     
    12341234
    12351235                reset($formfiles);
    1236                 while (list($field_name, $file_names) = each($formfiles)) {
     1236                foreach ( $formfiles as $field_name => $file_names ) {
    12371237                    settype($file_names, "array");
    1238                     while (list(, $file_name) = each($file_names)) {
     1238                    foreach ( $file_names as $file_name ) {
    12391239                        if (!is_readable($file_name)) continue;
    12401240
Note: See TracChangeset for help on using the changeset viewer.