Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion packages/block-library/src/avatar/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function render_block_core_avatar( $attributes, $content, $block ) {
'class' => $image_classes,
)
);
if ( isset( $attributes['isLink'] ) && $attributes['isLink'] && isset( $comment->comment_author_url ) && '' !== $comment->comment_author_url ) {
if ( isset( $attributes['isLink'] ) && $attributes['isLink'] && '' !== $comment->comment_author_url ) {
$label = '';
if ( '_blank' === $attributes['linkTarget'] ) {
// translators: %s: Comment author name.
Expand Down
15 changes: 9 additions & 6 deletions packages/block-library/src/navigation/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ private static function get_inner_blocks_html( $attributes, $inner_blocks ) {
* @since 6.5.0
*
* @param array $attributes The block attributes.
* @return WP_Block_List Returns the inner blocks for the navigation block.
* @return WP_Block_List|null Returns the inner blocks for the navigation block, or null if the navigation post is not published.
*/
private static function get_inner_blocks_from_navigation_post( $attributes ) {
$navigation_post = get_post( $attributes['ref'] );
Expand Down Expand Up @@ -351,6 +351,8 @@ private static function get_inner_blocks_from_navigation_post( $attributes ) {
// context which could be refined.
return new WP_Block_List( $blocks, $attributes );
}

return null;
}

/**
Expand Down Expand Up @@ -802,10 +804,11 @@ private static function get_responsive_container_markup( $attributes, $inner_blo
$toggle_aria_label_close = $should_display_icon_label ? 'aria-label="' . __( 'Close menu' ) . '"' : ''; // Close button label.

// Add Interactivity API directives to the markup if needed.
$open_button_directives = '';
$responsive_container_directives = '';
$responsive_dialog_directives = '';
$close_button_directives = '';
$open_button_directives = '';
$responsive_container_directives = '';
$responsive_dialog_directives = '';
$responsive_container_content_directives = '';

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.

Good. PhpStorm's static analysis is also fixed by this. It was reporting:

Image

$close_button_directives = '';
if ( $is_interactive ) {
$open_button_directives = '
data-wp-on--click="actions.openMenuOnClick"
Expand Down Expand Up @@ -1465,7 +1468,7 @@ function block_core_navigation_block_tree_has_block_type( $blocks, $block_type,
}

// Recursively check inner blocks, skipping specified block types.
if ( ! in_array( $block->name, $skip_block_types, true ) && ! empty( $block->inner_blocks ) ) {
if ( ! in_array( $block->name, $skip_block_types, true ) && count( $block->inner_blocks ) > 0 ) {
if ( block_core_navigation_block_tree_has_block_type( $block->inner_blocks, $block_type, $skip_block_types ) ) {
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/playlist/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function render_block_core_playlist( $attributes, $content, $block ) {

// Parse inner blocks to extract track data.
// This approach avoids duplicating track data in the HTML output.
if ( ! empty( $block->inner_blocks ) ) {
if ( count( $block->inner_blocks ) > 0 ) {
foreach ( $block->inner_blocks as $inner_block ) {
if ( 'core/playlist-track' === $inner_block->name ) {
$track_attributes = $inner_block->attributes;
Expand Down
5 changes: 0 additions & 5 deletions packages/block-library/src/post-time-to-read/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ function block_core_post_time_to_read_word_count( $text, $type ) {
// Remove all HTML comments.
$text = preg_replace( $settings['html_comment_regexp'], '', $text );

// If a shortcode regular expression has been provided use it to remove shortcodes.
if ( ! empty( $settings['shortcodes_regexp'] ) ) {
$text = preg_replace( $settings['shortcodes_regexp'], "\n", $text );
}
Comment on lines -64 to -67

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.

I'm curious about the history of this if statement. It seems it was added in #72091 but not used? Should it have been added to the $settings array? cc @t-hamano

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This block was originally meant to count words via a new wp_word_count() function, which accepted a $settings parameter (including shortcodes). This code is a leftover from that. Since wp_word_count() was not shipped in core, #72091 moved the logic into a block-specific function without that parameter, so shortcodes_regexp is never set. This if statement can be safely removed.


// Normalize non-breaking space to a normal space.
$text = preg_replace( $settings['space_regexp'], ' ', $text );

Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/search/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ function render_block_core_search( $attributes ) {
if ( ! $show_button && ! empty( $color_classes ) ) {
$input_classes[] = $color_classes;
}
$is_expandable_searchfield = false;

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.

PhpStorm also identified the need for this:

Image

if ( $input->next_tag() ) {
$input->add_class( implode( ' ', $input_classes ) );
$input->set_attribute( 'id', $input_id );
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/term-template/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* @return string Returns the output of the term template.
*/
function render_block_core_term_template( $attributes, $content, $block ) {
if ( ! isset( $block->context ) || empty( $block->context['termQuery'] ) ) {
if ( empty( $block->context['termQuery'] ) ) {
return '';
}

Expand Down
54 changes: 0 additions & 54 deletions tools/phpstan/baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,6 @@ parameters:
count: 1
path: ../../lib/experimental/navigation-theme-opt-in.php

-
message: '#^Property WP_Comment\:\:\$comment_author_url \(string\) in isset\(\) is not nullable\.$#'
identifier: isset.property
count: 1
path: ../../packages/block-library/src/avatar/index.php

-
message: '#^Call to function is_array\(\) with array\<mixed\> will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
Expand All @@ -102,60 +96,12 @@ parameters:
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: '#^Property WP_Block\:\:\$inner_blocks \(WP_Block_List\) in empty\(\) is not falsy\.$#'
identifier: empty.property
count: 1
path: ../../packages/block-library/src/navigation/index.php

-
message: '#^Variable \$responsive_container_content_directives might not be defined\.$#'
identifier: variable.undefined
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
count: 1
path: ../../packages/block-library/src/playlist/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
count: 1
path: ../../packages/block-library/src/post-time-to-read/index.php

-
message: '#^Offset ''shortcodes_regexp'' 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'', \.\.\.\} in empty\(\) does not exist\.$#'
identifier: empty.offset
count: 1
path: ../../packages/block-library/src/post-time-to-read/index.php

-
message: '#^Variable \$is_expandable_searchfield might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../packages/block-library/src/search/index.php

-
message: '#^Right side of \|\| is always true\.$#'
identifier: booleanOr.rightAlwaysTrue
count: 1
path: ../../packages/block-library/src/template-part/index.php

-
message: '#^Property WP_Block\:\:\$context \(array\) in isset\(\) is not nullable\.$#'
identifier: isset.property
count: 1
path: ../../packages/block-library/src/term-template/index.php

-
message: '#^Unsafe usage of new static\(\)\.$#'
identifier: new.static
Expand Down
Loading