Skip to content

Commit eef6fb2

Browse files
Docs: Add missing null to $post parameter types in various functions.
Props apermo. Fixes #64645. git-svn-id: https://develop.svn.wordpress.org/trunk@61649 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 9004673 commit eef6fb2

9 files changed

Lines changed: 54 additions & 54 deletions

File tree

src/wp-includes/category-template.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,7 +1487,7 @@ function the_terms( $post_id, $taxonomy, $before = '', $sep = ', ', $after = ''
14871487
*
14881488
* @param string|int|array $category Optional. The category name/term_id/slug,
14891489
* or an array of them to check for. Default empty.
1490-
* @param int|WP_Post $post Optional. Post to check. Defaults to the current post.
1490+
* @param int|WP_Post|null $post Optional. Post to check. Defaults to the current post.
14911491
* @return bool True if the current post has any of the given categories
14921492
* (or any category, if no category specified). False otherwise.
14931493
*/
@@ -1514,7 +1514,7 @@ function has_category( $category = '', $post = null ) {
15141514
*
15151515
* @param string|int|array $tag Optional. The tag name/term_id/slug,
15161516
* or an array of them to check for. Default empty.
1517-
* @param int|WP_Post $post Optional. Post to check. Defaults to the current post.
1517+
* @param int|WP_Post|null $post Optional. Post to check. Defaults to the current post.
15181518
* @return bool True if the current post has any of the given tags
15191519
* (or any tag, if no tag specified). False otherwise.
15201520
*/
@@ -1535,7 +1535,7 @@ function has_tag( $tag = '', $post = null ) {
15351535
* @param string|int|array $term Optional. The term name/term_id/slug,
15361536
* or an array of them to check for. Default empty.
15371537
* @param string $taxonomy Optional. Taxonomy name. Default empty.
1538-
* @param int|WP_Post $post Optional. Post to check. Defaults to the current post.
1538+
* @param int|WP_Post|null $post Optional. Post to check. Defaults to the current post.
15391539
* @return bool True if the current post has any of the given terms
15401540
* (or any term, if no term specified). False otherwise.
15411541
*/

src/wp-includes/comment-template.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2157,8 +2157,8 @@ function comment_form_title( $no_reply_text = false, $reply_text = false, $link_
21572157
*
21582158
* @access private
21592159
*
2160-
* @param int|WP_Post $post The post the comment is being displayed for.
2161-
* Defaults to the current global post.
2160+
* @param int|WP_Post|null $post The post the comment is being displayed for.
2161+
* Defaults to the current global post.
21622162
* @return int Comment's reply to ID.
21632163
*/
21642164
function _get_comment_reply_id( $post = null ) {

src/wp-includes/embed.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ function wp_maybe_enqueue_oembed_host_js( $html ) {
413413
*
414414
* @since 4.4.0
415415
*
416-
* @param int|WP_Post $post Optional. Post ID or object. Defaults to the current post.
416+
* @param int|WP_Post|null $post Optional. Post ID or object. Defaults to the current post.
417417
* @return string|false The post embed URL on success, false if the post doesn't exist.
418418
*/
419419
function get_post_embed_url( $post = null ) {
@@ -482,9 +482,9 @@ function get_oembed_endpoint_url( $permalink = '', $format = 'json' ) {
482482
*
483483
* @since 4.4.0
484484
*
485-
* @param int $width The width for the response.
486-
* @param int $height The height for the response.
487-
* @param int|WP_Post $post Optional. Post ID or object. Default is global `$post`.
485+
* @param int $width The width for the response.
486+
* @param int $height The height for the response.
487+
* @param int|WP_Post|null $post Optional. Post ID or object. Default is global `$post`.
488488
* @return string|false Embed code on success, false if post doesn't exist.
489489
*/
490490
function get_post_embed_html( $width, $height, $post = null ) {

src/wp-includes/general-template.php

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2716,8 +2716,8 @@ function the_date( $format = '', $before = '', $after = '', $display = true ) {
27162716
*
27172717
* @since 3.0.0
27182718
*
2719-
* @param string $format Optional. PHP date format. Defaults to the 'date_format' option.
2720-
* @param int|WP_Post $post Optional. Post ID or WP_Post object. Default current post.
2719+
* @param string $format Optional. PHP date format. Defaults to the 'date_format' option.
2720+
* @param int|WP_Post|null $post Optional. Post ID or WP_Post object. Default current post.
27212721
* @return string|int|false Date the current post was written. False on failure.
27222722
*/
27232723
function get_the_date( $format = '', $post = null ) {
@@ -2782,8 +2782,8 @@ function the_modified_date( $format = '', $before = '', $after = '', $display =
27822782
* @since 2.1.0
27832783
* @since 4.6.0 Added the `$post` parameter.
27842784
*
2785-
* @param string $format Optional. PHP date format. Defaults to the 'date_format' option.
2786-
* @param int|WP_Post $post Optional. Post ID or WP_Post object. Default current post.
2785+
* @param string $format Optional. PHP date format. Defaults to the 'date_format' option.
2786+
* @param int|WP_Post|null $post Optional. Post ID or WP_Post object. Default current post.
27872787
* @return string|int|false Date the current post was modified. False on failure.
27882788
*/
27892789
function get_the_modified_date( $format = '', $post = null ) {
@@ -2838,10 +2838,10 @@ function the_time( $format = '' ) {
28382838
*
28392839
* @since 1.5.0
28402840
*
2841-
* @param string $format Optional. Format to use for retrieving the time the post
2842-
* was written. Accepts 'G', 'U', or PHP date format.
2843-
* Defaults to the 'time_format' option.
2844-
* @param int|WP_Post $post Post ID or post object. Default is global `$post` object.
2841+
* @param string $format Optional. Format to use for retrieving the time the post
2842+
* was written. Accepts 'G', 'U', or PHP date format.
2843+
* Defaults to the 'time_format' option.
2844+
* @param int|WP_Post|null $post Post ID or post object. Default is global `$post` object.
28452845
* @return string|int|false Formatted date string or Unix timestamp if `$format` is 'U' or 'G'.
28462846
* False on failure.
28472847
*/
@@ -2874,11 +2874,11 @@ function get_the_time( $format = '', $post = null ) {
28742874
*
28752875
* @since 2.0.0
28762876
*
2877-
* @param string $format Optional. Format to use for retrieving the time the post
2878-
* was written. Accepts 'G', 'U', or PHP date format. Default 'U'.
2879-
* @param bool $gmt Optional. Whether to retrieve the GMT time. Default false.
2880-
* @param int|WP_Post $post Post ID or post object. Default is global `$post` object.
2881-
* @param bool $translate Whether to translate the time string. Default false.
2877+
* @param string $format Optional. Format to use for retrieving the time the post
2878+
* was written. Accepts 'G', 'U', or PHP date format. Default 'U'.
2879+
* @param bool $gmt Optional. Whether to retrieve the GMT time. Default false.
2880+
* @param int|WP_Post|null $post Post ID or post object. Default is global `$post` object.
2881+
* @param bool $translate Whether to translate the time string. Default false.
28822882
* @return string|int|false Formatted date string or Unix timestamp if `$format` is 'U' or 'G'.
28832883
* False on failure.
28842884
*/
@@ -2938,11 +2938,11 @@ function get_post_time( $format = 'U', $gmt = false, $post = null, $translate =
29382938
*
29392939
* @since 5.3.0
29402940
*
2941-
* @param int|WP_Post $post Optional. Post ID or post object. Default is global `$post` object.
2942-
* @param string $field Optional. Published or modified time to use from database. Accepts 'date' or 'modified'.
2943-
* Default 'date'.
2944-
* @param string $source Optional. Local or UTC time to use from database. Accepts 'local' or 'gmt'.
2945-
* Default 'local'.
2941+
* @param int|WP_Post|null $post Optional. Post ID or post object. Default is global `$post` object.
2942+
* @param string $field Optional. Published or modified time to use from database. Accepts 'date' or 'modified'.
2943+
* Default 'date'.
2944+
* @param string $source Optional. Local or UTC time to use from database. Accepts 'local' or 'gmt'.
2945+
* Default 'local'.
29462946
* @return DateTimeImmutable|false Time object on success, false on failure.
29472947
*/
29482948
function get_post_datetime( $post = null, $field = 'date', $source = 'local' ) {
@@ -2983,9 +2983,9 @@ function get_post_datetime( $post = null, $field = 'date', $source = 'local' ) {
29832983
*
29842984
* @since 5.3.0
29852985
*
2986-
* @param int|WP_Post $post Optional. Post ID or post object. Default is global `$post` object.
2987-
* @param string $field Optional. Published or modified time to use from database. Accepts 'date' or 'modified'.
2988-
* Default 'date'.
2986+
* @param int|WP_Post|null $post Optional. Post ID or post object. Default is global `$post` object.
2987+
* @param string $field Optional. Published or modified time to use from database. Accepts 'date' or 'modified'.
2988+
* Default 'date'.
29892989
* @return int|false Unix timestamp on success, false on failure.
29902990
*/
29912991
function get_post_timestamp( $post = null, $field = 'date' ) {
@@ -3026,10 +3026,10 @@ function the_modified_time( $format = '' ) {
30263026
* @since 2.0.0
30273027
* @since 4.6.0 Added the `$post` parameter.
30283028
*
3029-
* @param string $format Optional. Format to use for retrieving the time the post
3030-
* was modified. Accepts 'G', 'U', or PHP date format.
3031-
* Defaults to the 'time_format' option.
3032-
* @param int|WP_Post $post Optional. Post ID or WP_Post object. Default current post.
3029+
* @param string $format Optional. Format to use for retrieving the time the post
3030+
* was modified. Accepts 'G', 'U', or PHP date format.
3031+
* Defaults to the 'time_format' option.
3032+
* @param int|WP_Post|null $post Optional. Post ID or WP_Post object. Default current post.
30333033
* @return string|int|false Formatted date string or Unix timestamp. False on failure.
30343034
*/
30353035
function get_the_modified_time( $format = '', $post = null ) {
@@ -3063,11 +3063,11 @@ function get_the_modified_time( $format = '', $post = null ) {
30633063
*
30643064
* @since 2.0.0
30653065
*
3066-
* @param string $format Optional. Format to use for retrieving the time the post
3067-
* was modified. Accepts 'G', 'U', or PHP date format. Default 'U'.
3068-
* @param bool $gmt Optional. Whether to retrieve the GMT time. Default false.
3069-
* @param int|WP_Post $post Post ID or post object. Default is global `$post` object.
3070-
* @param bool $translate Whether to translate the time string. Default false.
3066+
* @param string $format Optional. Format to use for retrieving the time the post
3067+
* was modified. Accepts 'G', 'U', or PHP date format. Default 'U'.
3068+
* @param bool $gmt Optional. Whether to retrieve the GMT time. Default false.
3069+
* @param int|WP_Post|null $post Post ID or post object. Default is global `$post` object.
3070+
* @param bool $translate Whether to translate the time string. Default false.
30713071
* @return string|int|false Formatted date string or Unix timestamp if `$format` is 'U' or 'G'.
30723072
* False on failure.
30733073
*/

src/wp-includes/link-template.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ function permalink_anchor( $mode = 'id' ) {
9494
*
9595
* @since 5.7.0
9696
*
97-
* @param WP_Post|int|null $post Optional. Post ID or post object. Defaults to global $post.
97+
* @param int|WP_Post|null $post Optional. Post ID or post object. Defaults to global $post.
9898
* @param bool|null $sample Optional. Whether to force consideration based on sample links.
9999
* If omitted, a sample link is generated if a post object is passed
100100
* with the filter property set to 'sample'.

src/wp-includes/ms-blogs.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -904,9 +904,9 @@ function _update_posts_count_on_delete( $post_id, $post ) {
904904
* @since 4.0.0
905905
* @since 4.9.0 Added the `$post` parameter.
906906
*
907-
* @param string $new_status The status the post is changing to.
908-
* @param string $old_status The status the post is changing from.
909-
* @param WP_Post $post Post object
907+
* @param string $new_status The status the post is changing to.
908+
* @param string $old_status The status the post is changing from.
909+
* @param WP_Post|null $post Post object.
910910
*/
911911
function _update_posts_count_on_transition_post_status( $new_status, $old_status, $post = null ) {
912912
if ( $new_status === $old_status ) {

src/wp-includes/post-template.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ function the_excerpt() {
407407
* @since 0.71
408408
* @since 4.5.0 Introduced the `$post` parameter.
409409
*
410-
* @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
410+
* @param int|WP_Post|null $post Optional. Post ID or WP_Post object. Default is global $post.
411411
* @return string Post excerpt.
412412
*/
413413
function get_the_excerpt( $post = null ) {
@@ -458,9 +458,9 @@ function has_excerpt( $post = 0 ) {
458458
*
459459
* @since 2.7.0
460460
*
461-
* @param string|string[] $css_class Optional. One or more classes to add to the class list.
462-
* Default empty.
463-
* @param int|WP_Post $post Optional. Post ID or post object. Defaults to the global `$post`.
461+
* @param string|string[] $css_class Optional. One or more classes to add to the class list.
462+
* Default empty.
463+
* @param int|WP_Post|null $post Optional. Post ID or post object. Defaults to the global `$post`.
464464
*/
465465
function post_class( $css_class = '', $post = null ) {
466466
// Separates classes with a single space, collates classes for post DIV.
@@ -486,9 +486,9 @@ function post_class( $css_class = '', $post = null ) {
486486
* @since 2.7.0
487487
* @since 4.2.0 Custom taxonomy class names were added.
488488
*
489-
* @param string|string[] $css_class Optional. Space-separated string or array of class names
490-
* to add to the class list. Default empty.
491-
* @param int|WP_Post $post Optional. Post ID or post object.
489+
* @param string|string[] $css_class Optional. Space-separated string or array of class names
490+
* to add to the class list. Default empty.
491+
* @param int|WP_Post|null $post Optional. Post ID or post object.
492492
* @return string[] Array of class names.
493493
*/
494494
function get_post_class( $css_class = '', $post = null ) {
@@ -1883,7 +1883,7 @@ function is_page_template( $template = '' ) {
18831883
* @since 3.4.0
18841884
* @since 4.7.0 Now works with any post type, not just pages.
18851885
*
1886-
* @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
1886+
* @param int|WP_Post|null $post Optional. Post ID or WP_Post object. Default is global $post.
18871887
* @return string|false Page template filename. Returns an empty string when the default page template
18881888
* is in use. Returns false if the post does not exist.
18891889
*/

src/wp-includes/post.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,7 @@ function get_post_field( $field, $post = null, $context = 'display' ) {
12231223
*
12241224
* @since 2.0.0
12251225
*
1226-
* @param int|WP_Post $post Optional. Post ID or post object. Defaults to global $post.
1226+
* @param int|WP_Post|null $post Optional. Post ID or post object. Defaults to global $post.
12271227
* @return string|false The mime type on success, false on failure.
12281228
*/
12291229
function get_post_mime_type( $post = null ) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,8 @@ class="media-widget-instance-property"
360360
*
361361
* @since 4.8.0
362362
*
363-
* @param array $states An array of media states.
364-
* @param WP_Post $post The current attachment object.
363+
* @param array $states An array of media states.
364+
* @param WP_Post|null $post The current attachment object.
365365
* @return array
366366
*/
367367
public function display_media_state( $states, $post = null ) {

0 commit comments

Comments
 (0)