Skip to content

Commit 45a4e0f

Browse files
committed
Docs: Add descriptions and improved typing to @return tags in various admin and includes files.
Developed in WordPress#10863 Props huzaifaalmesbah, westonruter, noruzzaman, mukesh27. See #64224. git-svn-id: https://develop.svn.wordpress.org/trunk@61594 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 8451b29 commit 45a4e0f

10 files changed

Lines changed: 61 additions & 59 deletions

src/wp-admin/includes/class-wp-debug-data.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ static function ( $section ) {
142142
*
143143
* @since 6.7.0
144144
*
145-
* @return array
145+
* @return array<string, string|array> The debug data for the Info screen.
146146
*/
147147
private static function get_wp_core(): array {
148148
// Save few function calls.
@@ -305,7 +305,7 @@ private static function get_wp_core(): array {
305305
*
306306
* @since 6.7.0
307307
*
308-
* @return array
308+
* @return array<string, string|bool|array> The drop-ins debug data.
309309
*/
310310
private static function get_wp_dropins(): array {
311311
// Get a list of all drop-in replacements.
@@ -340,7 +340,7 @@ private static function get_wp_dropins(): array {
340340
*
341341
* @since 6.7.0
342342
*
343-
* @return array
343+
* @return array<string, string|array> The server-related debug data.
344344
*/
345345
private static function get_wp_server(): array {
346346
// Populate the server debug fields.
@@ -561,7 +561,7 @@ private static function get_wp_server(): array {
561561
* @since 6.7.0
562562
*
563563
* @throws ImagickException
564-
* @return array
564+
* @return array<string, string|array> The media handling debug data.
565565
*/
566566
private static function get_wp_media(): array {
567567
// Spare few function calls.
@@ -773,7 +773,7 @@ private static function get_wp_media(): array {
773773
*
774774
* @since 6.7.0
775775
*
776-
* @return array
776+
* @return array<string, string|bool|array> The must-use plugins debug data.
777777
*/
778778
private static function get_wp_mu_plugins(): array {
779779
// List must use plugins if there are any.
@@ -904,7 +904,7 @@ private static function get_wp_paths_sizes(): ?array {
904904
*
905905
* @since 6.7.0
906906
*
907-
* @return array
907+
* @return array<string, string|bool|array> The active plugins debug data.
908908
*/
909909
private static function get_wp_plugins_active(): array {
910910
return array(
@@ -919,7 +919,7 @@ private static function get_wp_plugins_active(): array {
919919
*
920920
* @since 6.7.0
921921
*
922-
* @return array
922+
* @return array<string, string|bool|array> The inactive plugins debug data.
923923
*/
924924
private static function get_wp_plugins_inactive(): array {
925925
return array(
@@ -934,7 +934,7 @@ private static function get_wp_plugins_inactive(): array {
934934
*
935935
* @since 6.7.0
936936
*
937-
* @return array
937+
* @return array<string, array<string, array<string, string>>> The raw plugin debug data for active and inactive plugins.
938938
*/
939939
private static function get_wp_plugins_raw_data(): array {
940940
// List all available plugins.
@@ -1057,7 +1057,7 @@ private static function get_wp_plugins_raw_data(): array {
10571057
*
10581058
* @global array $_wp_theme_features
10591059
*
1060-
* @return array
1060+
* @return array<string, string|array> The active theme debug data.
10611061
*/
10621062
private static function get_wp_active_theme(): array {
10631063
global $_wp_theme_features;
@@ -1201,7 +1201,7 @@ private static function get_wp_active_theme(): array {
12011201
*
12021202
* @since 6.7.0
12031203
*
1204-
* @return array
1204+
* @return array<string, string|array> The parent theme debug data.
12051205
*/
12061206
private static function get_wp_parent_theme(): array {
12071207
$theme_updates = get_theme_updates();
@@ -1313,7 +1313,7 @@ private static function get_wp_parent_theme(): array {
13131313
*
13141314
* @since 6.7.0
13151315
*
1316-
* @return array
1316+
* @return array<string, string|bool|array> The inactive themes debug data.
13171317
*/
13181318
private static function get_wp_themes_inactive(): array {
13191319
$active_theme = wp_get_theme();
@@ -1444,7 +1444,7 @@ private static function get_wp_themes_inactive(): array {
14441444
*
14451445
* @since 6.7.0
14461446
*
1447-
* @return array
1447+
* @return array<string, string|array> The WordPress constants debug data.
14481448
*/
14491449
private static function get_wp_constants(): array {
14501450
// Check if WP_DEBUG_LOG is set.
@@ -1613,7 +1613,7 @@ private static function get_wp_constants(): array {
16131613
*
16141614
* @global wpdb $wpdb WordPress database abstraction object.
16151615
*
1616-
* @return array
1616+
* @return array<string, string|array> The database debug data.
16171617
*/
16181618
private static function get_wp_database(): array {
16191619
global $wpdb;
@@ -1695,7 +1695,7 @@ private static function get_wp_database(): array {
16951695
*
16961696
* @since 6.7.0
16971697
*
1698-
* @return array
1698+
* @return array<string, string|array> The debug data and other information for the Info screen.
16991699
*/
17001700
private static function get_wp_filesystem(): array {
17011701
$upload_dir = wp_upload_dir();

src/wp-admin/includes/class-wp-list-table.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ public function get_pagination_arg( $key ) {
352352
*
353353
* @since 3.1.0
354354
*
355-
* @return bool
355+
* @return bool Whether the table has items to display.
356356
*/
357357
public function has_items() {
358358
return ! empty( $this->items );
@@ -490,7 +490,7 @@ protected function get_views_links( $link_data = array() ) {
490490
*
491491
* @since 3.1.0
492492
*
493-
* @return array
493+
* @return array<string, string> An associative array of views.
494494
*/
495495
protected function get_views() {
496496
return array();
@@ -554,7 +554,7 @@ public function views() {
554554
* @since 3.1.0
555555
* @since 5.6.0 A bulk action can now contain an array of options in order to create an optgroup.
556556
*
557-
* @return array
557+
* @return array<string, string|array<string, string>> An associative array of bulk actions.
558558
*/
559559
protected function get_bulk_actions() {
560560
return array();
@@ -954,7 +954,7 @@ protected function comments_bubble( $post_id, $pending_comments ) {
954954
*
955955
* @since 3.1.0
956956
*
957-
* @return int
957+
* @return int Current page number.
958958
*/
959959
public function get_pagenum() {
960960
$pagenum = isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 0;
@@ -973,7 +973,7 @@ public function get_pagenum() {
973973
*
974974
* @param string $option User option name.
975975
* @param int $default_value Optional. The number of items to display. Default 20.
976-
* @return int
976+
* @return int Number of items to display per page.
977977
*/
978978
protected function get_items_per_page( $option, $default_value = 20 ) {
979979
$per_page = (int) get_user_option( $option );
@@ -1179,7 +1179,7 @@ protected function pagination( $which ) {
11791179
* @since 3.1.0
11801180
* @abstract
11811181
*
1182-
* @return array
1182+
* @return array<string, string> An associative array of columns.
11831183
*/
11841184
public function get_columns() {
11851185
die( 'function WP_List_Table::get_columns() must be overridden in a subclass.' );
@@ -1202,7 +1202,7 @@ public function get_columns() {
12021202
* @since 3.1.0
12031203
* @since 6.3.0 Added 'abbr', 'orderby-text' and 'initially-sorted-column-order'.
12041204
*
1205-
* @return array
1205+
* @return array<string, array<int, string|bool>|string> An associative array of sortable columns.
12061206
*/
12071207
protected function get_sortable_columns() {
12081208
return array();
@@ -1293,7 +1293,7 @@ protected function get_primary_column_name() {
12931293
*
12941294
* @since 3.1.0
12951295
*
1296-
* @return array
1296+
* @return array<int, array|string> Column information.
12971297
*/
12981298
protected function get_column_info() {
12991299
// $_column_headers is already set / cached.
@@ -1376,7 +1376,7 @@ protected function get_column_info() {
13761376
*
13771377
* @since 3.1.0
13781378
*
1379-
* @return int
1379+
* @return int The number of visible columns.
13801380
*/
13811381
public function get_column_count() {
13821382
list ( $columns, $hidden ) = $this->get_column_info();

src/wp-admin/includes/class-wp-media-list-table.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function __construct( $args = array() ) {
5353
}
5454

5555
/**
56-
* @return bool
56+
* @return bool Whether the user can upload files.
5757
*/
5858
public function ajax_user_can() {
5959
return current_user_can( 'upload_files' );
@@ -119,7 +119,7 @@ public function prepare_items() {
119119
/**
120120
* @global array $post_mime_types
121121
* @global array $avail_post_mime_types
122-
* @return array
122+
* @return array<string, string> An array of links for the available views.
123123
*/
124124
protected function get_views() {
125125
global $post_mime_types, $avail_post_mime_types;
@@ -174,7 +174,7 @@ protected function get_views() {
174174
}
175175

176176
/**
177-
* @return array
177+
* @return array<string, string> An associative array of bulk actions.
178178
*/
179179
protected function get_bulk_actions() {
180180
$actions = array();
@@ -227,7 +227,7 @@ protected function extra_tablenav( $which ) {
227227
}
228228

229229
/**
230-
* @return string
230+
* @return string|false The current action.
231231
*/
232232
public function current_action() {
233233
if ( isset( $_REQUEST['found_post_id'] ) && isset( $_REQUEST['media'] ) ) {
@@ -246,7 +246,7 @@ public function current_action() {
246246
}
247247

248248
/**
249-
* @return bool
249+
* @return bool Whether the list table has items to display.
250250
*/
251251
public function has_items() {
252252
return have_posts();
@@ -393,7 +393,7 @@ public function get_columns() {
393393
}
394394

395395
/**
396-
* @return array
396+
* @return array<string, array<int, mixed>> An array of sortable columns.
397397
*/
398398
protected function get_sortable_columns() {
399399
return array(
@@ -764,7 +764,7 @@ protected function get_default_primary_column_name() {
764764
/**
765765
* @param WP_Post $post
766766
* @param string $att_title
767-
* @return array
767+
* @return array<string, string> An array of row actions.
768768
*/
769769
private function _get_row_actions( $post, $att_title ) {
770770
$actions = array();

src/wp-admin/includes/class-wp-screen.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,7 @@ public function render_screen_meta() {
988988
*
989989
* @global array $wp_meta_boxes Global meta box state.
990990
*
991-
* @return bool
991+
* @return bool Whether to show the Screen Options tab for the current screen.
992992
*/
993993
public function show_screen_options() {
994994
global $wp_meta_boxes;

src/wp-admin/includes/class-wp-theme-install-list-table.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class WP_Theme_Install_List_Table extends WP_Themes_List_Table {
1919
public $features = array();
2020

2121
/**
22-
* @return bool
22+
* @return bool Whether the user can install themes.
2323
*/
2424
public function ajax_user_can() {
2525
return current_user_can( 'install_themes' );
@@ -179,7 +179,7 @@ public function no_items() {
179179
/**
180180
* @global array $tabs
181181
* @global string $tab
182-
* @return array
182+
* @return array<string, string> An array of links for the available views.
183183
*/
184184
protected function get_views() {
185185
global $tabs, $tab;

src/wp-admin/includes/media.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ function media_upload_form_handler() {
868868
*
869869
* @since 2.5.0
870870
*
871-
* @return null|string
871+
* @return null|string The form handler result or null.
872872
*/
873873
function wp_media_upload_handler() {
874874
$errors = array();
@@ -1096,7 +1096,7 @@ function media_sideload_image( $file, $post_id = 0, $desc = null, $return_type =
10961096
*
10971097
* @since 2.5.0
10981098
*
1099-
* @return string|null
1099+
* @return string|null The form handler result or null.
11001100
*/
11011101
function media_upload_gallery() {
11021102
$errors = array();
@@ -1122,7 +1122,7 @@ function media_upload_gallery() {
11221122
*
11231123
* @since 2.5.0
11241124
*
1125-
* @return string|null
1125+
* @return string|null The form handler result or null.
11261126
*/
11271127
function media_upload_library() {
11281128
$errors = array();
@@ -1148,7 +1148,7 @@ function media_upload_library() {
11481148
*
11491149
* @param WP_Post $post
11501150
* @param string $checked
1151-
* @return string
1151+
* @return string HTML for the image alignment radio buttons.
11521152
*/
11531153
function image_align_input_fields( $post, $checked = '' ) {
11541154

@@ -1186,7 +1186,7 @@ function image_align_input_fields( $post, $checked = '' ) {
11861186
*
11871187
* @param WP_Post $post
11881188
* @param bool|string $check
1189-
* @return array
1189+
* @return array<string, string> An array of data for the image size input fields.
11901190
*/
11911191
function image_size_input_fields( $post, $check = '' ) {
11921192
/**
@@ -1264,7 +1264,7 @@ function image_size_input_fields( $post, $check = '' ) {
12641264
*
12651265
* @param WP_Post $post
12661266
* @param string $url_type
1267-
* @return string
1267+
* @return string HTML markup for the link URL buttons.
12681268
*/
12691269
function image_link_input_fields( $post, $url_type = '' ) {
12701270

@@ -1313,7 +1313,7 @@ function wp_caption_input_textarea( $edit_post ) {
13131313
*
13141314
* @param array $form_fields
13151315
* @param object $post
1316-
* @return array
1316+
* @return array<string, array<string, mixed>> The attachment form fields.
13171317
*/
13181318
function image_attachment_fields_to_edit( $form_fields, $post ) {
13191319
return $form_fields;
@@ -1355,7 +1355,7 @@ function media_post_single_attachment_fields_to_edit( $form_fields, $post ) {
13551355
* @param string $html
13561356
* @param int $attachment_id
13571357
* @param array $attachment
1358-
* @return string
1358+
* @return string HTML markup for the media element.
13591359
*/
13601360
function image_media_send_to_editor( $html, $attachment_id, $attachment ) {
13611361
$post = get_post( $attachment_id );
@@ -1380,7 +1380,7 @@ function image_media_send_to_editor( $html, $attachment_id, $attachment ) {
13801380
*
13811381
* @param WP_Post $post
13821382
* @param array $errors
1383-
* @return array
1383+
* @return array<string, array<string, mixed>> The attachment fields.
13841384
*/
13851385
function get_attachment_fields_to_edit( $post, $errors = null ) {
13861386
if ( is_int( $post ) ) {
@@ -1865,11 +1865,13 @@ function get_media_item( $attachment_id, $args = null ) {
18651865
}
18661866

18671867
/**
1868+
* Retrieves the media markup for an attachment.
1869+
*
18681870
* @since 3.5.0
18691871
*
18701872
* @param int $attachment_id
18711873
* @param array $args
1872-
* @return array
1874+
* @return array<string, string> An array containing the media item and its metadata.
18731875
*/
18741876
function get_compat_media_markup( $attachment_id, $args = null ) {
18751877
$post = get_post( $attachment_id );

0 commit comments

Comments
 (0)