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

See #48303

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


git-svn-id: http://core.svn.wordpress.org/trunk@46461 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
John Blackbourn 2019-11-05 21:27:02 +00:00
parent f545bb3f63
commit 9ac1d82f23
16 changed files with 66 additions and 62 deletions

View File

@ -129,7 +129,7 @@ function get_bookmark_field( $field, $bookmark, $context = 'display' ) {
* and searched in 'link_url', 'link_name' and 'link_description'. * and searched in 'link_url', 'link_name' and 'link_description'.
* Default empty. * Default empty.
* } * }
* @return array List of bookmark row objects. * @return object[] List of bookmark row objects.
*/ */
function get_bookmarks( $args = '' ) { function get_bookmarks( $args = '' ) {
global $wpdb; global $wpdb;

View File

@ -33,7 +33,7 @@
* @param string $cap Capability name. * @param string $cap Capability name.
* @param int $user_id User ID. * @param int $user_id User ID.
* @param mixed ...$args Optional further parameters, typically starting with an object ID. * @param mixed ...$args Optional further parameters, typically starting with an object ID.
* @return array Actual capabilities for meta capability. * @return string[] Actual capabilities for meta capability.
*/ */
function map_meta_cap( $cap, $user_id, ...$args ) { function map_meta_cap( $cap, $user_id, ...$args ) {
$caps = array(); $caps = array();
@ -838,7 +838,7 @@ function remove_role( $role ) {
* *
* @global array $super_admins * @global array $super_admins
* *
* @return array List of super admin logins * @return string[] List of super admin logins.
*/ */
function get_super_admins() { function get_super_admins() {
global $super_admins; global $super_admins;

View File

@ -789,7 +789,7 @@ class Requests {
* Convert a key => value array to a 'key: value' array for headers * Convert a key => value array to a 'key: value' array for headers
* *
* @param array $array Dictionary of header values * @param array $array Dictionary of header values
* @return array List of headers * @return string[] List of headers
*/ */
public static function flatten($array) { public static function flatten($array) {
$return = array(); $return = array();
@ -805,7 +805,7 @@ class Requests {
* @codeCoverageIgnore * @codeCoverageIgnore
* @deprecated Misspelling of {@see Requests::flatten} * @deprecated Misspelling of {@see Requests::flatten}
* @param array $array Dictionary of header values * @param array $array Dictionary of header values
* @return array List of headers * @return string[] List of headers
*/ */
public static function flattern($array) { public static function flattern($array) {
return self::flatten($array); return self::flatten($array);

View File

@ -251,7 +251,7 @@ final class WP_Comment {
* `$meta_query`. Also accepts false, an empty array, or * `$meta_query`. Also accepts false, an empty array, or
* 'none' to disable `ORDER BY` clause. * 'none' to disable `ORDER BY` clause.
* } * }
* @return array Array of `WP_Comment` objects. * @return WP_Comment[] Array of `WP_Comment` objects.
*/ */
public function get_children( $args = array() ) { public function get_children( $args = array() ) {
$defaults = array( $defaults = array(

View File

@ -436,8 +436,8 @@ final class WP_Customize_Manager {
* *
* @since 3.4.0 * @since 3.4.0
* *
* @param mixed $ajax_message Ajax return * @param string|WP_Error $ajax_message Ajax return.
* @param mixed $message UI message * @param string $message Optional. UI message.
*/ */
protected function wp_die( $ajax_message, $message = null ) { protected function wp_die( $ajax_message, $message = null ) {
if ( $this->doing_ajax() ) { if ( $this->doing_ajax() ) {

View File

@ -173,15 +173,15 @@ class WP_Embed {
$return = call_user_func( $handler['callback'], $matches, $attr, $url, $rawattr ); $return = call_user_func( $handler['callback'], $matches, $attr, $url, $rawattr );
if ( false !== $return ) { if ( false !== $return ) {
/** /**
* Filters the returned embed handler. * Filters the returned embed HTML.
* *
* @since 2.9.0 * @since 2.9.0
* *
* @see WP_Embed::shortcode() * @see WP_Embed::shortcode()
* *
* @param mixed $return The shortcode callback function to call. * @param string|false $return The HTML result of the shortcode, or false on failure.
* @param string $url The attempted embed URL. * @param string $url The embed URL.
* @param array $attr An array of shortcode attributes. * @param array $attr An array of shortcode attributes.
*/ */
return apply_filters( 'embed_handler_html', $return, $url, $attr ); return apply_filters( 'embed_handler_html', $return, $url, $attr );
} }
@ -248,10 +248,10 @@ class WP_Embed {
* *
* @see WP_Embed::shortcode() * @see WP_Embed::shortcode()
* *
* @param mixed $cache The cached HTML result, stored in post meta. * @param string|false $cache The cached HTML result, stored in post meta.
* @param string $url The attempted embed URL. * @param string $url The attempted embed URL.
* @param array $attr An array of shortcode attributes. * @param array $attr An array of shortcode attributes.
* @param int $post_ID Post ID. * @param int $post_ID Post ID.
*/ */
return apply_filters( 'embed_oembed_html', $cache, $url, $attr, $post_ID ); return apply_filters( 'embed_oembed_html', $cache, $url, $attr, $post_ID );
} }

View File

@ -172,7 +172,12 @@ abstract class WP_Image_Editor {
* *
* @since 3.5.0 * @since 3.5.0
* *
* @return array {'width'=>int, 'height'=>int} * @return array {
* Dimensions of the image.
*
* @type int $width The image width.
* @type int $height The image height.
* }
*/ */
public function get_size() { public function get_size() {
return $this->size; return $this->size;

View File

@ -1402,7 +1402,7 @@ class WP_Query {
* @since 3.7.0 * @since 3.7.0
* *
* @param string[] $terms Array of terms to check. * @param string[] $terms Array of terms to check.
* @return array Terms that are not stopwords. * @return string[] Terms that are not stopwords.
*/ */
protected function parse_search_terms( $terms ) { protected function parse_search_terms( $terms ) {
$strtolower = function_exists( 'mb_strtolower' ) ? 'mb_strtolower' : 'strtolower'; $strtolower = function_exists( 'mb_strtolower' ) ? 'mb_strtolower' : 'strtolower';
@ -1438,7 +1438,7 @@ class WP_Query {
* *
* @since 3.7.0 * @since 3.7.0
* *
* @return array Stopwords. * @return string[] Stopwords.
*/ */
protected function get_search_stopwords() { protected function get_search_stopwords() {
if ( isset( $this->stopwords ) ) { if ( isset( $this->stopwords ) ) {
@ -3585,7 +3585,7 @@ class WP_Query {
* *
* @since 3.1.0 * @since 3.1.0
* *
* @param mixed $post_types Optional. Post type or array of posts types to check against. * @param string|string[] $post_types Optional. Post type or array of posts types to check against.
* @return bool * @return bool
*/ */
public function is_post_type_archive( $post_types = '' ) { public function is_post_type_archive( $post_types = '' ) {

View File

@ -306,7 +306,7 @@ When seeking help with this issue, you may be asked for some of the following in
* @since 5.3.0 * @since 5.3.0
* *
* @param array $extension The extension that caused the error. * @param array $extension The extension that caused the error.
* @return array An associated array of debug information. * @return array An associative array of debug information.
*/ */
private function get_debug( $extension ) { private function get_debug( $extension ) {
$theme = wp_get_theme(); $theme = wp_get_theme();

View File

@ -463,7 +463,7 @@ class WP_Rewrite {
* *
* @since 1.5.0 * @since 1.5.0
* *
* @return array Page rewrite rules. * @return string[] Page rewrite rules.
*/ */
public function page_rewrite_rules() { public function page_rewrite_rules() {
// The extra .? at the beginning prevents clashes with other regular expressions in the rules array. // The extra .? at the beginning prevents clashes with other regular expressions in the rules array.
@ -1250,7 +1250,7 @@ class WP_Rewrite {
* *
* @since 1.5.0 * @since 1.5.0
* *
* @return array An associate array of matches and queries. * @return string[] An associative array of matches and queries.
*/ */
public function rewrite_rules() { public function rewrite_rules() {
$rewrite = array(); $rewrite = array();
@ -1455,7 +1455,7 @@ class WP_Rewrite {
* *
* @since 1.5.0 * @since 1.5.0
* *
* @return array Rewrite rules. * @return string[] Array of rewrite rules keyed by their regex pattern.
*/ */
public function wp_rewrite_rules() { public function wp_rewrite_rules() {
$this->rules = get_option( 'rewrite_rules' ); $this->rules = get_option( 'rewrite_rules' );

View File

@ -1156,8 +1156,8 @@ final class WP_Theme implements ArrayAccess {
* @param mixed $type Optional. Array of extensions to return. Defaults to all files (null). * @param mixed $type Optional. Array of extensions to return. Defaults to all files (null).
* @param int $depth Optional. How deep to search for files. Defaults to a flat scan (0 depth). -1 depth is infinite. * @param int $depth Optional. How deep to search for files. Defaults to a flat scan (0 depth). -1 depth is infinite.
* @param bool $search_parent Optional. Whether to return parent files. Defaults to false. * @param bool $search_parent Optional. Whether to return parent files. Defaults to false.
* @return array Array of files, keyed by the path to the file relative to the theme's directory, with the values * @return string[] Array of files, keyed by the path to the file relative to the theme's directory, with the values
* being absolute paths. * being absolute paths.
*/ */
public function get_files( $type = null, $depth = 0, $search_parent = false ) { public function get_files( $type = null, $depth = 0, $search_parent = false ) {
$files = (array) self::scandir( $this->get_stylesheet_directory(), $type, $depth ); $files = (array) self::scandir( $this->get_stylesheet_directory(), $type, $depth );
@ -1174,7 +1174,7 @@ final class WP_Theme implements ArrayAccess {
* *
* @since 4.7.0 * @since 4.7.0
* *
* @return array Array of page templates, keyed by filename and post type, * @return string Array of page templates, keyed by filename and post type,
* with the value of the translated header name. * with the value of the translated header name.
*/ */
public function get_post_templates() { public function get_post_templates() {
@ -1233,7 +1233,7 @@ final class WP_Theme implements ArrayAccess {
* @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'.
* If a post is provided, its post type is used. * If a post is provided, its post type is used.
* @return array Array of page templates, keyed by filename, with the value of the translated header name. * @return string[] Array of template header names keyed by the template file name.
*/ */
public function get_page_templates( $post = null, $post_type = 'page' ) { public function get_page_templates( $post = null, $post_type = 'page' ) {
if ( $post ) { if ( $post ) {
@ -1248,8 +1248,7 @@ final class WP_Theme implements ArrayAccess {
* *
* @since 4.9.6 * @since 4.9.6
* *
* @param string[] $post_templates Array of page templates. Keys are filenames, * @param string[] $post_templates Array of template header names keyed by the template file name.
* values are translated names.
* @param WP_Theme $this The theme object. * @param WP_Theme $this The theme object.
* @param WP_Post|null $post The post being edited, provided for context, or null. * @param WP_Post|null $post The post being edited, provided for context, or null.
* @param string $post_type Post type to get the templates for. * @param string $post_type Post type to get the templates for.
@ -1265,8 +1264,7 @@ final class WP_Theme implements ArrayAccess {
* @since 4.4.0 Converted to allow complete control over the `$page_templates` array. * @since 4.4.0 Converted to allow complete control over the `$page_templates` array.
* @since 4.7.0 Added the `$post_type` parameter. * @since 4.7.0 Added the `$post_type` parameter.
* *
* @param string[] $post_templates Array of page templates. Keys are filenames, * @param string[] $post_templates Array of template header names keyed by the template file name.
* values are translated names.
* @param WP_Theme $this The theme object. * @param WP_Theme $this The theme object.
* @param WP_Post|null $post The post being edited, provided for context, or null. * @param WP_Post|null $post The post being edited, provided for context, or null.
* @param string $post_type Post type to get the templates for. * @param string $post_type Post type to get the templates for.
@ -1289,8 +1287,8 @@ final class WP_Theme implements ArrayAccess {
* @param string $relative_path Optional. The basename of the absolute path. Used to control the * @param string $relative_path Optional. The basename of the absolute path. Used to control the
* returned path for the found files, particularly when this function * returned path for the found files, particularly when this function
* recurses to lower depths. Default empty. * recurses to lower depths. Default empty.
* @return array|false Array of files, keyed by the path to the file relative to the `$path` directory prepended * @return string[]|false Array of files, keyed by the path to the file relative to the `$path` directory prepended
* with `$relative_path`, with the values being absolute paths. False otherwise. * with `$relative_path`, with the values being absolute paths. False otherwise.
*/ */
private static function scandir( $path, $extensions = null, $depth = 0, $relative_path = '' ) { private static function scandir( $path, $extensions = null, $depth = 0, $relative_path = '' ) {
if ( ! is_dir( $path ) ) { if ( ! is_dir( $path ) ) {

View File

@ -864,7 +864,8 @@ class WP_User {
* *
* @since 4.9.0 * @since 4.9.0
* *
* @return array User capabilities array. * @return bool[] List of capabilities keyed by the capability name,
* e.g. array( 'edit_posts' => true, 'delete_posts' => false ).
*/ */
private function get_caps_data() { private function get_caps_data() {
$caps = get_user_meta( $this->ID, $this->cap_key, true ); $caps = get_user_meta( $this->ID, $this->cap_key, true );

View File

@ -25,26 +25,26 @@ class WP_Dependencies {
public $registered = array(); public $registered = array();
/** /**
* An array of queued _WP_Dependency handle objects. * An array of handles of queued objects.
* *
* @since 2.6.8 * @since 2.6.8
* @var array * @var string[]
*/ */
public $queue = array(); public $queue = array();
/** /**
* An array of _WP_Dependency handle objects to queue. * An array of handles of objects to queue.
* *
* @since 2.6.0 * @since 2.6.0
* @var array * @var string[]
*/ */
public $to_do = array(); public $to_do = array();
/** /**
* An array of _WP_Dependency handle objects already queued. * An array of handles of objects already queued.
* *
* @since 2.6.0 * @since 2.6.0
* @var array * @var string[]
*/ */
public $done = array(); public $done = array();
@ -83,9 +83,9 @@ class WP_Dependencies {
* @since 2.6.0 * @since 2.6.0
* @since 2.8.0 Added the `$group` parameter. * @since 2.8.0 Added the `$group` parameter.
* *
* @param mixed $handles Optional. Items to be processed: Process queue (false), process item (string), process items (array of strings). * @param mixed $handles Optional. Items to be processed: Process queue (false), process item (string), process items (array of strings).
* @param mixed $group Group level: level (int), no groups (false). * @param int|false $group Optional. Group level: level (int), no groups (false).
* @return array Handles of items that have been processed. * @return string[] Array of handles of items that have been processed.
*/ */
public function do_items( $handles = false, $group = false ) { public function do_items( $handles = false, $group = false ) {
/* /*
@ -136,9 +136,9 @@ class WP_Dependencies {
* @since 2.6.0 Moved from `WP_Scripts`. * @since 2.6.0 Moved from `WP_Scripts`.
* @since 2.8.0 Added the `$group` parameter. * @since 2.8.0 Added the `$group` parameter.
* *
* @param mixed $handles Item handle and argument (string) or item handles and arguments (array of strings). * @param string|string[] $handles Item handle and argument (string) or item handles and arguments (array of strings).
* @param bool $recursion Internal flag that function is calling itself. * @param bool $recursion Internal flag that function is calling itself.
* @param int|false $group Group level: (int) level, (false) no groups. * @param int|false $group Group level: (int) level, (false) no groups.
* @return bool True on success, false on failure. * @return bool True on success, false on failure.
*/ */
public function all_deps( $handles, $recursion = false, $group = false ) { public function all_deps( $handles, $recursion = false, $group = false ) {
@ -270,7 +270,7 @@ class WP_Dependencies {
* @since 2.1.0 * @since 2.1.0
* @since 2.6.0 Moved from `WP_Scripts`. * @since 2.6.0 Moved from `WP_Scripts`.
* *
* @param mixed $handles Item handle and argument (string) or item handles and arguments (array of strings). * @param string|string[] $handles Item handle and argument (string) or item handles and arguments (array of strings).
* @return void * @return void
*/ */
public function remove( $handles ) { public function remove( $handles ) {
@ -290,7 +290,7 @@ class WP_Dependencies {
* @since 2.1.0 * @since 2.1.0
* @since 2.6.0 Moved from `WP_Scripts`. * @since 2.6.0 Moved from `WP_Scripts`.
* *
* @param mixed $handles Item handle and argument (string) or item handles and arguments (array of strings). * @param string|string[] $handles Item handle and argument (string) or item handles and arguments (array of strings).
*/ */
public function enqueue( $handles ) { public function enqueue( $handles ) {
foreach ( (array) $handles as $handle ) { foreach ( (array) $handles as $handle ) {
@ -313,7 +313,7 @@ class WP_Dependencies {
* @since 2.1.0 * @since 2.1.0
* @since 2.6.0 Moved from `WP_Scripts`. * @since 2.6.0 Moved from `WP_Scripts`.
* *
* @param mixed $handles Item handle and argument (string) or item handles and arguments (array of strings). * @param string|string[] $handles Item handle and argument (string) or item handles and arguments (array of strings).
*/ */
public function dequeue( $handles ) { public function dequeue( $handles ) {
foreach ( (array) $handles as $handle ) { foreach ( (array) $handles as $handle ) {

View File

@ -175,11 +175,11 @@ class WP_Scripts extends WP_Dependencies {
* @since 2.1.0 * @since 2.1.0
* @since 2.8.0 Added the `$group` parameter. * @since 2.8.0 Added the `$group` parameter.
* *
* @param mixed $handles Optional. Scripts to be printed. (void) prints queue, (string) prints * @param mixed $handles Optional. Scripts to be printed. (void) prints queue, (string) prints
* that script, (array of strings) prints those scripts. Default false. * that script, (array of strings) prints those scripts. Default false.
* @param int $group Optional. If scripts were queued in groups prints this group number. * @param int|false $group Optional. If scripts were queued in groups prints this group number.
* Default false. * Default false.
* @return array Scripts that have been printed. * @return string[] Handles of scripts that have been printed.
*/ */
public function print_scripts( $handles = false, $group = false ) { public function print_scripts( $handles = false, $group = false ) {
return $this->do_items( $handles, $group ); return $this->do_items( $handles, $group );
@ -627,7 +627,7 @@ JS;
* *
* @see WP_Dependencies::do_items() * @see WP_Dependencies::do_items()
* *
* @return array Handles of items that have been processed. * @return string[] Handles of items that have been processed.
*/ */
public function do_head_items() { public function do_head_items() {
$this->do_items( false, 0 ); $this->do_items( false, 0 );
@ -641,7 +641,7 @@ JS;
* *
* @see WP_Dependencies::do_items() * @see WP_Dependencies::do_items()
* *
* @return array Handles of items that have been processed. * @return string[] Handles of items that have been processed.
*/ */
public function do_footer_items() { public function do_footer_items() {
$this->do_items( false, 1 ); $this->do_items( false, 1 );

View File

@ -356,9 +356,9 @@ class WP_Styles extends WP_Dependencies {
* *
* @see WP_Dependencies::all_deps() * @see WP_Dependencies::all_deps()
* *
* @param mixed $handles Item handle and argument (string) or item handles and arguments (array of strings). * @param string|string[] $handles Item handle and argument (string) or item handles and arguments (array of strings).
* @param bool $recursion Internal flag that function is calling itself. * @param bool $recursion Internal flag that function is calling itself.
* @param int|false $group Group level: (int) level, (false) no groups. * @param int|false $group Group level: (int) level, (false) no groups.
* @return bool True on success, false on failure. * @return bool True on success, false on failure.
*/ */
public function all_deps( $handles, $recursion = false, $group = false ) { public function all_deps( $handles, $recursion = false, $group = false ) {
@ -437,7 +437,7 @@ class WP_Styles extends WP_Dependencies {
* *
* @see WP_Dependencies::do_items() * @see WP_Dependencies::do_items()
* *
* @return array Handles of items that have been processed. * @return string[] Handles of items that have been processed.
*/ */
public function do_footer_items() { public function do_footer_items() {
$this->do_items( false, 1 ); $this->do_items( false, 1 );

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.4-alpha-46660'; $wp_version = '5.4-alpha-46661';
/** /**
* 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.