Skip to content

Commit 31e3936

Browse files
Docs: Document default values for optional parameters in various DocBlocks.
Props paulkevan, costdev, audrasjb, SergeyBiryukov. See #56792. git-svn-id: https://develop.svn.wordpress.org/trunk@55398 602fd350-edb4-49c9-b593-d223f7449a82
1 parent ef89c31 commit 31e3936

16 files changed

+109
-77
lines changed

src/wp-includes/author-template.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ function the_modified_author() {
155155
* @global WP_User $authordata The current author's data.
156156
*
157157
* @param string $field Optional. The user field to retrieve. Default empty.
158-
* @param int|false $user_id Optional. User ID.
158+
* @param int|false $user_id Optional. User ID. Defaults to the current post author.
159159
* @return string The author's field from the current author's DB object, otherwise an empty string.
160160
*/
161161
function get_the_author_meta( $field = '', $user_id = false ) {
@@ -196,7 +196,7 @@ function get_the_author_meta( $field = '', $user_id = false ) {
196196
*
197197
* @param string $field Selects the field of the users record. See get_the_author_meta()
198198
* for the list of possible fields.
199-
* @param int|false $user_id Optional. User ID.
199+
* @param int|false $user_id Optional. User ID. Defaults to the current post author.
200200
*
201201
* @see get_the_author_meta()
202202
*/

src/wp-includes/bookmark.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ function get_bookmark( $bookmark, $output = OBJECT, $filter = 'raw' ) {
7171
*
7272
* @param string $field The name of the data field to return.
7373
* @param int $bookmark The bookmark ID to get field.
74-
* @param string $context Optional. The context of how the field will be used.
74+
* @param string $context Optional. The context of how the field will be used. Default 'display'.
7575
* @return string|WP_Error
7676
*/
7777
function get_bookmark_field( $field, $bookmark, $context = 'display' ) {

src/wp-includes/class-wp-editor.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,7 +1451,7 @@ private static function get_translation() {
14511451
*
14521452
* @param string $mce_locale The locale used for the editor.
14531453
* @param bool $json_only Optional. Whether to include the JavaScript calls to tinymce.addI18n() and
1454-
* tinymce.ScriptLoader.markDone().
1454+
* tinymce.ScriptLoader.markDone(). Default false.
14551455
* @return string Translation object, JSON encoded.
14561456
*/
14571457
public static function wp_mce_translation( $mce_locale = '', $json_only = false ) {
@@ -1751,7 +1751,12 @@ public static function wp_fullscreen_html() {
17511751
*
17521752
* @since 3.1.0
17531753
*
1754-
* @param array $args Optional. Accepts 'pagenum' and 's' (search) arguments.
1754+
* @param array $args {
1755+
* Optional. Array of link query arguments.
1756+
*
1757+
* @type int $pagenum Page number. Default 1.
1758+
* @type string $s Search keywords.
1759+
* }
17551760
* @return array|false $results {
17561761
* An array of associative arrays of query results, false if there are none.
17571762
*

src/wp-includes/class-wp-error.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class WP_Error {
5656
*
5757
* @param string|int $code Error code.
5858
* @param string $message Error message.
59-
* @param mixed $data Optional. Error data.
59+
* @param mixed $data Optional. Error data. Default empty string.
6060
*/
6161
public function __construct( $code = '', $message = '', $data = '' ) {
6262
if ( empty( $code ) ) {
@@ -103,7 +103,8 @@ public function get_error_code() {
103103
*
104104
* @since 2.1.0
105105
*
106-
* @param string|int $code Optional. Retrieve messages matching code, if exists.
106+
* @param string|int $code Optional. Error code to retrieve the messages for.
107+
* Default empty string.
107108
* @return string[] Error strings on success, or empty array if there are none.
108109
*/
109110
public function get_error_messages( $code = '' ) {
@@ -132,7 +133,8 @@ public function get_error_messages( $code = '' ) {
132133
*
133134
* @since 2.1.0
134135
*
135-
* @param string|int $code Optional. Error code to retrieve message.
136+
* @param string|int $code Optional. Error code to retrieve the message for.
137+
* Default empty string.
136138
* @return string The error message.
137139
*/
138140
public function get_error_message( $code = '' ) {
@@ -151,7 +153,7 @@ public function get_error_message( $code = '' ) {
151153
*
152154
* @since 2.1.0
153155
*
154-
* @param string|int $code Optional. Error code.
156+
* @param string|int $code Optional. Error code. Default empty string.
155157
* @return mixed Error data, if it exists.
156158
*/
157159
public function get_error_data( $code = '' ) {
@@ -185,7 +187,7 @@ public function has_errors() {
185187
*
186188
* @param string|int $code Error code.
187189
* @param string $message Error message.
188-
* @param mixed $data Optional. Error data.
190+
* @param mixed $data Optional. Error data. Default empty string.
189191
*/
190192
public function add( $code, $message, $data = '' ) {
191193
$this->errors[ $code ][] = $message;

src/wp-includes/class-wp-meta-query.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ public function get_cast_for_type( $type = '' ) {
345345
* @param string $primary_id_column ID column for the filtered object in $primary_table.
346346
* @param object $context Optional. The main query object that corresponds to the type, for
347347
* example a `WP_Query`, `WP_User_Query`, or `WP_Site_Query`.
348+
* Default null.
348349
* @return string[]|false {
349350
* Array containing JOIN and WHERE SQL clauses to append to the main query,
350351
* or false if no table exists for the requested meta type.
@@ -521,6 +522,7 @@ protected function get_sql_for_query( &$query, $depth = 0 ) {
521522
* @param array $parent_query Parent query array.
522523
* @param string $clause_key Optional. The array key used to name the clause in the original `$meta_query`
523524
* parameters. If not provided, a key will be generated automatically.
525+
* Default empty string.
524526
* @return string[] {
525527
* Array containing JOIN and WHERE SQL clauses to append to a first-order query.
526528
*

src/wp-includes/class-wp-widget.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public function form( $instance ) {
152152
*
153153
* @since 2.8.0
154154
*
155-
* @param string $id_base Optional. Base ID for the widget, lowercase and unique. If left empty,
155+
* @param string $id_base Base ID for the widget, lowercase and unique. If left empty,
156156
* a portion of the widget's PHP class name will be used. Has to be unique.
157157
* @param string $name Name for the widget displayed on the configuration page.
158158
* @param array $widget_options Optional. Widget options. See wp_register_sidebar_widget() for
@@ -188,7 +188,7 @@ public function __construct( $id_base, $name, $widget_options = array(), $contro
188188
*
189189
* @see WP_Widget::__construct()
190190
*
191-
* @param string $id_base Optional. Base ID for the widget, lowercase and unique. If left empty,
191+
* @param string $id_base Base ID for the widget, lowercase and unique. If left empty,
192192
* a portion of the widget's PHP class name will be used. Has to be unique.
193193
* @param string $name Name for the widget displayed on the configuration page.
194194
* @param array $widget_options Optional. Widget options. See wp_register_sidebar_widget() for

src/wp-includes/class-wpdb.php

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,7 @@ public function set_prefix( $prefix, $set_table_names = true ) {
10721072
* @since 3.0.0
10731073
*
10741074
* @param int $blog_id
1075-
* @param int $network_id Optional.
1075+
* @param int $network_id Optional. Network ID. Default 0.
10761076
* @return int Previous blog ID.
10771077
*/
10781078
public function set_blog_id( $blog_id, $network_id = 0 ) {
@@ -1101,7 +1101,8 @@ public function set_blog_id( $blog_id, $network_id = 0 ) {
11011101
*
11021102
* @since 3.0.0
11031103
*
1104-
* @param int $blog_id Optional.
1104+
* @param int $blog_id Optional. Blog ID to retrieve the table prefix for.
1105+
* Defaults to the current blog ID.
11051106
* @return string Blog prefix.
11061107
*/
11071108
public function get_blog_prefix( $blog_id = null ) {
@@ -1220,7 +1221,8 @@ public function tables( $scope = 'all', $prefix = true, $blog_id = 0 ) {
12201221
* @since 0.71
12211222
*
12221223
* @param string $db Database name.
1223-
* @param mysqli|resource $dbh Optional database connection.
1224+
* @param mysqli|resource $dbh Optional. Database connection.
1225+
* Defaults to the current database handle.
12241226
*/
12251227
public function select( $db, $dbh = null ) {
12261228
if ( is_null( $dbh ) ) {
@@ -2561,7 +2563,7 @@ public function remove_placeholder_escape( $query ) {
25612563
* If string, that format will be used for all of the values in $data.
25622564
* A format is one of '%d', '%f', '%s' (integer, float, string).
25632565
* If omitted, all values in $data will be treated as strings unless otherwise
2564-
* specified in wpdb::$field_types.
2566+
* specified in wpdb::$field_types. Default null.
25652567
* @return int|false The number of rows inserted, or false on error.
25662568
*/
25672569
public function insert( $table, $data, $format = null ) {
@@ -2591,7 +2593,7 @@ public function insert( $table, $data, $format = null ) {
25912593
* If string, that format will be used for all of the values in $data.
25922594
* A format is one of '%d', '%f', '%s' (integer, float, string).
25932595
* If omitted, all values in $data will be treated as strings unless otherwise
2594-
* specified in wpdb::$field_types.
2596+
* specified in wpdb::$field_types. Default null.
25952597
* @return int|false The number of rows affected, or false on error.
25962598
*/
25972599
public function replace( $table, $data, $format = null ) {
@@ -2618,7 +2620,7 @@ public function replace( $table, $data, $format = null ) {
26182620
* If string, that format will be used for all of the values in $data.
26192621
* A format is one of '%d', '%f', '%s' (integer, float, string).
26202622
* If omitted, all values in $data will be treated as strings unless otherwise
2621-
* specified in wpdb::$field_types.
2623+
* specified in wpdb::$field_types. Default null.
26222624
* @param string $type Optional. Type of operation. Possible values include 'INSERT' or 'REPLACE'.
26232625
* Default 'INSERT'.
26242626
* @return int|false The number of rows affected, or false on error.
@@ -2684,11 +2686,11 @@ public function _insert_replace_helper( $table, $data, $format = null, $type = '
26842686
* If string, that format will be used for all of the values in $data.
26852687
* A format is one of '%d', '%f', '%s' (integer, float, string).
26862688
* If omitted, all values in $data will be treated as strings unless otherwise
2687-
* specified in wpdb::$field_types.
2689+
* specified in wpdb::$field_types. Default null.
26882690
* @param array|string $where_format Optional. An array of formats to be mapped to each of the values in $where.
26892691
* If string, that format will be used for all of the items in $where.
26902692
* A format is one of '%d', '%f', '%s' (integer, float, string).
2691-
* If omitted, all values in $where will be treated as strings.
2693+
* If omitted, all values in $where will be treated as strings. Default null.
26922694
* @return int|false The number of rows updated, or false on error.
26932695
*/
26942696
public function update( $table, $data, $where, $format = null, $where_format = null ) {
@@ -2760,7 +2762,7 @@ public function update( $table, $data, $where, $format = null, $where_format = n
27602762
* If string, that format will be used for all of the items in $where.
27612763
* A format is one of '%d', '%f', '%s' (integer, float, string).
27622764
* If omitted, all values in $data will be treated as strings unless otherwise
2763-
* specified in wpdb::$field_types.
2765+
* specified in wpdb::$field_types. Default null.
27642766
* @return int|false The number of rows deleted, or false on error.
27652767
*/
27662768
public function delete( $table, $where, $where_format = null ) {
@@ -2967,8 +2969,8 @@ protected function process_field_lengths( $data, $table ) {
29672969
* @since 0.71
29682970
*
29692971
* @param string|null $query Optional. SQL query. Defaults to null, use the result from the previous query.
2970-
* @param int $x Optional. Column of value to return. Indexed from 0.
2971-
* @param int $y Optional. Row of value to return. Indexed from 0.
2972+
* @param int $x Optional. Column of value to return. Indexed from 0. Default 0.
2973+
* @param int $y Optional. Row of value to return. Indexed from 0. Default 0.
29722974
* @return string|null Database query result (as string), or null on failure.
29732975
*/
29742976
public function get_var( $query = null, $x = 0, $y = 0 ) {
@@ -3002,7 +3004,7 @@ public function get_var( $query = null, $x = 0, $y = 0 ) {
30023004
* @param string $output Optional. The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which
30033005
* correspond to an stdClass object, an associative array, or a numeric array,
30043006
* respectively. Default OBJECT.
3005-
* @param int $y Optional. Row to return. Indexed from 0.
3007+
* @param int $y Optional. Row to return. Indexed from 0. Default 0.
30063008
* @return array|object|null|void Database query result in format specified by $output or null on failure.
30073009
*/
30083010
public function get_row( $query = null, $output = OBJECT, $y = 0 ) {
@@ -3046,7 +3048,7 @@ public function get_row( $query = null, $output = OBJECT, $y = 0 ) {
30463048
* @since 0.71
30473049
*
30483050
* @param string|null $query Optional. SQL query. Defaults to previous query.
3049-
* @param int $x Optional. Column to return. Indexed from 0.
3051+
* @param int $x Optional. Column to return. Indexed from 0. Default 0.
30503052
* @return array Database query result. Array indexed from 0 by SQL result row number.
30513053
*/
30523054
public function get_col( $query = null, $x = 0 ) {
@@ -3083,6 +3085,7 @@ public function get_col( $query = null, $x = 0 ) {
30833085
* or an object ( ->column = value ), respectively. With OBJECT_K,
30843086
* return an associative array of row objects keyed by the value
30853087
* of each row's first column's value. Duplicate keys are discarded.
3088+
* Default OBJECT.
30863089
* @return array|object|null Database query results.
30873090
*/
30883091
public function get_results( $query = null, $output = OBJECT ) {

src/wp-includes/comment-template.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2159,7 +2159,7 @@ function _get_comment_reply_id( $post = null ) {
21592159
* @type bool $short_ping Whether to output short pings. Default false.
21602160
* @type bool $echo Whether to echo the output or return it. Default true.
21612161
* }
2162-
* @param WP_Comment[] $comments Optional. Array of WP_Comment objects.
2162+
* @param WP_Comment[] $comments Optional. Array of WP_Comment objects. Default null.
21632163
* @return void|string Void if 'echo' argument is true, or no comments to list.
21642164
* Otherwise, HTML list of comments.
21652165
*/

src/wp-includes/comment.php

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,13 @@ function check_comment( $author, $email, $url, $comment, $user_ip, $user_agent,
155155
* @since 4.1.0 Refactored to leverage WP_Comment_Query over a direct query.
156156
*
157157
* @param int $post_id The ID of the post.
158-
* @param array $args Optional. See WP_Comment_Query::__construct() for information on accepted arguments.
158+
* @param array $args {
159+
* Optional. See WP_Comment_Query::__construct() for information on accepted arguments.
160+
*
161+
* @type int $status Comment status to limit results by. Defaults to approved comments.
162+
* @type int $post_id Limit results to those affiliated with a given post ID.
163+
* @type string $order How to order retrieved comments. Default 'ASC'.
164+
* }
159165
* @return WP_Comment[]|int[]|int The approved comments, or number of comments if `$count`
160166
* argument is true.
161167
*/
@@ -236,7 +242,7 @@ function get_comment( $comment = null, $output = OBJECT ) {
236242
* @since 2.7.0
237243
*
238244
* @param string|array $args Optional. Array or string of arguments. See WP_Comment_Query::__construct()
239-
* for information on accepted arguments. Default empty.
245+
* for information on accepted arguments. Default empty string.
240246
* @return WP_Comment[]|int[]|int List of comments or number of found comments if `$count` argument is true.
241247
*/
242248
function get_comments( $args = '' ) {
@@ -449,7 +455,7 @@ function add_comment_meta( $comment_id, $meta_key, $meta_value, $unique = false
449455
* @param string $meta_key Metadata name.
450456
* @param mixed $meta_value Optional. Metadata value. If provided,
451457
* rows will only be removed that match the value.
452-
* Must be serializable if non-scalar. Default empty.
458+
* Must be serializable if non-scalar. Default empty string.
453459
* @return bool True on success, false on failure.
454460
*/
455461
function delete_comment_meta( $comment_id, $meta_key, $meta_value = '' ) {
@@ -465,7 +471,7 @@ function delete_comment_meta( $comment_id, $meta_key, $meta_value = '' ) {
465471
*
466472
* @param int $comment_id Comment ID.
467473
* @param string $key Optional. The meta key to retrieve. By default,
468-
* returns data for all keys.
474+
* returns data for all keys. Default empty string.
469475
* @param bool $single Optional. Whether to return a single value.
470476
* This parameter has no effect if `$key` is not specified.
471477
* Default false.
@@ -495,7 +501,7 @@ function get_comment_meta( $comment_id, $key = '', $single = false ) {
495501
* @param mixed $meta_value Metadata value. Must be serializable if non-scalar.
496502
* @param mixed $prev_value Optional. Previous value to check before updating.
497503
* If specified, only update existing metadata entries with
498-
* this value. Otherwise, update all entries. Default empty.
504+
* this value. Otherwise, update all entries. Default empty string.
499505
* @return int|bool Meta ID if the key didn't exist, true on successful update,
500506
* false on failure or if the value passed to the function
501507
* is the same as the one that is already in the database.
@@ -985,8 +991,10 @@ function separate_comments( &$comments ) {
985991
* @global WP_Query $wp_query WordPress Query object.
986992
*
987993
* @param WP_Comment[] $comments Optional. Array of WP_Comment objects. Defaults to `$wp_query->comments`.
988-
* @param int $per_page Optional. Comments per page.
989-
* @param bool $threaded Optional. Control over flat or threaded comments.
994+
* @param int $per_page Optional. Comments per page. Defaults to the value of `comments_per_page`
995+
* query var, option of the same name, or 1 (in that order).
996+
* @param bool $threaded Optional. Control over flat or threaded comments. Defaults to the value
997+
* of `thread_comments` option.
990998
* @return int Number of comment pages.
991999
*/
9921000
function get_comment_pages_count( $comments = null, $per_page = null, $threaded = null ) {

0 commit comments

Comments
 (0)