Make WordPress Core

Changeset 59340


Ignore:
Timestamp:
11/04/2024 03:23:26 PM (3 months ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Use explicit returns in WP_Site_Health_Auto_Updates::test_*().

This commit corrects several instances of test_*() methods potentially returning void instead of their documented return types.

Since these methods are public, null is used to represent a passed test for backward compatibility with the coercion of the previously-returned void. Previous usage of false is preserved.

Includes updating some @return tags for clarity.

Follow-up to [44986], [46276], [49927].

Props justlevine, apermo, SergeyBiryukov.
See #52217.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-site-health-auto-updates.php

    r58921 r59340  
    6767     * @param bool|string|array $value The value that the constant should be, if set,
    6868     *                                 or an array of acceptable values.
    69      * @return array The test results.
     69     * @return array|null The test results if there are any constants set incorrectly,
     70     *                    or null if the test passed.
    7071     */
    7172    public function test_constants( $constant, $value ) {
     
    8384            );
    8485        }
     86
     87        return null;
    8588    }
    8689
     
    9093     * @since 5.2.0
    9194     *
    92      * @return array The test results.
     95     * @return array|null The test results if wp_version_check() is disabled,
     96     *                    or null if the test passed.
    9397     */
    9498    public function test_wp_version_check_attached() {
     
    105109            );
    106110        }
     111
     112        return null;
    107113    }
    108114
     
    112118     * @since 5.2.0
    113119     *
    114      * @return array The test results.
     120     * @return array|null The test results if the {@see 'automatic_updater_disabled'} filter is set,
     121     *                    or null if the test passed.
    115122     */
    116123    public function test_filters_automatic_updater_disabled() {
     
    126133            );
    127134        }
     135
     136        return null;
    128137    }
    129138
     
    133142     * @since 5.3.0
    134143     *
    135      * @return array|false The test results. False if auto-updates are enabled.
     144     * @return array|false The test results if auto-updates are disabled, false otherwise.
    136145     */
    137146    public function test_wp_automatic_updates_disabled() {
     
    157166     * @since 5.2.0
    158167     *
    159      * @return array|false The test results. False if the auto-updates failed.
     168     * @return array|false The test results if auto-updates previously failed, false otherwise.
    160169     */
    161170    public function test_if_failed_update() {
     
    313322     * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
    314323     *
    315      * @return array|false The test results. False if they're not writeable.
     324     * @return array|false The test results if at least some of WordPress core files are writeable,
     325     *                     or if a list of the checksums could not be retrieved from WordPress.org.
     326     *                     False if the core files are not writeable.
    316327     */
    317328    public function test_all_files_writable() {
     
    398409     * @since 5.2.0
    399410     *
    400      * @return array|false The test results. False if it isn't a development version.
     411     * @return array|false|null The test results if development updates are blocked.
     412     *                          False if it isn't a development version. Null if the test passed.
    401413     */
    402414    public function test_accepts_dev_updates() {
     
    429441            );
    430442        }
     443
     444        return null;
    431445    }
    432446
     
    436450     * @since 5.2.0
    437451     *
    438      * @return array The test results.
     452     * @return array|null The test results if minor updates are blocked,
     453     *                    or null if the test passed.
    439454     */
    440455    public function test_accepts_minor_updates() {
     
    461476            );
    462477        }
     478
     479        return null;
    463480    }
    464481}
Note: See TracChangeset for help on using the changeset viewer.