Make WordPress Core

Changeset 53242


Ignore:
Timestamp:
04/22/2022 10:29:45 AM (2 years ago)
Author:
SergeyBiryukov
Message:

Code Modernization: Rename parameters that use reserved keywords in wp-includes/class-wp-customize-manager.php.

While using reserved PHP keywords as parameter name labels is allowed, in the context of function calls using named parameters in PHP 8.0+, this will easily lead to confusion. To avoid that, it is recommended not to use reserved keywords as function parameter names.

This commit:

  • Renames the $default parameter to $default_value in WP_Customize_Manager::post_value().
  • Renames the $return parameter to $callback in WP_Customize_Manager::remove_preview_signature().

Follow-up to [52946], [52996], [52997], [52998], [53003], [53014], [53029], [53039], [53116], [53117], [53137], [53174], [53184], [53185], [53192], [53193], [53198], [53203], [53207], [53215], [53216], [53220], [53230], [53232], [53236], [53239], [53240].

Props jrf, aristath, poena, justinahinon, SergeyBiryukov.
See #55327.

File:
1 edited

Legend:

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

    r53060 r53242  
    18071807     *
    18081808     * @since 3.4.0
    1809      * @since 4.1.1 Introduced the `$default` parameter.
    1810      * @since 4.6.0 `$default` is now returned early when the setting post value is invalid.
     1809     * @since 4.1.1 Introduced the `$default_value` parameter.
     1810     * @since 4.6.0 `$default_value` is now returned early when the setting post value is invalid.
    18111811     *
    18121812     * @see WP_REST_Server::dispatch()
     
    18141814     * @see WP_REST_Request::has_valid_params()
    18151815     *
    1816      * @param WP_Customize_Setting $setting A WP_Customize_Setting derived object.
    1817      * @param mixed                $default Value returned $setting has no post value (added in 4.2.0)
    1818      *                                      or the post value is invalid (added in 4.6.0).
    1819      * @return string|mixed Sanitized value or the $default provided.
    1820      */
    1821     public function post_value( $setting, $default = null ) {
     1816     * @param WP_Customize_Setting $setting       A WP_Customize_Setting derived object.
     1817     * @param mixed                $default_value Value returned if `$setting` has no post value (added in 4.2.0)
     1818     *                                            or the post value is invalid (added in 4.6.0).
     1819     * @return string|mixed Sanitized value or the `$default_value` provided.
     1820     */
     1821    public function post_value( $setting, $default_value = null ) {
    18221822        $post_values = $this->unsanitized_post_values();
    18231823        if ( ! array_key_exists( $setting->id, $post_values ) ) {
    1824             return $default;
    1825         }
     1824            return $default_value;
     1825        }
     1826
    18261827        $value = $post_values[ $setting->id ];
    18271828        $valid = $setting->validate( $value );
    18281829        if ( is_wp_error( $valid ) ) {
    1829             return $default;
    1830         }
     1830            return $default_value;
     1831        }
     1832
    18311833        $value = $setting->sanitize( $value );
    18321834        if ( is_null( $value ) || is_wp_error( $value ) ) {
    1833             return $default;
    1834         }
     1835            return $default_value;
     1836        }
     1837
    18351838        return $value;
    18361839    }
     
    22332236     * @deprecated 4.7.0
    22342237     *
    2235      * @param mixed $return Value passed through for {@see 'wp_die_handler'} filter.
     2238     * @param mixed $callback Value passed through for {@see 'wp_die_handler'} filter.
    22362239     * @return mixed Value passed through for {@see 'wp_die_handler'} filter.
    22372240     */
    2238     public function remove_preview_signature( $return = null ) {
     2241    public function remove_preview_signature( $callback = null ) {
    22392242        _deprecated_function( __METHOD__, '4.7.0' );
    22402243
    2241         return $return;
     2244        return $callback;
    22422245    }
    22432246
Note: See TracChangeset for help on using the changeset viewer.