Docs: Docs on docs. Further improve documentation of known return types, plus other docs fixes.

See #48303

Built from https://develop.svn.wordpress.org/trunk@46662


git-svn-id: http://core.svn.wordpress.org/trunk@46462 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
John Blackbourn
2019-11-05 21:30:03 +00:00
parent 9ac1d82f23
commit eda6a9e111
16 changed files with 50 additions and 44 deletions

View File

@@ -117,12 +117,12 @@ function wp_delete_link( $link_id ) {
} }
/** /**
* Retrieves the link categories associated with the link specified. * Retrieves the link category IDs associated with the link specified.
* *
* @since 2.1.0 * @since 2.1.0
* *
* @param int $link_id Link ID to look up * @param int $link_id Link ID to look up.
* @return array The requested link's categories * @return int[] The IDs of the requested link's categories.
*/ */
function wp_get_link_cats( $link_id = 0 ) { function wp_get_link_cats( $link_id = 0 ) {
$cats = wp_get_object_terms( $link_id, 'link_category', array( 'fields' => 'ids' ) ); $cats = wp_get_object_terms( $link_id, 'link_category', array( 'fields' => 'ids' ) );

View File

@@ -1217,7 +1217,7 @@ class WP_List_Table {
* *
* @since 3.1.0 * @since 3.1.0
* *
* @return array List of CSS classes for the table tag. * @return string[] Array of CSS classes for the table tag.
*/ */
protected function get_table_classes() { protected function get_table_classes() {
return array( 'widefat', 'fixed', 'striped', $this->_args['plural'] ); return array( 'widefat', 'fixed', 'striped', $this->_args['plural'] );

View File

@@ -35,7 +35,7 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table {
* *
* @since 4.9.6 * @since 4.9.6
* *
* @return array Array of columns. * @return string[] Array of column titles keyed by their column name.
*/ */
public function get_columns() { public function get_columns() {
$columns = array( $columns = array(
@@ -137,7 +137,7 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table {
* *
* @since 4.9.6 * @since 4.9.6
* *
* @return array Associative array of views in the format of $view_name => $view_markup. * @return string[] An array of HTML links keyed by their view.
*/ */
protected function get_views() { protected function get_views() {
$current_status = isset( $_REQUEST['filter-status'] ) ? sanitize_text_field( $_REQUEST['filter-status'] ) : ''; $current_status = isset( $_REQUEST['filter-status'] ) ? sanitize_text_field( $_REQUEST['filter-status'] ) : '';
@@ -200,7 +200,7 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table {
* *
* @since 4.9.6 * @since 4.9.6
* *
* @return array List of bulk actions. * @return string[] Array of bulk action labels keyed by their action.
*/ */
protected function get_bulk_actions() { protected function get_bulk_actions() {
return array( return array(

View File

@@ -170,7 +170,7 @@ class WP_Users_List_Table extends WP_List_Table {
* *
* @global string $role * @global string $role
* *
* @return array An array of HTML links, one for each view. * @return string[] An array of HTML links keyed by their view.
*/ */
protected function get_views() { protected function get_views() {
global $role; global $role;
@@ -259,7 +259,7 @@ class WP_Users_List_Table extends WP_List_Table {
* *
* @since 3.1.0 * @since 3.1.0
* *
* @return array Array of bulk actions. * @return string[] Array of bulk action labels keyed by their action.
*/ */
protected function get_bulk_actions() { protected function get_bulk_actions() {
$actions = array(); $actions = array();
@@ -348,8 +348,7 @@ class WP_Users_List_Table extends WP_List_Table {
* *
* @since 3.1.0 * @since 3.1.0
* *
* @return array Array in which the key is the ID of the column, * @return string[] Array of column titles keyed by their column name.
* and the value is the description.
*/ */
public function get_columns() { public function get_columns() {
$c = array( $c = array(

View File

@@ -62,7 +62,7 @@ function got_url_rewrite() {
* *
* @param string $filename Filename to extract the strings from. * @param string $filename Filename to extract the strings from.
* @param string $marker The marker to extract the strings from. * @param string $marker The marker to extract the strings from.
* @return array An array of strings from a file (.htaccess) from between BEGIN and END markers. * @return string[] An array of strings from a file (.htaccess) from between BEGIN and END markers.
*/ */
function extract_from_markers( $filename, $marker ) { function extract_from_markers( $filename, $marker ) {
$result = array(); $result = array();

View File

@@ -1085,7 +1085,7 @@ function wp_get_nav_menu_to_edit( $menu_id = 0 ) {
* *
* @since 3.0.0 * @since 3.0.0
* *
* @return array Columns. * @return string[] Array of column titles keyed by their column name.
*/ */
function wp_nav_menu_manage_columns() { function wp_nav_menu_manage_columns() {
return array( return array(

View File

@@ -226,7 +226,7 @@ function _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup
* @since 2.8.0 * @since 2.8.0
* *
* @param string $plugin Path to the plugin file relative to the plugins directory. * @param string $plugin Path to the plugin file relative to the plugins directory.
* @return array List of files relative to the plugin root. * @return string[] Array of file names relative to the plugin root.
*/ */
function get_plugin_files( $plugin ) { function get_plugin_files( $plugin ) {
$plugin_file = WP_PLUGIN_DIR . '/' . $plugin; $plugin_file = WP_PLUGIN_DIR . '/' . $plugin;
@@ -273,7 +273,7 @@ function get_plugin_files( $plugin ) {
* @since 1.5.0 * @since 1.5.0
* *
* @param string $plugin_folder Optional. Relative path to single plugin folder. * @param string $plugin_folder Optional. Relative path to single plugin folder.
* @return array Key is the plugin file path and the value is an array of the plugin data. * @return array[] Array of arrays of plugin data, keyed by plugin file name. See `get_plugin_data()`.
*/ */
function get_plugins( $plugin_folder = '' ) { function get_plugins( $plugin_folder = '' ) {
@@ -354,7 +354,7 @@ function get_plugins( $plugin_folder = '' ) {
* WordPress only includes mu-plugin files in the base mu-plugins directory (wp-content/mu-plugins). * WordPress only includes mu-plugin files in the base mu-plugins directory (wp-content/mu-plugins).
* *
* @since 3.0.0 * @since 3.0.0
* @return array Key is the mu-plugin file path and the value is an array of the mu-plugin data. * @return array[] Array of arrays of mu-plugin data, keyed by plugin file name. See `get_plugin_data()`.
*/ */
function get_mu_plugins() { function get_mu_plugins() {
$wp_plugins = array(); $wp_plugins = array();
@@ -423,7 +423,7 @@ function _sort_uname_callback( $a, $b ) {
* Check the wp-content directory and retrieve all drop-ins with any plugin data. * Check the wp-content directory and retrieve all drop-ins with any plugin data.
* *
* @since 3.0.0 * @since 3.0.0
* @return array Key is the file path and the value is an array of the plugin data. * @return array[] Array of arrays of dropin plugin data, keyed by plugin file name. See `get_plugin_data()`.
*/ */
function get_dropins() { function get_dropins() {
$dropins = array(); $dropins = array();
@@ -471,7 +471,7 @@ function get_dropins() {
* Includes Multisite drop-ins only when is_multisite() * Includes Multisite drop-ins only when is_multisite()
* *
* @since 3.0.0 * @since 3.0.0
* @return array Key is file name. The value is an array, with the first value the * @return array[] Key is file name. The value is an array, with the first value the
* purpose of the drop-in and the second value the name of the constant that must be * purpose of the drop-in and the second value the name of the constant that must be
* true for the drop-in to be used, or true if no constant is required. * true for the drop-in to be used, or true if no constant is required.
*/ */
@@ -1029,7 +1029,7 @@ function delete_plugins( $plugins, $deprecated = '' ) {
* returns an array of deactivated ones. * returns an array of deactivated ones.
* *
* @since 2.5.0 * @since 2.5.0
* @return array invalid plugins, plugin as key, error as value * @return WP_Error[] Array of plugin errors keyed by plugin file name.
*/ */
function validate_active_plugins() { function validate_active_plugins() {
$plugins = get_option( 'active_plugins', array() ); $plugins = get_option( 'active_plugins', array() );

View File

@@ -1082,8 +1082,8 @@ function _fix_attachment_links( $post ) {
* *
* @since 2.5.0 * @since 2.5.0
* *
* @param string $type The post_type you want the statuses for * @param string $type The post_type you want the statuses for. Default 'post'.
* @return array As array of all the statuses for the supplied post type * @return string[] An array of all the statuses for the supplied post type.
*/ */
function get_available_post_statuses( $type = 'post' ) { function get_available_post_statuses( $type = 'post' ) {
$stati = wp_count_posts( $type ); $stati = wp_count_posts( $type );
@@ -1492,7 +1492,7 @@ function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) {
* @since 2.9.0 * @since 2.9.0
* *
* @param int $thumbnail_id ID of the attachment used for thumbnail * @param int $thumbnail_id ID of the attachment used for thumbnail
* @param mixed $post The post ID or object associated with the thumbnail, defaults to global $post. * @param int|WP_Post $post Optional. The post ID or object associated with the thumbnail, defaults to global $post.
* @return string html * @return string html
*/ */
function _wp_post_thumbnail_html( $thumbnail_id = null, $post = null ) { function _wp_post_thumbnail_html( $thumbnail_id = null, $post = null ) {
@@ -2150,7 +2150,7 @@ function use_block_editor_for_post_type( $post_type ) {
* @since 5.0.0 * @since 5.0.0
* *
* @param WP_Post $post Post object. * @param WP_Post $post Post object.
* @return array Array of block categories. * @return array[] Array of block categories.
*/ */
function get_block_categories( $post ) { function get_block_categories( $post ) {
$default_categories = array( $default_categories = array(

View File

@@ -140,12 +140,12 @@ function meta_box_prefs( $screen ) {
} }
/** /**
* Get Hidden Meta Boxes * Gets an array of IDs of hidden meta boxes.
* *
* @since 2.7.0 * @since 2.7.0
* *
* @param string|WP_Screen $screen Screen identifier * @param string|WP_Screen $screen Screen identifier
* @return array Hidden Meta Boxes * @return string[] IDs of hidden meta boxes.
*/ */
function get_hidden_meta_boxes( $screen ) { function get_hidden_meta_boxes( $screen ) {
if ( is_string( $screen ) ) { if ( is_string( $screen ) ) {
@@ -172,7 +172,7 @@ function get_hidden_meta_boxes( $screen ) {
* *
* @since 3.1.0 * @since 3.1.0
* *
* @param array $hidden An array of meta boxes hidden by default. * @param string[] $hidden An array of IDs of meta boxes hidden by default.
* @param WP_Screen $screen WP_Screen object of the current screen. * @param WP_Screen $screen WP_Screen object of the current screen.
*/ */
$hidden = apply_filters( 'default_hidden_meta_boxes', $hidden, $screen ); $hidden = apply_filters( 'default_hidden_meta_boxes', $hidden, $screen );
@@ -183,7 +183,7 @@ function get_hidden_meta_boxes( $screen ) {
* *
* @since 3.3.0 * @since 3.3.0
* *
* @param array $hidden An array of hidden meta boxes. * @param string[] $hidden An array of IDs of hidden meta boxes.
* @param WP_Screen $screen WP_Screen object of the current screen. * @param WP_Screen $screen WP_Screen object of the current screen.
* @param bool $use_defaults Whether to show the default meta boxes. * @param bool $use_defaults Whether to show the default meta boxes.
* Default true. * Default true.
@@ -233,8 +233,8 @@ function get_current_screen() {
* *
* @since 3.0.0 * @since 3.0.0
* *
* @param mixed $hook_name Optional. The hook name (also known as the hook suffix) used to determine the screen, * @param string|WP_Screen $hook_name Optional. The hook name (also known as the hook suffix) used to determine the screen,
* or an existing screen object. * or an existing screen object.
*/ */
function set_current_screen( $hook_name = '' ) { function set_current_screen( $hook_name = '' ) {
WP_Screen::get( $hook_name )->set_current_screen(); WP_Screen::get( $hook_name )->set_current_screen();

View File

@@ -73,7 +73,7 @@ function wp_create_category( $cat_name, $parent = 0 ) {
* *
* @param string[] $categories Array of category names to create. * @param string[] $categories Array of category names to create.
* @param int $post_id Optional. The post ID. Default empty. * @param int $post_id Optional. The post ID. Default empty.
* @return array List of categories to create for the given post. * @return int[] Array of IDs of categories assigned to the given post.
*/ */
function wp_create_categories( $categories, $post_id = '' ) { function wp_create_categories( $categories, $post_id = '' ) {
$cat_ids = array(); $cat_ids = array();

View File

@@ -199,10 +199,10 @@ function wp_terms_checklist( $post_id = 0, $args = array() ) {
* @since 2.5.0 * @since 2.5.0
* *
* @param string $taxonomy Taxonomy to retrieve terms from. * @param string $taxonomy Taxonomy to retrieve terms from.
* @param int $default Not used. * @param int $default Not used.
* @param int $number Number of terms to retrieve. Defaults to 10. * @param int $number Number of terms to retrieve. Defaults to 10.
* @param bool $echo Optionally output the list as well. Defaults to true. * @param bool $echo Optionally output the list as well. Defaults to true.
* @return array List of popular term IDs. * @return int[] Array of popular term IDs.
*/ */
function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $echo = true ) { function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $echo = true ) {
$post = get_post(); $post = get_post();
@@ -2097,12 +2097,12 @@ function _post_states( $post, $echo = true ) {
} }
/** /**
* Function to retrieve an array of post states from a post. * Retrieves an array of post states from a post.
* *
* @since 5.3.0 * @since 5.3.0
* *
* @param WP_Post $post The post to retrieve states for. * @param WP_Post $post The post to retrieve states for.
* @return array The array of translated post states. * @return string[] Array of post state labels keyed by their state.
*/ */
function get_post_states( $post ) { function get_post_states( $post ) {
$post_states = array(); $post_states = array();

View File

@@ -112,14 +112,14 @@ function delete_theme( $stylesheet, $redirect = '' ) {
} }
/** /**
* Get the Page Templates available in this theme * Gets the page templates available in this theme.
* *
* @since 1.5.0 * @since 1.5.0
* @since 4.7.0 Added the `$post_type` parameter. * @since 4.7.0 Added the `$post_type` parameter.
* *
* @param WP_Post|null $post Optional. The post being edited, provided for context. * @param WP_Post|null $post Optional. The post being edited, provided for context.
* @param string $post_type Optional. Post type to get the templates for. Default 'page'. * @param string $post_type Optional. Post type to get the templates for. Default 'page'.
* @return array Key is the template name, value is the filename of the template * @return string[] Array of template file names keyed by the template header name.
*/ */
function get_page_templates( $post = null, $post_type = 'page' ) { function get_page_templates( $post = null, $post_type = 'page' ) {
return array_flip( wp_get_theme()->get_page_templates( $post, $post_type ) ); return array_flip( wp_get_theme()->get_page_templates( $post, $post_type ) );

View File

@@ -115,8 +115,8 @@ function translations_api( $type, $args = null ) {
* *
* @see translations_api() * @see translations_api()
* *
* @return array Array of translations, each an array of data. If the API response results * @return array[] Array of translations, each an array of data, keyed by the language. If the API response results
* in an error, an empty array will be returned. * in an error, an empty array will be returned.
*/ */
function wp_get_available_translations() { function wp_get_available_translations() {
if ( ! wp_installing() ) { if ( ! wp_installing() ) {

View File

@@ -35,7 +35,14 @@ if ( ! function_exists( 'wp_install' ) ) :
* @param string $deprecated Optional. Not used. * @param string $deprecated Optional. Not used.
* @param string $user_password Optional. User's chosen password. Default empty (random password). * @param string $user_password Optional. User's chosen password. Default empty (random password).
* @param string $language Optional. Language chosen. Default empty. * @param string $language Optional. Language chosen. Default empty.
* @return array Array keys 'url', 'user_id', 'password', and 'password_message'. * @return array {
* Data for the newly installed site.
*
* @type string $url The URL of the site.
* @type int $user_id The ID of the site owner.
* @type string $password The password of the site owner, if their user account didn't already exist.
* @type string $password_message The explanatory message regarding the password.
* }
*/ */
function wp_install( $blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '', $language = '' ) { function wp_install( $blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '', $language = '' ) {
if ( ! empty( $deprecated ) ) { if ( ! empty( $deprecated ) ) {

View File

@@ -98,7 +98,7 @@ function has_block( $block_type, $post = null ) {
* *
* @since 5.0.0 * @since 5.0.0
* *
* @return array Array of dynamic block names. * @return string[] Array of dynamic block names.
*/ */
function get_dynamic_block_names() { function get_dynamic_block_names() {
$dynamic_block_names = array(); $dynamic_block_names = array();
@@ -281,7 +281,7 @@ function render_block( $block ) {
* @since 5.0.0 * @since 5.0.0
* *
* @param string $content Post content. * @param string $content Post content.
* @return array Array of parsed block objects. * @return array[] Array of parsed block objects.
*/ */
function parse_blocks( $content ) { function parse_blocks( $content ) {
/** /**

View File

@@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.4-alpha-46661'; $wp_version = '5.4-alpha-46662';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.