From 63c152828304a41b4c768e6c8d8bebaab49a94f1 Mon Sep 17 00:00:00 2001 From: Dovid Levine Date: Tue, 29 Oct 2024 11:17:13 +0200 Subject: [PATCH 1/3] fix: use explicit returns in WP_Site_Health_Auto_Updates::test_*() methods. Since these methods are public, `null` is used to represent a passed test for backwards-compatibility with a coreced void. Previous usage of `false` is preserved. --- .../class-wp-site-health-auto-updates.php | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/wp-admin/includes/class-wp-site-health-auto-updates.php b/src/wp-admin/includes/class-wp-site-health-auto-updates.php index 581fc44600c5f..62910e1b35066 100644 --- a/src/wp-admin/includes/class-wp-site-health-auto-updates.php +++ b/src/wp-admin/includes/class-wp-site-health-auto-updates.php @@ -66,7 +66,7 @@ static function ( $test ) { * @param string $constant The name of the constant to check. * @param bool|string|array $value The value that the constant should be, if set, * or an array of acceptable values. - * @return array The test results. + * @return ?array The test results. Null if the test passed. */ public function test_constants( $constant, $value ) { $acceptable_values = (array) $value; @@ -82,6 +82,8 @@ public function test_constants( $constant, $value ) { 'severity' => 'fail', ); } + + return null; } /** @@ -89,7 +91,7 @@ public function test_constants( $constant, $value ) { * * @since 5.2.0 * - * @return array The test results. + * @return ?array The test results. Null if the test passed. */ public function test_wp_version_check_attached() { if ( ( ! is_multisite() || is_main_site() && is_network_admin() ) @@ -104,6 +106,8 @@ public function test_wp_version_check_attached() { 'severity' => 'fail', ); } + + return null; } /** @@ -111,7 +115,7 @@ public function test_wp_version_check_attached() { * * @since 5.2.0 * - * @return array The test results. + * @return ?array The test results. Null if the test passed. */ public function test_filters_automatic_updater_disabled() { /** This filter is documented in wp-admin/includes/class-wp-automatic-updater.php */ @@ -125,6 +129,8 @@ public function test_filters_automatic_updater_disabled() { 'severity' => 'fail', ); } + + return null; } /** @@ -156,7 +162,7 @@ public function test_wp_automatic_updates_disabled() { * * @since 5.2.0 * - * @return array|false The test results. False if the auto-updates failed. + * @return array|false The test results. False if auto-updates didn't previously fail. */ public function test_if_failed_update() { $failed = get_site_option( 'auto_core_update_failed' ); @@ -397,7 +403,7 @@ public function test_all_files_writable() { * * @since 5.2.0 * - * @return array|false The test results. False if it isn't a development version. + * @return array|false|null The test results. False if it isn't a development version. Null if the test passed. */ public function test_accepts_dev_updates() { require ABSPATH . WPINC . '/version.php'; // $wp_version; // x.y.z @@ -428,6 +434,8 @@ public function test_accepts_dev_updates() { 'severity' => 'fail', ); } + + return null; } /** @@ -435,7 +443,7 @@ public function test_accepts_dev_updates() { * * @since 5.2.0 * - * @return array The test results. + * @return ?array The test results. Null if the test passed. */ public function test_accepts_minor_updates() { if ( defined( 'WP_AUTO_UPDATE_CORE' ) && false === WP_AUTO_UPDATE_CORE ) { @@ -460,5 +468,7 @@ public function test_accepts_minor_updates() { 'severity' => 'fail', ); } + + return null; } } From 5513d245e7615373a7044af19df3b7100136ee56 Mon Sep 17 00:00:00 2001 From: Dovid Levine Date: Tue, 29 Oct 2024 15:34:04 +0200 Subject: [PATCH 2/3] chore: Avoid capitalizing `null` type in doc-blocks. --- .../includes/class-wp-site-health-auto-updates.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/wp-admin/includes/class-wp-site-health-auto-updates.php b/src/wp-admin/includes/class-wp-site-health-auto-updates.php index 62910e1b35066..bd782f3382ff3 100644 --- a/src/wp-admin/includes/class-wp-site-health-auto-updates.php +++ b/src/wp-admin/includes/class-wp-site-health-auto-updates.php @@ -66,7 +66,7 @@ static function ( $test ) { * @param string $constant The name of the constant to check. * @param bool|string|array $value The value that the constant should be, if set, * or an array of acceptable values. - * @return ?array The test results. Null if the test passed. + * @return ?array The test results, or null if the test passed. */ public function test_constants( $constant, $value ) { $acceptable_values = (array) $value; @@ -91,7 +91,7 @@ public function test_constants( $constant, $value ) { * * @since 5.2.0 * - * @return ?array The test results. Null if the test passed. + * @return ?array The test results or null if the test passed. */ public function test_wp_version_check_attached() { if ( ( ! is_multisite() || is_main_site() && is_network_admin() ) @@ -115,7 +115,7 @@ public function test_wp_version_check_attached() { * * @since 5.2.0 * - * @return ?array The test results. Null if the test passed. + * @return ?array The test results or null if the test passed. */ public function test_filters_automatic_updater_disabled() { /** This filter is documented in wp-admin/includes/class-wp-automatic-updater.php */ @@ -403,7 +403,7 @@ public function test_all_files_writable() { * * @since 5.2.0 * - * @return array|false|null The test results. False if it isn't a development version. Null if the test passed. + * @return array|false|null The test results. False if it isn't a development version. Returns null if the test passed. */ public function test_accepts_dev_updates() { require ABSPATH . WPINC . '/version.php'; // $wp_version; // x.y.z From 4a6e02f6f311504aef102f0412ad2a3d2be459a3 Mon Sep 17 00:00:00 2001 From: Dovid Levine Date: Tue, 29 Oct 2024 15:44:27 +0200 Subject: [PATCH 3/3] chore: missing commas --- src/wp-admin/includes/class-wp-site-health-auto-updates.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wp-admin/includes/class-wp-site-health-auto-updates.php b/src/wp-admin/includes/class-wp-site-health-auto-updates.php index bd782f3382ff3..f7dd1554e4a6f 100644 --- a/src/wp-admin/includes/class-wp-site-health-auto-updates.php +++ b/src/wp-admin/includes/class-wp-site-health-auto-updates.php @@ -91,7 +91,7 @@ public function test_constants( $constant, $value ) { * * @since 5.2.0 * - * @return ?array The test results or null if the test passed. + * @return ?array The test results, or null if the test passed. */ public function test_wp_version_check_attached() { if ( ( ! is_multisite() || is_main_site() && is_network_admin() ) @@ -115,7 +115,7 @@ public function test_wp_version_check_attached() { * * @since 5.2.0 * - * @return ?array The test results or null if the test passed. + * @return ?array The test results, or null if the test passed. */ public function test_filters_automatic_updater_disabled() { /** This filter is documented in wp-admin/includes/class-wp-automatic-updater.php */