Make WordPress Core

Changeset 61670


Ignore:
Timestamp:
02/18/2026 04:38:42 AM (5 weeks ago)
Author:
westonruter
Message:

Customize: Ensure WP_Customize_Setting::update() and subclass overrides return consistent types.

This addresses PHPStan type check issues.

Developed in https://github.com/WordPress/wordpress-develop/pull/10952

Props westonruter, peterwilsoncc, justlevine.
See #64238, #61175.

Location:
trunk/src/wp-includes
Files:
6 edited

Legend:

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

    r61433 r61670  
    709709            do_action( "customize_update_{$this->type}", $value, $this );
    710710
    711             return has_action( "customize_update_{$this->type}" );
     711            return (bool) has_action( "customize_update_{$this->type}" );
    712712        }
    713713    }
  • trunk/src/wp-includes/customize/class-wp-customize-background-image-setting.php

    r53411 r61670  
    2727    /**
    2828     * @since 3.4.0
     29     * @since 7.0.0 Return type updated from void to true for compatibility with base class.
    2930     *
    3031     * @param mixed $value The value to update. Not used.
     32     * @return true Always returns true.
    3133     */
    3234    public function update( $value ) {
    3335        remove_theme_mod( 'background_image_thumb' );
     36        return true;
    3437    }
    3538}
  • trunk/src/wp-includes/customize/class-wp-customize-filter-setting.php

    r41162 r61670  
    2323     *
    2424     * @since 3.4.0
     25     * @since 7.0.0 Return type updated from void to true for compatibility with base class.
    2526     *
    2627     * @param mixed $value The value to update.
     28     * @return true Always returns true.
    2729     */
    28     public function update( $value ) {}
     30    public function update( $value ) {
     31        return true;
     32    }
    2933}
  • trunk/src/wp-includes/customize/class-wp-customize-header-image-setting.php

    r61433 r61670  
    2929    /**
    3030     * @since 3.4.0
     31     * @since 7.0.0 Return type updated from void to true for compatibility with base class.
    3132     *
    3233     * @global Custom_Image_Header $custom_image_header
    3334     *
    3435     * @param mixed $value The value to update.
     36     * @return true Always returns true.
    3537     */
    3638    public function update( $value ) {
     
    5961            $custom_image_header->set_header_image( $value );
    6062        }
     63        return true;
    6164    }
    6265}
  • trunk/src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php

    r61433 r61670  
    760760     *
    761761     * @since 4.3.0
     762     * @since 7.0.0 Return type updated from null|void to bool for compatibility with base class.
    762763     *
    763764     * @see wp_update_nav_menu_item()
     
    766767     *                           entirely. See WP_Customize_Nav_Menu_Item_Setting::$default for what the value
    767768     *                           should consist of.
    768      * @return null|void
     769     * @return bool Whether updated.
    769770     */
    770771    protected function update( $value ) {
    771772        if ( $this->is_updated ) {
    772             return;
     773            return ( 'error' !== $this->update_status );
    773774        }
    774775
     
    807808                    $this->update_status = 'error';
    808809                    $this->update_error  = new WP_Error( 'unexpected_nav_menu_setting' );
    809                     return;
     810                    return false;
    810811                }
    811812
     
    813814                    $this->update_status = 'error';
    814815                    $this->update_error  = new WP_Error( 'nav_menu_setting_failure' );
    815                     return;
     816                    return false;
    816817                }
    817818
     
    819820                    $this->update_status = 'error';
    820821                    $this->update_error  = new WP_Error( 'unexpected_previous_term_id' );
    821                     return;
     822                    return false;
    822823                }
    823824
     
    833834                    $this->update_status = 'error';
    834835                    $this->update_error  = new WP_Error( 'unexpected_nav_menu_item_setting' );
    835                     return;
     836                    return false;
    836837                }
    837838
     
    839840                    $this->update_status = 'error';
    840841                    $this->update_error  = new WP_Error( 'nav_menu_item_setting_failure' );
    841                     return;
     842                    return false;
    842843                }
    843844
     
    845846                    $this->update_status = 'error';
    846847                    $this->update_error  = new WP_Error( 'unexpected_previous_post_id' );
    847                     return;
     848                    return false;
    848849                }
    849850
     
    887888            }
    888889        }
     890
     891        return ( 'error' !== $this->update_status );
    889892    }
    890893
  • trunk/src/wp-includes/customize/class-wp-customize-nav-menu-setting.php

    r52597 r61670  
    467467     *
    468468     * @since 4.3.0
     469     * @since 7.0.0 Return type updated from null|void to bool for compatibility with base class.
    469470     *
    470471     * @see wp_update_nav_menu_object()
     
    479480     *     @type bool   $auto_add    Whether pages will auto_add to this menu. Default false.
    480481     * }
    481      * @return null|void
     482     * @return bool Whether updated.
    482483     */
    483484    protected function update( $value ) {
    484485        if ( $this->is_updated ) {
    485             return;
     486            return ( 'error' !== $this->update_status );
    486487        }
    487488
     
    583584            }
    584585        }
     586
     587        return ( 'error' !== $this->update_status );
    585588    }
    586589
Note: See TracChangeset for help on using the changeset viewer.