Skip to content

Commit 16de833

Browse files
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. git-svn-id: https://develop.svn.wordpress.org/trunk@59340 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 80a4604 commit 16de833

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

src/wp-admin/includes/class-wp-site-health-auto-updates.php

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ static function ( $test ) {
6666
* @param string $constant The name of the constant to check.
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 ) {
7273
$acceptable_values = (array) $value;
@@ -82,14 +83,17 @@ public function test_constants( $constant, $value ) {
8283
'severity' => 'fail',
8384
);
8485
}
86+
87+
return null;
8588
}
8689

8790
/**
8891
* Checks if updates are intercepted by a filter.
8992
*
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() {
9599
if ( ( ! is_multisite() || is_main_site() && is_network_admin() )
@@ -104,14 +108,17 @@ public function test_wp_version_check_attached() {
104108
'severity' => 'fail',
105109
);
106110
}
111+
112+
return null;
107113
}
108114

109115
/**
110116
* Checks if automatic updates are disabled by a filter.
111117
*
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() {
117124
/** This filter is documented in wp-admin/includes/class-wp-automatic-updater.php */
@@ -125,14 +132,16 @@ public function test_filters_automatic_updater_disabled() {
125132
'severity' => 'fail',
126133
);
127134
}
135+
136+
return null;
128137
}
129138

130139
/**
131140
* Checks if automatic updates are disabled.
132141
*
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() {
138147
if ( ! class_exists( 'WP_Automatic_Updater' ) ) {
@@ -156,7 +165,7 @@ public function test_wp_automatic_updates_disabled() {
156165
*
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() {
162171
$failed = get_site_option( 'auto_core_update_failed' );
@@ -312,7 +321,9 @@ public function test_check_wp_filesystem_method() {
312321
*
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() {
318329
global $wp_filesystem;
@@ -397,7 +408,8 @@ public function test_all_files_writable() {
397408
*
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() {
403415
require ABSPATH . WPINC . '/version.php'; // $wp_version; // x.y.z
@@ -428,14 +440,17 @@ public function test_accepts_dev_updates() {
428440
'severity' => 'fail',
429441
);
430442
}
443+
444+
return null;
431445
}
432446

433447
/**
434448
* Checks if the site supports automatic minor updates.
435449
*
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() {
441456
if ( defined( 'WP_AUTO_UPDATE_CORE' ) && false === WP_AUTO_UPDATE_CORE ) {
@@ -460,5 +475,7 @@ public function test_accepts_minor_updates() {
460475
'severity' => 'fail',
461476
);
462477
}
478+
479+
return null;
463480
}
464481
}

0 commit comments

Comments
 (0)