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.
Built from https://develop.svn.wordpress.org/trunk@53246


git-svn-id: http://core.svn.wordpress.org/trunk@52835 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2022-04-24 00:28:08 +00:00
parent ccde5b8bd3
commit 8ca3012db9
2 changed files with 15 additions and 15 deletions

View File

@ -547,11 +547,11 @@ class WP_Customize_Setting {
* *
* @since 3.4.0 * @since 3.4.0
* *
* @param mixed $default A default value which is used as a fallback. Default null. * @param mixed $default_value A default value which is used as a fallback. Default null.
* @return mixed The default value on failure, otherwise the sanitized and validated value. * @return mixed The default value on failure, otherwise the sanitized and validated value.
*/ */
final public function post_value( $default = null ) { final public function post_value( $default_value = null ) {
return $this->manager->post_value( $this, $default ); return $this->manager->post_value( $this, $default_value );
} }
/** /**
@ -621,22 +621,22 @@ class WP_Customize_Setting {
* *
* @since 4.4.0 * @since 4.4.0
* *
* @param mixed $default Value to return if root does not exist. * @param mixed $default_value Value to return if root does not exist.
* @return mixed * @return mixed
*/ */
protected function get_root_value( $default = null ) { protected function get_root_value( $default_value = null ) {
$id_base = $this->id_data['base']; $id_base = $this->id_data['base'];
if ( 'option' === $this->type ) { if ( 'option' === $this->type ) {
return get_option( $id_base, $default ); return get_option( $id_base, $default_value );
} elseif ( 'theme_mod' === $this->type ) { } elseif ( 'theme_mod' === $this->type ) {
return get_theme_mod( $id_base, $default ); return get_theme_mod( $id_base, $default_value );
} else { } else {
/* /*
* Any WP_Customize_Setting subclass implementing aggregate multidimensional * Any WP_Customize_Setting subclass implementing aggregate multidimensional
* will need to override this method to obtain the data from the appropriate * will need to override this method to obtain the data from the appropriate
* location. * location.
*/ */
return $default; return $default_value;
} }
} }
@ -761,8 +761,8 @@ class WP_Customize_Setting {
* @since 3.4.0 * @since 3.4.0
* @since 4.6.0 Added the `$this` setting instance as the second parameter. * @since 4.6.0 Added the `$this` setting instance as the second parameter.
* *
* @param mixed $default The setting default value. Default empty. * @param mixed $default_value The setting default value. Default empty.
* @param WP_Customize_Setting $setting The setting instance. * @param WP_Customize_Setting $setting The setting instance.
*/ */
$value = apply_filters( "customize_value_{$id_base}", $value, $this ); $value = apply_filters( "customize_value_{$id_base}", $value, $this );
} elseif ( $this->is_multidimensional_aggregated ) { } elseif ( $this->is_multidimensional_aggregated ) {
@ -930,16 +930,16 @@ class WP_Customize_Setting {
* *
* @param array $root * @param array $root
* @param array $keys * @param array $keys
* @param mixed $default A default value which is used as a fallback. Default null. * @param mixed $default_value A default value which is used as a fallback. Default null.
* @return mixed The requested value or the default value. * @return mixed The requested value or the default value.
*/ */
final protected function multidimensional_get( $root, $keys, $default = null ) { final protected function multidimensional_get( $root, $keys, $default_value = null ) {
if ( empty( $keys ) ) { // If there are no keys, test the root. if ( empty( $keys ) ) { // If there are no keys, test the root.
return isset( $root ) ? $root : $default; return isset( $root ) ? $root : $default_value;
} }
$result = $this->multidimensional( $root, $keys ); $result = $this->multidimensional( $root, $keys );
return isset( $result ) ? $result['node'][ $result['key'] ] : $default; return isset( $result ) ? $result['node'][ $result['key'] ] : $default_value;
} }
/** /**

View File

@ -16,7 +16,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '6.0-beta2-53245'; $wp_version = '6.0-beta2-53246';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.