- Timestamp:
- 07/19/2024 11:42:14 PM (18 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/html-api/class-wp-html-open-elements.php
r58742 r58769 59 59 * @since 6.6.0 60 60 * 61 * @var Closure 61 * @var Closure|null 62 62 */ 63 63 private $pop_handler = null; … … 70 70 * @since 6.6.0 71 71 * 72 * @var Closure 72 * @var Closure|null 73 73 */ 74 74 private $push_handler = null; … … 84 84 * @param Closure $handler The handler function. 85 85 */ 86 public function set_pop_handler( Closure $handler ) {86 public function set_pop_handler( Closure $handler ): void { 87 87 $this->pop_handler = $handler; 88 88 } … … 98 98 * @param Closure $handler The handler function. 99 99 */ 100 public function set_push_handler( Closure $handler ) {100 public function set_push_handler( Closure $handler ): void { 101 101 $this->push_handler = $handler; 102 102 } … … 110 110 * @return bool Whether the referenced node is in the stack of open elements. 111 111 */ 112 public function contains_node( $token ){112 public function contains_node( WP_HTML_Token $token ): bool { 113 113 foreach ( $this->walk_up() as $item ) { 114 114 if ( $token->bookmark_name === $item->bookmark_name ) { … … 127 127 * @return int How many node are in the stack of open elements. 128 128 */ 129 public function count() {129 public function count(): int { 130 130 return count( $this->stack ); 131 131 } … … 139 139 * @return WP_HTML_Token|null Last node in the stack of open elements, if one exists, otherwise null. 140 140 */ 141 public function current_node() {141 public function current_node(): ?WP_HTML_Token { 142 142 $current_node = end( $this->stack ); 143 143 … … 198 198 * @return bool Whether the element was found in a specific scope. 199 199 */ 200 public function has_element_in_specific_scope( $tag_name, $termination_list ){200 public function has_element_in_specific_scope( string $tag_name, $termination_list ): bool { 201 201 foreach ( $this->walk_up() as $node ) { 202 202 if ( $node->node_name === $tag_name ) { … … 234 234 * @return bool Whether given element is in scope. 235 235 */ 236 public function has_element_in_scope( $tag_name ){236 public function has_element_in_scope( string $tag_name ): bool { 237 237 return $this->has_element_in_specific_scope( 238 238 $tag_name, … … 261 261 * @return bool Whether given element is in scope. 262 262 */ 263 public function has_element_in_list_item_scope( $tag_name ){263 public function has_element_in_list_item_scope( string $tag_name ): bool { 264 264 return $this->has_element_in_specific_scope( 265 265 $tag_name, … … 282 282 * @return bool Whether given element is in scope. 283 283 */ 284 public function has_element_in_button_scope( $tag_name ){284 public function has_element_in_button_scope( string $tag_name ): bool { 285 285 return $this->has_element_in_specific_scope( $tag_name, array( 'BUTTON' ) ); 286 286 } … … 298 298 * @return bool Whether given element is in scope. 299 299 */ 300 public function has_element_in_table_scope( $tag_name ){300 public function has_element_in_table_scope( string $tag_name ): bool { 301 301 throw new WP_HTML_Unsupported_Exception( 'Cannot process elements depending on table scope.' ); 302 302 … … 324 324 * @return bool Whether the given element is in SELECT scope. 325 325 */ 326 public function has_element_in_select_scope( $tag_name ){326 public function has_element_in_select_scope( string $tag_name ): bool { 327 327 foreach ( $this->walk_up() as $node ) { 328 328 if ( $node->node_name === $tag_name ) { … … 350 350 * @return bool Whether a P is in BUTTON scope. 351 351 */ 352 public function has_p_in_button_scope() {352 public function has_p_in_button_scope(): bool { 353 353 return $this->has_p_in_button_scope; 354 354 } … … 363 363 * @return bool Whether a node was popped off of the stack. 364 364 */ 365 public function pop() {365 public function pop(): bool { 366 366 $item = array_pop( $this->stack ); 367 367 if ( null === $item ) { … … 388 388 * @return bool Whether a tag of the given name was found and popped off of the stack of open elements. 389 389 */ 390 public function pop_until( $tag_name ){390 public function pop_until( string $tag_name ): bool { 391 391 foreach ( $this->walk_up() as $item ) { 392 392 if ( 'context-node' === $item->bookmark_name ) { … … 420 420 * @param WP_HTML_Token $stack_item Item to add onto stack. 421 421 */ 422 public function push( $stack_item ){422 public function push( WP_HTML_Token $stack_item ): void { 423 423 $this->stack[] = $stack_item; 424 424 $this->after_element_push( $stack_item ); … … 433 433 * @return bool Whether the node was found and removed from the stack of open elements. 434 434 */ 435 public function remove_node( $token ){435 public function remove_node( WP_HTML_Token $token ): bool { 436 436 if ( 'context-node' === $token->bookmark_name ) { 437 437 return false; … … 503 503 * if provided and if the node exists. 504 504 */ 505 public function walk_up( $above_this_node = null ) {505 public function walk_up( ?WP_HTML_Token $above_this_node = null ) { 506 506 $has_found_node = null === $above_this_node; 507 507 … … 535 535 * @param WP_HTML_Token $item Element that was added to the stack of open elements. 536 536 */ 537 public function after_element_push( $item ){537 public function after_element_push( WP_HTML_Token $item ): void { 538 538 /* 539 539 * When adding support for new elements, expand this switch to trap … … 568 568 * @param WP_HTML_Token $item Element that was removed from the stack of open elements. 569 569 */ 570 public function after_element_pop( $item ){570 public function after_element_pop( WP_HTML_Token $item ): void { 571 571 /* 572 572 * When adding support for new elements, expand this switch to trap
Note: See TracChangeset
for help on using the changeset viewer.