From 329df9b3909920abdeb655da0dffc8e757a44811 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Tue, 10 Dec 2024 10:24:50 +0100 Subject: [PATCH 1/2] Update non-nullable return type on get_breadcrumbs This method is a getter for the breadcrumbs property, an array value. --- src/wp-includes/html-api/class-wp-html-processor.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/html-api/class-wp-html-processor.php b/src/wp-includes/html-api/class-wp-html-processor.php index 7b156d8a605fa..d416204c659b5 100644 --- a/src/wp-includes/html-api/class-wp-html-processor.php +++ b/src/wp-includes/html-api/class-wp-html-processor.php @@ -1153,9 +1153,9 @@ public function step( $node_to_process = self::PROCESS_NEXT_NODE ): bool { * * @since 6.4.0 * - * @return string[]|null Array of tag names representing path to matched node, if matched, otherwise NULL. + * @return string[] Array of tag names representing path to matched node. */ - public function get_breadcrumbs(): ?array { + public function get_breadcrumbs(): array { return $this->breadcrumbs; } From 3ad6269e46f0a2f9d0ac6c6a96251b105806864b Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Tue, 10 Dec 2024 10:26:17 +0100 Subject: [PATCH 2/2] Remove stale todo comment This comment mentions using a generator for breadcrumbs, but breadcrumbs are no longer calculated on the fly, so the comment is outdated. --- src/wp-includes/html-api/class-wp-html-processor.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/wp-includes/html-api/class-wp-html-processor.php b/src/wp-includes/html-api/class-wp-html-processor.php index d416204c659b5..371b78895801e 100644 --- a/src/wp-includes/html-api/class-wp-html-processor.php +++ b/src/wp-includes/html-api/class-wp-html-processor.php @@ -1141,11 +1141,7 @@ public function step( $node_to_process = self::PROCESS_NEXT_NODE ): bool { * Breadcrumbs start at the outermost parent and descend toward the matched element. * They always include the entire path from the root HTML node to the matched element. * - * @todo It could be more efficient to expose a generator-based version of this function - * to avoid creating the array copy on tag iteration. If this is done, it would likely - * be more useful to walk up the stack when yielding instead of starting at the top. - * - * Example + * Example: * * $processor = WP_HTML_Processor::create_fragment( '

' ); * $processor->next_tag( 'IMG' );