Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions packages/block-library/src/comment-date/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,26 @@ function render_block_core_comment_date( $attributes, $content, $block ) {
return '';
}

$datetime = get_comment_date( 'c', $comment );
if ( false === $datetime ) {
return '';
}

$classes = ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) ? 'has-link-color' : '';

$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) );
if ( isset( $attributes['format'] ) && 'human-diff' === $attributes['format'] ) {
$timestamp = get_comment_date( 'U', $comment );
if ( false === $timestamp ) {
return '';
}
// translators: %s: human-readable time difference.
$formatted_date = sprintf( __( '%s ago' ), human_time_diff( get_comment_date( 'U', $comment ) ) );
$formatted_date = sprintf( __( '%s ago' ), human_time_diff( $timestamp ) );
} else {
$formatted_date = get_comment_date( empty( $attributes['format'] ) ? '' : $attributes['format'], $comment );
if ( false === $formatted_date ) {
return '';
}
}
$link = get_comment_link( $comment );

Expand All @@ -43,7 +55,7 @@ function render_block_core_comment_date( $attributes, $content, $block ) {
return sprintf(
'<div %1$s><time datetime="%2$s">%3$s</time></div>',
$wrapper_attributes,
esc_attr( get_comment_date( 'c', $comment ) ),
esc_attr( $datetime ),
$formatted_date
);
}
Expand Down
6 changes: 3 additions & 3 deletions packages/block-library/src/gallery/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -463,9 +463,9 @@ function block_core_gallery_render_dynamic_image( $attachment_id, $attributes, $
*
* @since 6.0.0
*
* @param array $attributes Attributes of the block being rendered.
* @param string $content Content of the block being rendered.
* @param array $block The block instance being rendered.
* @param array $attributes Attributes of the block being rendered.
* @param string $content Content of the block being rendered.
* @param WP_Block $block The block instance being rendered.
* @return string The content of the block being rendered.
*/
function block_core_gallery_render( $attributes, $content, $block ) {
Expand Down
16 changes: 10 additions & 6 deletions packages/block-library/src/latest-comments/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function render_block_core_latest_comments( $attributes ) {
$list_items_markup .= '<footer class="wp-block-latest-comments__comment-meta">';
$author_url = get_comment_author_url( $comment );
if ( empty( $author_url ) && ! empty( $comment->user_id ) ) {
$author_url = get_author_posts_url( $comment->user_id );
$author_url = get_author_posts_url( (int) $comment->user_id );

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense, because user_id is a numeric-string.

}

$author_markup = '';
Expand All @@ -112,11 +112,15 @@ function render_block_core_latest_comments( $attributes ) {
);

if ( $attributes['displayDate'] ) {
$list_items_markup .= sprintf(
'<time datetime="%1$s" class="wp-block-latest-comments__comment-date">%2$s</time>',
esc_attr( get_comment_date( 'c', $comment ) ),
date_i18n( get_option( 'date_format' ), get_comment_date( 'U', $comment ) )
);
$datetime = get_comment_date( 'c', $comment );
$timestamp = get_comment_date( 'U', $comment );
if ( false !== $datetime && false !== $timestamp ) {
$list_items_markup .= sprintf(
'<time datetime="%1$s" class="wp-block-latest-comments__comment-date">%2$s</time>',
esc_attr( $datetime ),
date_i18n( get_option( 'date_format' ), $timestamp )
);
}
}
$list_items_markup .= '</footer>';
if ( 'full' === $display_content ) {
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/navigation/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -1910,7 +1910,7 @@ static function ( $a, $b ) {
* @deprecated 6.3.0 Use WP_Navigation_Fallback::get_classic_menu_fallback_blocks() instead.
*
* @param object $classic_nav_menu WP_Term The classic navigation object to convert.
* @return array the normalized parsed blocks.
* @return string The serialized blocks of the classic menu, or an empty string if it has no items.
*/
function block_core_navigation_get_classic_menu_fallback_blocks( $classic_nav_menu ) {

Expand Down
5 changes: 4 additions & 1 deletion packages/block-library/src/post-time-to-read/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
* @param string $text Text to count elements in.
* @param string $type The type of count. Accepts 'words', 'characters_excluding_spaces', or 'characters_including_spaces'.
*
* @return string The rendered word count.
* @return int The number of words or characters in the text.
Comment thread
westonruter marked this conversation as resolved.
Resolved
*
* @phpstan-param 'words'|'characters_excluding_spaces'|'characters_including_spaces' $type
* @phpstan-return int<0, max>
*/
function block_core_post_time_to_read_word_count( $text, $type ) {
$settings = array(
Expand Down
15 changes: 9 additions & 6 deletions packages/block-library/src/search/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,12 +290,15 @@ function classnames_for_block_core_search( $attributes ) {
*
* @since 6.1.0
*
* @param array $attributes The block attributes.
* @param string $property Border property to generate rule for e.g. width or color.
* @param string $side Optional side border. The dictates the value retrieved and final CSS property.
* @param array $wrapper_styles Current collection of wrapper styles.
* @param array $button_styles Current collection of button styles.
* @param array $input_styles Current collection of input styles.
* @param array $attributes The block attributes.
* @param string $property Border property to generate rule for e.g. width or color.
* @param string|null $side Side of the border to style, or null for all sides. This dictates the value
* retrieved and the final CSS property.
* @param array $wrapper_styles Current collection of wrapper styles.
* @param array $button_styles Current collection of button styles.
* @param array $input_styles Current collection of input styles.
*
* @phpstan-param 'top'|'right'|'bottom'|'left'|null $side
*/
function apply_block_core_search_border_style( $attributes, $property, $side, &$wrapper_styles, &$button_styles, &$input_styles ) {
$is_button_inside = isset( $attributes['buttonPosition'] ) && 'button-inside' === $attributes['buttonPosition'];
Expand Down
72 changes: 0 additions & 72 deletions tools/phpstan/baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -84,36 +84,6 @@ parameters:
count: 1
path: ../../packages/block-library/src/avatar/index.php

-
message: '#^Parameter \#1 \$from of function human_time_diff expects int, string given\.$#'
identifier: argument.type
count: 1
path: ../../packages/block-library/src/comment-date/index.php

-
message: '#^Cannot access property \$context on array\.$#'
identifier: property.nonObject
count: 3
path: ../../packages/block-library/src/gallery/index.php

-
message: '#^Parameter \#2 \$block of function block_core_gallery_resolve_dynamic_source expects WP_Block, array given\.$#'
identifier: argument.type
count: 1
path: ../../packages/block-library/src/gallery/index.php

-
message: '#^Parameter \#1 \$author_id of function get_author_posts_url expects int, string given\.$#'
identifier: argument.type
count: 1
path: ../../packages/block-library/src/latest-comments/index.php

-
message: '#^Parameter \#2 \$timestamp_with_offset of function date_i18n expects bool\|int, string given\.$#'
identifier: argument.type
count: 1
path: ../../packages/block-library/src/latest-comments/index.php

-
message: '#^Call to function is_array\(\) with array\<mixed\> will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
Expand All @@ -132,24 +102,12 @@ parameters:
count: 1
path: ../../packages/block-library/src/navigation/index.php

-
message: '#^Function block_core_navigation_get_classic_menu_fallback_blocks\(\) should return array but returns string\.$#'
identifier: return.type
count: 1
path: ../../packages/block-library/src/navigation/index.php

-
message: '#^Method WP_Navigation_Block_Renderer\:\:get_inner_blocks_from_navigation_post\(\) should return WP_Block_List but return statement is missing\.$#'
identifier: return.missing
count: 1
path: ../../packages/block-library/src/navigation/index.php

-
message: '#^Parameter \#1 \$postarr of function wp_insert_post expects array\{ID\?\: int, post_author\?\: int, post_date\?\: string, post_date_gmt\?\: string, post_content\?\: string, post_content_filtered\?\: string, post_title\?\: string, post_excerpt\?\: string, \.\.\.\}, array\{post_content\: non\-empty\-array, post_title\: mixed, post_name\: mixed, post_status\: ''publish'', post_type\: ''wp_navigation''\} given\.$#'
identifier: argument.type
count: 1
path: ../../packages/block-library/src/navigation/index.php

-
message: '#^Property WP_Block\:\:\$inner_blocks \(WP_Block_List\) in empty\(\) is not falsy\.$#'
identifier: empty.property
Expand All @@ -168,18 +126,6 @@ parameters:
count: 1
path: ../../packages/block-library/src/playlist/index.php

-
message: '#^Function block_core_post_time_to_read_word_count\(\) should return string but returns int\.$#'
identifier: return.type
count: 1
path: ../../packages/block-library/src/post-time-to-read/index.php

-
message: '#^Function block_core_post_time_to_read_word_count\(\) should return string but returns int\<0, max\>\.$#'
identifier: return.type
count: 1
path: ../../packages/block-library/src/post-time-to-read/index.php

-
message: '#^Offset ''shortcodes_regexp'' does not exist on array\{html_regexp\: ''/\<\\\\/\?\[a\-z\]\[\^\>\]\*\?\>/i'', html_comment_regexp\: ''/\<\!\-\-\[\\\\s\\\\S\]\*\?\-\-\>/'', space_regexp\: ''/&nbsp;\|&\#160;/i'', html_entity_regexp\: ''/&\\\\S\+\?;/'', connector_regexp\: ''/\-\-\|\\\\x\{2014\}/u'', remove_regexp\: ''/\[\\\\x\{0021\}\-\\\\x\{0040\}…'', astral_regexp\: ''/\[\\\\x\{010000\}\-\\\\x…'', words_regexp\: ''/\\\\S\\\\s\+/u'', \.\.\.\}\.$#'
identifier: offsetAccess.notFound
Expand All @@ -192,24 +138,6 @@ parameters:
count: 1
path: ../../packages/block-library/src/post-time-to-read/index.php

-
message: '#^Parameter \#1 \$number of function number_format_i18n expects float, string given\.$#'
identifier: argument.type
count: 2
path: ../../packages/block-library/src/post-time-to-read/index.php

-
message: '#^Parameter \#3 \$number of function _n expects int, string given\.$#'
identifier: argument.type
count: 2
path: ../../packages/block-library/src/post-time-to-read/index.php

-
message: '#^Parameter \#3 \$side of function apply_block_core_search_border_style expects string, null given\.$#'
identifier: argument.type
count: 1
path: ../../packages/block-library/src/search/index.php

-
message: '#^Variable \$is_expandable_searchfield might not be defined\.$#'
identifier: variable.undefined
Expand Down
8 changes: 4 additions & 4 deletions tools/phpstan/wordpress-stubs/composer.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "php-stubs/wordpress-stubs",
"version": "7.2.0-beta3.65220",
"description": "WordPress stubs generated from https://github.com/WordPress/wordpress-develop/commit/140b182252392fb12733a9c7cc7d5136a522ba43 (r65220), in place of the released package.",
"version": "7.2.0-beta4.65263",
"description": "WordPress stubs generated from https://github.com/WordPress/wordpress-develop/commit/a87c255146a7d74038ad20133db10ffd63f5cb50 (r65263), in place of the released package.",
"license": "GPL-2.0-or-later",
"extra": {
"source": {
"commit": "140b182252392fb12733a9c7cc7d5136a522ba43",
"revision": 65220
"commit": "a87c255146a7d74038ad20133db10ffd63f5cb50",
"revision": 65263
}
}
}
Loading