Make WordPress Core

Changeset 47902


Ignore:
Timestamp:
06/03/2020 05:38:56 PM (4 years ago)
Author:
desrosj
Message:

General: Continuing to work towards a passing PHP Compatibility scan.

This is a final pass to fix PHP compatibiilty issues in the codebase with code changes or adding phpcs:ignore comments.

With this change, all PHP compatibility warnings and errors without specific tickets have been addressed (see #49810 and #41750).

Props desrosj, johnbillion, jrf.
See #49922.

Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/phpcompat.xml.dist

    r47735 r47902  
    7575
    7676    <!-- Whitelist the WP DB Class for use of `mysql_` extension in PHP < 7.0. -->
    77     <rule ref="PHPCompatibility.Extensions.RemovedExtensions">
     77    <rule ref="PHPCompatibility.Extensions.RemovedExtensions.mysql_DeprecatedRemoved">
    7878        <exclude-pattern>/src/wp-includes/wp-db\.php</exclude-pattern>
    7979    </rule>
  • trunk/src/wp-admin/includes/class-ftp.php

    r47198 r47902  
    900900if ( ! $mod_sockets && function_exists( 'dl' ) && is_callable( 'dl' ) ) {
    901901    $prefix = ( PHP_SHLIB_SUFFIX == 'dll' ) ? 'php_' : '';
    902     @dl( $prefix . 'sockets.' . PHP_SHLIB_SUFFIX );
     902    @dl( $prefix . 'sockets.' . PHP_SHLIB_SUFFIX ); // phpcs:ignore PHPCompatibility.FunctionUse.RemovedFunctions.dlDeprecated
    903903    $mod_sockets = extension_loaded( 'sockets' );
    904904}
  • trunk/src/wp-includes/ID3/module.audio-video.quicktime.php

    r47601 r47902  
    115115                $ISO6709parsed = array('latitude'=>false, 'longitude'=>false, 'altitude'=>false);
    116116                if (preg_match('#^([\\+\\-])([0-9]{2}|[0-9]{4}|[0-9]{6})(\\.[0-9]+)?([\\+\\-])([0-9]{3}|[0-9]{5}|[0-9]{7})(\\.[0-9]+)?(([\\+\\-])([0-9]{3}|[0-9]{5}|[0-9]{7})(\\.[0-9]+)?)?/$#', $ISO6709string, $matches)) {
    117                     @list($dummy, $lat_sign, $lat_deg, $lat_deg_dec, $lon_sign, $lon_deg, $lon_deg_dec, $dummy, $alt_sign, $alt_deg, $alt_deg_dec) = $matches;
     117                    @list($dummy, $lat_sign, $lat_deg, $lat_deg_dec, $lon_sign, $lon_deg, $lon_deg_dec, $dummy, $alt_sign, $alt_deg, $alt_deg_dec) = $matches; // phpcs:ignore PHPCompatibility.Lists.AssignmentOrder.Affected
    118118
    119119                    if (strlen($lat_deg) == 2) {        // [+-]DD.D
  • trunk/src/wp-includes/capabilities.php

    r47808 r47902  
    291291        case 'delete_user_meta':
    292292        case 'add_user_meta':
    293             list( $_, $object_type, $_ ) = explode( '_', $cap );
    294             $object_id                   = (int) $args[0];
     293            $object_type = explode( '_', $cap )[1];
     294            $object_id   = (int) $args[0];
    295295
    296296            $object_subtype = get_object_subtype( $object_type, $object_id );
  • trunk/src/wp-includes/class-requests.php

    r46661 r47902  
    188188        // Don't search for a transport if it's already been done for these $capabilities
    189189        if (isset(self::$transport[$cap_string]) && self::$transport[$cap_string] !== null) {
    190             return new self::$transport[$cap_string]();
     190            $class = self::$transport[$cap_string];
     191            return new $class();
    191192        }
    192193        // @codeCoverageIgnoreEnd
     
    215216        }
    216217
    217         return new self::$transport[$cap_string]();
     218        $class = self::$transport[$cap_string];
     219        return new $class();
    218220    }
    219221
  • trunk/src/wp-includes/class-simplepie.php

    r47733 r47902  
    31663166
    31673167        $class = get_class($this);
    3168         $trace = debug_backtrace();
     3168        $trace = debug_backtrace(); // phpcs:ignore PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.NeedsInspection
    31693169        $file = $trace[0]['file'];
    31703170        $line = $trace[0]['line'];
  • trunk/src/wp-includes/cron.php

    r47754 r47902  
    403403    if ( ! is_array( $args ) ) {
    404404        _deprecated_argument( __FUNCTION__, '3.0.0', __( 'This argument has changed to an array to match the behavior of the other cron functions.' ) );
    405         $args = array_slice( func_get_args(), 1 );
     405        $args = array_slice( func_get_args(), 1 ); // phpcs:ignore PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.NeedsInspection
    406406    }
    407407
  • trunk/src/wp-includes/functions.php

    r47838 r47902  
    66286628
    66296629    if ( is_null( $overloaded ) ) {
    6630         $overloaded = function_exists( 'mb_internal_encoding' ) && ( ini_get( 'mbstring.func_overload' ) & 2 );
     6630        $overloaded = function_exists( 'mb_internal_encoding' ) && ( ini_get( 'mbstring.func_overload' ) & 2 ); // phpcs:ignore PHPCompatibility.IniDirectives.RemovedIniDirectives.mbstring_func_overloadDeprecated
    66316631    }
    66326632
  • trunk/src/wp-includes/plugin.php

    r47550 r47902  
    232232    if ( isset( $wp_filter['all'] ) ) {
    233233        $wp_current_filter[] = $tag;
    234         $all_args            = func_get_args();
     234        $all_args            = func_get_args(); // phpcs:ignore PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.NeedsInspection
    235235        _wp_call_all_hook( $all_args );
    236236    }
     
    454454    if ( isset( $wp_filter['all'] ) ) {
    455455        $wp_current_filter[] = $tag;
    456         $all_args            = func_get_args();
     456        $all_args            = func_get_args(); // phpcs:ignore PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.NeedsInspection
    457457        _wp_call_all_hook( $all_args );
    458458    }
     
    527527    if ( isset( $wp_filter['all'] ) ) {
    528528        $wp_current_filter[] = $tag;
    529         $all_args            = func_get_args();
     529        $all_args            = func_get_args(); // phpcs:ignore PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.NeedsInspection
    530530        _wp_call_all_hook( $all_args );
    531531    }
  • trunk/src/wp-includes/pomo/streams.php

    r47808 r47902  
    1919         */
    2020        function __construct() {
    21             $this->is_overloaded = ( ( ini_get( 'mbstring.func_overload' ) & 2 ) != 0 ) && function_exists( 'mb_substr' );
     21            $this->is_overloaded = ( ( ini_get( 'mbstring.func_overload' ) & 2 ) != 0 ) && function_exists( 'mb_substr' ); // phpcs:ignore PHPCompatibility.IniDirectives.RemovedIniDirectives.mbstring_func_overloadDeprecated
    2222            $this->_pos          = 0;
    2323        }
  • trunk/src/wp-includes/rss.php

    r42201 r47902  
    386386
    387387    function error( $errormsg, $lvl = E_USER_WARNING ) {
    388         // append PHP's error message if track_errors enabled
    389         if ( isset($php_errormsg) ) {
    390             $errormsg .= " ($php_errormsg)";
    391         }
    392388        if ( MAGPIE_DEBUG ) {
    393389            trigger_error( $errormsg, $lvl);
     
    822818\*=======================================================================*/
    823819    function error ($errormsg, $lvl=E_USER_WARNING) {
    824         // append PHP's error message if track_errors enabled
    825         if ( isset($php_errormsg) ) {
    826             $errormsg .= " ($php_errormsg)";
    827         }
    828820        $this->ERROR = $errormsg;
    829821        if ( MAGPIE_DEBUG ) {
Note: See TracChangeset for help on using the changeset viewer.