[wp-trac] [WordPress Trac] #64522: Clarify expected behavior for invalid weekday values in WP_Locale::get_weekday()

WordPress Trac noreply at wordpress.org
Thu Jan 22 19:18:20 UTC 2026


#64522: Clarify expected behavior for invalid weekday values in
WP_Locale::get_weekday()
--------------------------+------------------------------
 Reporter:  shishir1      |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  I18N          |     Version:  4.5
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Comment (by westonruter):

 With PHPStan ($61175), static analysis would catch this via:

 {{{#!diff
 diff --git a/src/wp-includes/class-wp-locale.php b/src/wp-includes/class-
 wp-locale.php
 index 0fcb130b81..bd15992a5a 100644
 --- a/src/wp-includes/class-wp-locale.php
 +++ b/src/wp-includes/class-wp-locale.php
 @@ -262,7 +262,7 @@ class WP_Locale {
          *
          * @since 2.1.0
          *
 -        * @param int $weekday_number 0 for Sunday through 6 Saturday.
 +        * @param int<0, 6> $weekday_number 0 for Sunday through 6
 Saturday.
          * @return string Full translated weekday.
          */
         public function get_weekday( $weekday_number ) {
 }}}

 Also, the issue with an invalid argument being passed to `::get_weekday()`
 is also present for `::get_weekday_initial()`, `::get_weekday_abbrev()`,
 etc.

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


More information about the wp-trac mailing list