Make WordPress Core

Changeset 51784


Ignore:
Timestamp:
09/09/2021 02:47:10 PM (3 years ago)
Author:
hellofromTonya
Message:

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

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], [21037], [21053], [21354], [38829], [51298].

Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.

Location:
trunk/src/wp-includes/customize
Files:
3 edited

Legend:

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

    r51298 r51784  
    2121     * @since 3.4.0
    2222     *
    23      * @param mixed $value
     23     * @param mixed $value The value to update. Not used.
    2424     */
    2525    public function update( $value ) {
  • trunk/src/wp-includes/customize/class-wp-customize-custom-css-setting.php

    r48782 r51784  
    174174     *
    175175     * @since 4.7.0
    176      *
    177      * @param string $css The input value.
     176     * @since 5.9.0 Renamed `$css` to `$value` for PHP 8 named parameter support.
     177     *
     178     * @param string $value CSS to update.
    178179     * @return int|false The post ID or false if the value could not be saved.
    179180     */
    180     public function update( $css ) {
     181    public function update( $value ) {
     182        // Restores the more descriptive, specific name for use within this method.
     183        $css = $value;
     184
    181185        if ( empty( $css ) ) {
    182186            $css = '';
  • trunk/src/wp-includes/customize/class-wp-customize-header-image-setting.php

    r51298 r51784  
    2525     * @global Custom_Image_Header $custom_image_header
    2626     *
    27      * @param mixed $value
     27     * @param mixed $value The value to update.
    2828     */
    2929    public function update( $value ) {
Note: See TracChangeset for help on using the changeset viewer.