Code Modernization: Fix parameter name mismatches for parent/child classes in `WP_Customize_Setting::sanitize()`.

In each child class: renames the parameter to match the parent's method signature.

Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.

Changes for readability:

- `@since` clearly specifies the original parameter name and its new name as well as why the change happened.

- In methods longer than a single line, the generic parameter is reassigned to the original parameter restoring it for context for use within the method. An inline comment is added to explain why this reassignment is made.

Follow-up to [19995], [32806].

Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51783


git-svn-id: http://core.svn.wordpress.org/trunk@51390 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
hellofromTonya 2021-09-09 14:32:57 +00:00
parent 5887edee86
commit 071c322bf2
4 changed files with 9 additions and 5 deletions

View File

@ -559,7 +559,7 @@ class WP_Customize_Setting {
*
* @since 3.4.0
*
* @param string|array $value The value to sanitize.
* @param string|array $value The value to sanitize.
* @return string|array|null|WP_Error Sanitized value, or `null`/`WP_Error` if invalid.
*/
public function sanitize( $value ) {

View File

@ -653,12 +653,16 @@ class WP_Customize_Nav_Menu_Item_Setting extends WP_Customize_Setting {
* we remove that in this override.
*
* @since 4.3.0
* @since 5.9.0 Renamed `$menu_item_value` to `$value` for PHP 8 named parameter support.
*
* @param array $menu_item_value The value to sanitize.
* @param array $value The menu item value to sanitize.
* @return array|false|null|WP_Error Null or WP_Error if an input isn't valid. False if it is marked for deletion.
* Otherwise the sanitized value.
*/
public function sanitize( $menu_item_value ) {
public function sanitize( $value ) {
// Restores the more descriptive, specific name for use within this method.
$menu_item_value = $value;
// Menu is marked for deletion.
if ( false === $menu_item_value ) {
return $menu_item_value;

View File

@ -407,7 +407,7 @@ class WP_Customize_Nav_Menu_Setting extends WP_Customize_Setting {
*
* @since 4.3.0
*
* @param array $value The value to sanitize.
* @param array $value The menu value to sanitize.
* @return array|false|null Null if an input isn't valid. False if it is marked for deletion.
* Otherwise the sanitized value.
*/

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.9-alpha-51782';
$wp_version = '5.9-alpha-51783';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.