[wp-trac] [WordPress Trac] #41046: @global tag is not present in function wp_maybe_decline_date().

WordPress Trac noreply at wordpress.org
Mon May 13 20:20:26 UTC 2024


#41046: @global tag is not present in function wp_maybe_decline_date().
--------------------------+-----------------------------
 Reporter:  Dency         |       Owner:  SergeyBiryukov
     Type:  defect (bug)  |      Status:  closed
 Priority:  normal        |   Milestone:  4.9
Component:  I18N          |     Version:
 Severity:  normal        |  Resolution:  fixed
 Keywords:  has-patch     |     Focuses:  docs
--------------------------+-----------------------------

Comment (by vovakuznd):

 I noticed that the `wp_maybe_decline_date()` function in WordPress uses
 the global variable `$wp_locale`, but this is not documented in the
 function's comment block.

 In changeset 40911, the following was addressed:
 "I18N: Add @global entry for $wp_locale in wp_maybe_decline_date(). Props
 Dency. Fixes #41046."

 Could someone provide guidance on how to properly document the use of the
 global `$wp_locale` variable in this function's comment block?
 Additionally, what are the best practices for ensuring that all global
 variables used in a function are properly documented?

 Here is the relevant code snippet for context:

 ```php
 /**
  * Function description here.
  *
  * @global WP_Locale $wp_locale WordPress locale instance.
  */
 function wp_maybe_decline_date() {
     global $wp_locale;

     // Function implementation here.
 }
 ```

 Is this the correct way to add the `@global` entry for `$wp_locale`, and
 are there any other considerations I should be aware of when documenting
 global variables in WordPress functions?

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/41046#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list