Make WordPress Core

Changeset 53246


Ignore:
Timestamp:
04/24/2022 12:26:03 AM (2 years ago)
Author:
SergeyBiryukov
Message:

Code Modernization: Rename parameters that use reserved keywords in swp-includes/class-wp-customize-setting.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_Setting class methods.

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], [53242], [53243], [53245].

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

File:
1 edited

Legend:

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

    r51919 r53246  
    548548     * @since 3.4.0
    549549     *
    550      * @param mixed $default A default value which is used as a fallback. Default null.
     550     * @param mixed $default_value A default value which is used as a fallback. Default null.
    551551     * @return mixed The default value on failure, otherwise the sanitized and validated value.
    552552     */
    553     final public function post_value( $default = null ) {
    554         return $this->manager->post_value( $this, $default );
     553    final public function post_value( $default_value = null ) {
     554        return $this->manager->post_value( $this, $default_value );
    555555    }
    556556
     
    622622     * @since 4.4.0
    623623     *
    624      * @param mixed $default Value to return if root does not exist.
     624     * @param mixed $default_value Value to return if root does not exist.
    625625     * @return mixed
    626626     */
    627     protected function get_root_value( $default = null ) {
     627    protected function get_root_value( $default_value = null ) {
    628628        $id_base = $this->id_data['base'];
    629629        if ( 'option' === $this->type ) {
    630             return get_option( $id_base, $default );
     630            return get_option( $id_base, $default_value );
    631631        } elseif ( 'theme_mod' === $this->type ) {
    632             return get_theme_mod( $id_base, $default );
     632            return get_theme_mod( $id_base, $default_value );
    633633        } else {
    634634            /*
     
    637637             * location.
    638638             */
    639             return $default;
     639            return $default_value;
    640640        }
    641641    }
     
    762762             * @since 4.6.0 Added the `$this` setting instance as the second parameter.
    763763             *
    764              * @param mixed                $default The setting default value. Default empty.
    765              * @param WP_Customize_Setting $setting The setting instance.
     764             * @param mixed                $default_value The setting default value. Default empty.
     765             * @param WP_Customize_Setting $setting       The setting instance.
    766766             */
    767767            $value = apply_filters( "customize_value_{$id_base}", $value, $this );
     
    931931     * @param array $root
    932932     * @param array $keys
    933      * @param mixed $default A default value which is used as a fallback. Default null.
     933     * @param mixed $default_value A default value which is used as a fallback. Default null.
    934934     * @return mixed The requested value or the default value.
    935935     */
    936     final protected function multidimensional_get( $root, $keys, $default = null ) {
     936    final protected function multidimensional_get( $root, $keys, $default_value = null ) {
    937937        if ( empty( $keys ) ) { // If there are no keys, test the root.
    938             return isset( $root ) ? $root : $default;
     938            return isset( $root ) ? $root : $default_value;
    939939        }
    940940
    941941        $result = $this->multidimensional( $root, $keys );
    942         return isset( $result ) ? $result['node'][ $result['key'] ] : $default;
     942        return isset( $result ) ? $result['node'][ $result['key'] ] : $default_value;
    943943    }
    944944
Note: See TracChangeset for help on using the changeset viewer.