Skip to content

Commit fbd1a8e

Browse files
westonruterclaude
andcommitted
Date/Time: Pass the weekday number to WP_Locale::get_weekday() as an int in wp_date().
`DateTimeInterface::format( 'w' )` returns a string from `'0'` to `'6'`, which worked only because the string was coerced to an integer array key. Casting it to an int matches the `int<0, 6>` parameter type and removes the last `get_weekday()` entry from the `argument.type` PHPStan baseline. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 96af501 commit fbd1a8e

2 files changed

Lines changed: 1 addition & 6 deletions

File tree

‎src/wp-includes/functions.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ function wp_date( $format, $timestamp = null, $timezone = null ) {
269269
$new_format = '';
270270
$format_length = strlen( $format );
271271
$month = $wp_locale->get_month( $datetime->format( 'm' ) );
272-
$weekday = $wp_locale->get_weekday( $datetime->format( 'w' ) );
272+
$weekday = $wp_locale->get_weekday( (int) $datetime->format( 'w' ) );
273273

274274
for ( $i = 0; $i < $format_length; $i++ ) {
275275
switch ( $format[ $i ] ) {

‎tests/phpstan/baselines/argument.type.neon‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -903,11 +903,6 @@ parameters:
903903
identifier: argument.type
904904
count: 2
905905
path: ../../../src/wp-includes/functions.php
906-
-
907-
message: '#^Parameter \#1 \$weekday_number of method WP_Locale\:\:get_weekday\(\) expects int\<0, 6\>, ''0''\|''1''\|''2''\|''3''\|''4''\|''5''\|''6'' given\.$#'
908-
identifier: argument.type
909-
count: 1
910-
path: ../../../src/wp-includes/functions.php
911906
-
912907
message: '#^Parameter \#2 \$fallback_url of function wp_validate_redirect expects string, false given\.$#'
913908
identifier: argument.type

0 commit comments

Comments
 (0)