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


git-svn-id: http://core.svn.wordpress.org/trunk@52831 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2022-04-22 10:31:15 +00:00
parent 2b25ad7c7b
commit 2bc70fc658
2 changed files with 17 additions and 14 deletions

View File

@ -1806,32 +1806,35 @@ final class WP_Customize_Manager {
* from the current changeset post and from the incoming post data.
*
* @since 3.4.0
* @since 4.1.1 Introduced the `$default` parameter.
* @since 4.6.0 `$default` is now returned early when the setting post value is invalid.
* @since 4.1.1 Introduced the `$default_value` parameter.
* @since 4.6.0 `$default_value` is now returned early when the setting post value is invalid.
*
* @see WP_REST_Server::dispatch()
* @see WP_REST_Request::sanitize_params()
* @see WP_REST_Request::has_valid_params()
*
* @param WP_Customize_Setting $setting A WP_Customize_Setting derived object.
* @param mixed $default Value returned $setting has no post value (added in 4.2.0)
* or the post value is invalid (added in 4.6.0).
* @return string|mixed Sanitized value or the $default provided.
* @param WP_Customize_Setting $setting A WP_Customize_Setting derived object.
* @param mixed $default_value Value returned if `$setting` has no post value (added in 4.2.0)
* or the post value is invalid (added in 4.6.0).
* @return string|mixed Sanitized value or the `$default_value` provided.
*/
public function post_value( $setting, $default = null ) {
public function post_value( $setting, $default_value = null ) {
$post_values = $this->unsanitized_post_values();
if ( ! array_key_exists( $setting->id, $post_values ) ) {
return $default;
return $default_value;
}
$value = $post_values[ $setting->id ];
$valid = $setting->validate( $value );
if ( is_wp_error( $valid ) ) {
return $default;
return $default_value;
}
$value = $setting->sanitize( $value );
if ( is_null( $value ) || is_wp_error( $value ) ) {
return $default;
return $default_value;
}
return $value;
}
@ -2232,13 +2235,13 @@ final class WP_Customize_Manager {
* @since 3.4.0
* @deprecated 4.7.0
*
* @param mixed $return Value passed through for {@see 'wp_die_handler'} filter.
* @param mixed $callback Value passed through for {@see 'wp_die_handler'} filter.
* @return mixed Value passed through for {@see 'wp_die_handler'} filter.
*/
public function remove_preview_signature( $return = null ) {
public function remove_preview_signature( $callback = null ) {
_deprecated_function( __METHOD__, '4.7.0' );
return $return;
return $callback;
}
/**

View File

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