Changeset 58769
- Timestamp:
- 07/19/2024 11:42:14 PM (5 months ago)
- Location:
- trunk/src/wp-includes
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-token-map.php
r58742 r58769 281 281 * @return WP_Token_Map|null Token map, unless unable to create it. 282 282 */ 283 public static function from_array( $mappings, $key_length = 2 ){283 public static function from_array( array $mappings, int $key_length = 2 ): ?WP_Token_Map { 284 284 $map = new WP_Token_Map(); 285 285 $map->key_length = $key_length; … … 329 329 usort( 330 330 $groups[ $group_key ], 331 static function ( $a, $b ){331 static function ( array $a, array $b ): int { 332 332 return self::longest_first_then_alphabetical( $a[0], $b[0] ); 333 333 } … … 386 386 * @return WP_Token_Map Map with precomputed data loaded. 387 387 */ 388 public static function from_precomputed_table( $state ) {388 public static function from_precomputed_table( $state ): ?WP_Token_Map { 389 389 $has_necessary_state = isset( 390 390 $state['storage_version'], … … 440 440 * @return bool Whether there's an entry for the given word in the map. 441 441 */ 442 public function contains( $word, $case_sensitivity = 'case-sensitive' ){442 public function contains( string $word, string $case_sensitivity = 'case-sensitive' ): bool { 443 443 $ignore_case = 'ascii-case-insensitive' === $case_sensitivity; 444 444 … … 528 528 * @return string|null Mapped value of lookup key if found, otherwise `null`. 529 529 */ 530 public function read_token( $text, $offset = 0, &$matched_token_byte_length = null, $case_sensitivity = 'case-sensitive' ){530 public function read_token( string $text, int $offset = 0, &$matched_token_byte_length = null, $case_sensitivity = 'case-sensitive' ): ?string { 531 531 $ignore_case = 'ascii-case-insensitive' === $case_sensitivity; 532 532 $text_length = strlen( $text ); … … 572 572 * Finds a match for a short word at the index. 573 573 * 574 * @since 6.6.0. 575 * 576 * @param string $text String in which to search for a lookup key. 577 * @param int $offset Optional. How many bytes into the string where the lookup key ought to start. Default 0. 578 * @param ?int &$matched_token_byte_length Optional. Holds byte-length of found lookup key if matched, otherwise not set. Default null. 579 * @param string $case_sensitivity Optional. Pass 'ascii-case-insensitive' to ignore ASCII case when matching. Default 'case-sensitive'. 574 * @since 6.6.0 575 * 576 * @param string $text String in which to search for a lookup key. 577 * @param int $offset Optional. How many bytes into the string where the lookup key ought to start. Default 0. 578 * @param int|null &$matched_token_byte_length Optional. Holds byte-length of found lookup key if matched, otherwise not set. Default null. 579 * @param string $case_sensitivity Optional. Pass 'ascii-case-insensitive' to ignore ASCII case when matching. Default 'case-sensitive'. 580 * 580 581 * @return string|null Mapped value of lookup key if found, otherwise `null`. 581 582 */ 582 private function read_small_token( $text, $offset, &$matched_token_byte_length, $case_sensitivity = 'case-sensitive' ){583 private function read_small_token( string $text, int $offset = 0, &$matched_token_byte_length = null, $case_sensitivity = 'case-sensitive' ): ?string { 583 584 $ignore_case = 'ascii-case-insensitive' === $case_sensitivity; 584 585 $small_length = strlen( $this->small_words ); … … 635 636 * @return array The lookup key/substitution values as an associate array. 636 637 */ 637 public function to_array() {638 public function to_array(): array { 638 639 $tokens = array(); 639 640 … … 697 698 * @return string Value which can be pasted into a PHP source file for quick loading of table. 698 699 */ 699 public function precomputed_php_source_table( $indent = "\t" ){700 public function precomputed_php_source_table( string $indent = "\t" ): string { 700 701 $i1 = $indent; 701 702 $i2 = $i1 . $indent; … … 802 803 * @return int -1 or lower if `$a` is less than `$b`; 1 or greater if `$a` is greater than `$b`, and 0 if they are equal. 803 804 */ 804 private static function longest_first_then_alphabetical( $a, $b ){805 private static function longest_first_then_alphabetical( string $a, string $b ): int { 805 806 if ( $a === $b ) { 806 807 return 0; -
trunk/src/wp-includes/html-api/class-wp-html-active-formatting-elements.php
r57209 r58769 52 52 * @return bool Whether the referenced node is in the stack of active formatting elements. 53 53 */ 54 public function contains_node( $token ) {54 public function contains_node( WP_HTML_Token $token ) { 55 55 foreach ( $this->walk_up() as $item ) { 56 56 if ( $token->bookmark_name === $item->bookmark_name ) { … … 96 96 * @param WP_HTML_Token $token Push this node onto the stack. 97 97 */ 98 public function push( $token ) {98 public function push( WP_HTML_Token $token ) { 99 99 /* 100 100 * > If there are already three elements in the list of active formatting elements after the last marker, … … 120 120 * @return bool Whether the node was found and removed from the stack of active formatting elements. 121 121 */ 122 public function remove_node( $token ) {122 public function remove_node( WP_HTML_Token $token ) { 123 123 foreach ( $this->walk_up() as $position_from_end => $item ) { 124 124 if ( $token->bookmark_name !== $item->bookmark_name ) { -
trunk/src/wp-includes/html-api/class-wp-html-decoder.php
r58613 r58769 32 32 * @return bool Whether the attribute value starts with the given string. 33 33 */ 34 public static function attribute_starts_with( $haystack, $search_text, $case_sensitivity = 'case-sensitive' ) {34 public static function attribute_starts_with( $haystack, $search_text, $case_sensitivity = 'case-sensitive' ): bool { 35 35 $search_length = strlen( $search_text ); 36 36 $loose_case = 'ascii-case-insensitive' === $case_sensitivity; … … 91 91 * @return string Decoded UTF-8 value of given text node. 92 92 */ 93 public static function decode_text_node( $text ) {93 public static function decode_text_node( $text ): string { 94 94 return static::decode( 'data', $text ); 95 95 } … … 111 111 * @return string Decoded UTF-8 value of given attribute value. 112 112 */ 113 public static function decode_attribute( $text ) {113 public static function decode_attribute( $text ): string { 114 114 return static::decode( 'attribute', $text ); 115 115 } … … 134 134 * @return string Decoded UTF-8 string. 135 135 */ 136 public static function decode( $context, $text ) {136 public static function decode( $context, $text ): string { 137 137 $decoded = ''; 138 138 $end = strlen( $text ); … … 422 422 * @return string Converted code point, or `�` if invalid. 423 423 */ 424 public static function code_point_to_utf8_bytes( $code_point ) {424 public static function code_point_to_utf8_bytes( $code_point ): string { 425 425 // Pre-check to ensure a valid code point. 426 426 if ( -
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 -
trunk/src/wp-includes/html-api/class-wp-html-processor-state.php
r58680 r58769 334 334 * @var WP_HTML_Open_Elements 335 335 */ 336 public $stack_of_open_elements = null;336 public $stack_of_open_elements; 337 337 338 338 /** … … 347 347 * @var WP_HTML_Active_Formatting_Elements 348 348 */ 349 public $active_formatting_elements = null;349 public $active_formatting_elements; 350 350 351 351 /** -
trunk/src/wp-includes/html-api/class-wp-html-processor.php
r58742 r58769 160 160 * @var WP_HTML_Processor_State 161 161 */ 162 private $state = null;162 private $state; 163 163 164 164 /** … … 209 209 * @since 6.4.0 210 210 * 211 * @var closure211 * @var Closure|null 212 212 */ 213 213 private $release_internal_bookmark_on_destruct = null; … … 369 369 370 370 $this->state->stack_of_open_elements->set_push_handler( 371 function ( WP_HTML_Token $token ) {371 function ( WP_HTML_Token $token ): void { 372 372 $is_virtual = ! isset( $this->state->current_token ) || $this->is_tag_closer(); 373 373 $same_node = isset( $this->state->current_token ) && $token->node_name === $this->state->current_token->node_name; … … 378 378 379 379 $this->state->stack_of_open_elements->set_pop_handler( 380 function ( WP_HTML_Token $token ) {380 function ( WP_HTML_Token $token ): void { 381 381 $is_virtual = ! isset( $this->state->current_token ) || ! $this->is_tag_closer(); 382 382 $same_node = isset( $this->state->current_token ) && $token->node_name === $this->state->current_token->node_name; … … 391 391 * exposing it to any public API. 392 392 */ 393 $this->release_internal_bookmark_on_destruct = function ( $name ){393 $this->release_internal_bookmark_on_destruct = function ( string $name ): void { 394 394 parent::release_bookmark( $name ); 395 395 }; … … 404 404 * 405 405 * @param string $message Explains support is missing in order to parse the current node. 406 *407 * @return mixed408 406 */ 409 407 private function bail( string $message ) { … … 458 456 * @return string|null The last error, if one exists, otherwise null. 459 457 */ 460 public function get_last_error() {458 public function get_last_error(): ?string { 461 459 return $this->last_error; 462 460 } … … 501 499 * @return bool Whether a tag was matched. 502 500 */ 503 public function next_tag( $query = null ) {501 public function next_tag( $query = null ): bool { 504 502 $visit_closers = isset( $query['tag_closers'] ) && 'visit' === $query['tag_closers']; 505 503 … … 591 589 * @return bool 592 590 */ 593 public function next_token() {591 public function next_token(): bool { 594 592 $this->current_element = null; 595 593 … … 644 642 } 645 643 646 647 644 /** 648 645 * Indicates if the current tag token is a tag closer. … … 661 658 * @return bool Whether the current tag is a tag closer. 662 659 */ 663 public function is_tag_closer() {660 public function is_tag_closer(): bool { 664 661 return $this->is_virtual() 665 662 ? ( WP_HTML_Stack_Event::POP === $this->current_element->operation && '#tag' === $this->get_token_type() ) … … 675 672 * @return bool Whether the current token is virtual. 676 673 */ 677 private function is_virtual() {674 private function is_virtual(): bool { 678 675 return ( 679 676 isset( $this->current_element->provenance ) && … … 707 704 * @return bool Whether the currently-matched tag is found at the given nested structure. 708 705 */ 709 public function matches_breadcrumbs( $breadcrumbs ) {706 public function matches_breadcrumbs( $breadcrumbs ): bool { 710 707 // Everything matches when there are zero constraints. 711 708 if ( 0 === count( $breadcrumbs ) ) { … … 758 755 * or `null` if not matched on any token. 759 756 */ 760 public function expects_closer( $node = null ) {757 public function expects_closer( $node = null ): ?bool { 761 758 $token_name = $node->node_name ?? $this->get_token_name(); 762 759 if ( ! isset( $token_name ) ) { … … 789 786 * @return bool Whether a tag was matched. 790 787 */ 791 public function step( $node_to_process = self::PROCESS_NEXT_NODE ) {788 public function step( $node_to_process = self::PROCESS_NEXT_NODE ): bool { 792 789 // Refuse to proceed if there was a previous error. 793 790 if ( null !== $this->last_error ) { … … 939 936 * @return string[]|null Array of tag names representing path to matched node, if matched, otherwise NULL. 940 937 */ 941 public function get_breadcrumbs() {938 public function get_breadcrumbs(): ?array { 942 939 return $this->breadcrumbs; 943 940 } … … 968 965 * @return int Nesting-depth of current location in the document. 969 966 */ 970 public function get_current_depth() {967 public function get_current_depth(): int { 971 968 return count( $this->breadcrumbs ); 972 969 } … … 987 984 * @return bool Whether an element was found. 988 985 */ 989 private function step_initial() {986 private function step_initial(): bool { 990 987 $this->bail( "No support for parsing in the '{$this->state->insertion_mode}' state." ); 991 988 } … … 1006 1003 * @return bool Whether an element was found. 1007 1004 */ 1008 private function step_before_html() {1005 private function step_before_html(): bool { 1009 1006 $this->bail( "No support for parsing in the '{$this->state->insertion_mode}' state." ); 1010 1007 } … … 1025 1022 * @return bool Whether an element was found. 1026 1023 */ 1027 private function step_before_head() {1024 private function step_before_head(): bool { 1028 1025 $this->bail( "No support for parsing in the '{$this->state->insertion_mode}' state." ); 1029 1026 } … … 1044 1041 * @return bool Whether an element was found. 1045 1042 */ 1046 private function step_in_head() {1043 private function step_in_head(): bool { 1047 1044 $this->bail( "No support for parsing in the '{$this->state->insertion_mode}' state." ); 1048 1045 } … … 1063 1060 * @return bool Whether an element was found. 1064 1061 */ 1065 private function step_in_head_noscript() {1062 private function step_in_head_noscript(): bool { 1066 1063 $this->bail( "No support for parsing in the '{$this->state->insertion_mode}' state." ); 1067 1064 } … … 1082 1079 * @return bool Whether an element was found. 1083 1080 */ 1084 private function step_after_head() {1081 private function step_after_head(): bool { 1085 1082 $this->bail( "No support for parsing in the '{$this->state->insertion_mode}' state." ); 1086 1083 } … … 1101 1098 * @return bool Whether an element was found. 1102 1099 */ 1103 private function step_in_body() {1100 private function step_in_body(): bool { 1104 1101 $token_name = $this->get_token_name(); 1105 1102 $token_type = $this->get_token_type(); … … 1724 1721 * @return bool Whether an element was found. 1725 1722 */ 1726 private function step_in_table() {1723 private function step_in_table(): bool { 1727 1724 $this->bail( "No support for parsing in the '{$this->state->insertion_mode}' state." ); 1728 1725 } … … 1743 1740 * @return bool Whether an element was found. 1744 1741 */ 1745 private function step_in_table_text() {1742 private function step_in_table_text(): bool { 1746 1743 $this->bail( "No support for parsing in the '{$this->state->insertion_mode}' state." ); 1747 1744 } … … 1762 1759 * @return bool Whether an element was found. 1763 1760 */ 1764 private function step_in_caption() {1761 private function step_in_caption(): bool { 1765 1762 $this->bail( "No support for parsing in the '{$this->state->insertion_mode}' state." ); 1766 1763 } … … 1781 1778 * @return bool Whether an element was found. 1782 1779 */ 1783 private function step_in_column_group() {1780 private function step_in_column_group(): bool { 1784 1781 $this->bail( "No support for parsing in the '{$this->state->insertion_mode}' state." ); 1785 1782 } … … 1800 1797 * @return bool Whether an element was found. 1801 1798 */ 1802 private function step_in_table_body() {1799 private function step_in_table_body(): bool { 1803 1800 $this->bail( "No support for parsing in the '{$this->state->insertion_mode}' state." ); 1804 1801 } … … 1819 1816 * @return bool Whether an element was found. 1820 1817 */ 1821 private function step_in_row() {1818 private function step_in_row(): bool { 1822 1819 $this->bail( "No support for parsing in the '{$this->state->insertion_mode}' state." ); 1823 1820 } … … 1838 1835 * @return bool Whether an element was found. 1839 1836 */ 1840 private function step_in_cell() {1837 private function step_in_cell(): bool { 1841 1838 $this->bail( "No support for parsing in the '{$this->state->insertion_mode}' state." ); 1842 1839 } … … 1857 1854 * @return bool Whether an element was found. 1858 1855 */ 1859 private function step_in_select() {1856 private function step_in_select(): bool { 1860 1857 $token_name = $this->get_token_name(); 1861 1858 $token_type = $this->get_token_type(); … … 2038 2035 * @return bool Whether an element was found. 2039 2036 */ 2040 private function step_in_select_in_table() {2037 private function step_in_select_in_table(): bool { 2041 2038 $this->bail( "No support for parsing in the '{$this->state->insertion_mode}' state." ); 2042 2039 } … … 2057 2054 * @return bool Whether an element was found. 2058 2055 */ 2059 private function step_in_template() {2056 private function step_in_template(): bool { 2060 2057 $this->bail( "No support for parsing in the '{$this->state->insertion_mode}' state." ); 2061 2058 } … … 2076 2073 * @return bool Whether an element was found. 2077 2074 */ 2078 private function step_after_body() {2075 private function step_after_body(): bool { 2079 2076 $this->bail( "No support for parsing in the '{$this->state->insertion_mode}' state." ); 2080 2077 } … … 2095 2092 * @return bool Whether an element was found. 2096 2093 */ 2097 private function step_in_frameset() {2094 private function step_in_frameset(): bool { 2098 2095 $this->bail( "No support for parsing in the '{$this->state->insertion_mode}' state." ); 2099 2096 } … … 2114 2111 * @return bool Whether an element was found. 2115 2112 */ 2116 private function step_after_frameset() {2113 private function step_after_frameset(): bool { 2117 2114 $this->bail( "No support for parsing in the '{$this->state->insertion_mode}' state." ); 2118 2115 } … … 2133 2130 * @return bool Whether an element was found. 2134 2131 */ 2135 private function step_after_after_body() {2132 private function step_after_after_body(): bool { 2136 2133 $this->bail( "No support for parsing in the '{$this->state->insertion_mode}' state." ); 2137 2134 } … … 2152 2149 * @return bool Whether an element was found. 2153 2150 */ 2154 private function step_after_after_frameset() {2151 private function step_after_after_frameset(): bool { 2155 2152 $this->bail( "No support for parsing in the '{$this->state->insertion_mode}' state." ); 2156 2153 } … … 2171 2168 * @return bool Whether an element was found. 2172 2169 */ 2173 private function step_in_foreign_content() {2170 private function step_in_foreign_content(): bool { 2174 2171 $this->bail( "No support for parsing in the '{$this->state->insertion_mode}' state." ); 2175 2172 } … … 2223 2220 * @return string|null Name of currently matched tag in input HTML, or `null` if none found. 2224 2221 */ 2225 public function get_tag() {2222 public function get_tag(): ?string { 2226 2223 if ( null !== $this->last_error ) { 2227 2224 return null; … … 2264 2261 * @return bool Whether the currently matched tag contains the self-closing flag. 2265 2262 */ 2266 public function has_self_closing_flag() {2263 public function has_self_closing_flag(): bool { 2267 2264 return $this->is_virtual() ? false : parent::has_self_closing_flag(); 2268 2265 } … … 2288 2285 * @return string|null Name of the matched token. 2289 2286 */ 2290 public function get_token_name() {2287 public function get_token_name(): ?string { 2291 2288 return $this->is_virtual() 2292 2289 ? $this->current_element->token->node_name … … 2316 2313 * @return string|null What kind of token is matched, or null. 2317 2314 */ 2318 public function get_token_type() {2315 public function get_token_type(): ?string { 2319 2316 if ( $this->is_virtual() ) { 2320 2317 /* … … 2378 2375 * @return bool Whether an attribute value was set. 2379 2376 */ 2380 public function set_attribute( $name, $value ) {2377 public function set_attribute( $name, $value ): bool { 2381 2378 return $this->is_virtual() ? false : parent::set_attribute( $name, $value ); 2382 2379 } … … 2390 2387 * @return bool Whether an attribute was removed. 2391 2388 */ 2392 public function remove_attribute( $name ) {2389 public function remove_attribute( $name ): bool { 2393 2390 return $this->is_virtual() ? false : parent::remove_attribute( $name ); 2394 2391 } … … 2420 2417 * @return array|null List of attribute names, or `null` when no tag opener is matched. 2421 2418 */ 2422 public function get_attribute_names_with_prefix( $prefix ) {2419 public function get_attribute_names_with_prefix( $prefix ): ?array { 2423 2420 return $this->is_virtual() ? null : parent::get_attribute_names_with_prefix( $prefix ); 2424 2421 } … … 2432 2429 * @return bool Whether the class was set to be added. 2433 2430 */ 2434 public function add_class( $class_name ) {2431 public function add_class( $class_name ): bool { 2435 2432 return $this->is_virtual() ? false : parent::add_class( $class_name ); 2436 2433 } … … 2444 2441 * @return bool Whether the class was set to be removed. 2445 2442 */ 2446 public function remove_class( $class_name ) {2443 public function remove_class( $class_name ): bool { 2447 2444 return $this->is_virtual() ? false : parent::remove_class( $class_name ); 2448 2445 } … … 2456 2453 * @return bool|null Whether the matched tag contains the given class name, or null if not matched. 2457 2454 */ 2458 public function has_class( $wanted_class ) {2455 public function has_class( $wanted_class ): ?bool { 2459 2456 return $this->is_virtual() ? null : parent::has_class( $wanted_class ); 2460 2457 } … … 2500 2497 * @return string 2501 2498 */ 2502 public function get_modifiable_text() {2499 public function get_modifiable_text(): string { 2503 2500 return $this->is_virtual() ? '' : parent::get_modifiable_text(); 2504 2501 } … … 2523 2520 * @return string|null 2524 2521 */ 2525 public function get_comment_type() {2522 public function get_comment_type(): ?string { 2526 2523 return $this->is_virtual() ? null : parent::get_comment_type(); 2527 2524 } … … 2538 2535 * @return bool Whether the bookmark already existed before removal. 2539 2536 */ 2540 public function release_bookmark( $bookmark_name ) {2537 public function release_bookmark( $bookmark_name ): bool { 2541 2538 return parent::release_bookmark( "_{$bookmark_name}" ); 2542 2539 } … … 2559 2556 * @return bool Whether the internal cursor was successfully moved to the bookmark's location. 2560 2557 */ 2561 public function seek( $bookmark_name ) {2558 public function seek( $bookmark_name ): bool { 2562 2559 // Flush any pending updates to the document before beginning. 2563 2560 $this->get_updated_html(); … … 2730 2727 * @return bool Whether the bookmark was successfully created. 2731 2728 */ 2732 public function set_bookmark( $bookmark_name ) {2729 public function set_bookmark( $bookmark_name ): bool { 2733 2730 return parent::set_bookmark( "_{$bookmark_name}" ); 2734 2731 } … … 2742 2739 * @return bool Whether that bookmark exists. 2743 2740 */ 2744 public function has_bookmark( $bookmark_name ) {2741 public function has_bookmark( $bookmark_name ): bool { 2745 2742 return parent::has_bookmark( "_{$bookmark_name}" ); 2746 2743 } … … 2759 2756 * @see https://html.spec.whatwg.org/#close-a-p-element 2760 2757 */ 2761 private function close_a_p_element() {2758 private function close_a_p_element(): void { 2762 2759 $this->generate_implied_end_tags( 'P' ); 2763 2760 $this->state->stack_of_open_elements->pop_until( 'P' ); … … 2774 2771 * @param string|null $except_for_this_element Perform as if this element doesn't exist in the stack of open elements. 2775 2772 */ 2776 private function generate_implied_end_tags( $except_for_this_element = null ){2773 private function generate_implied_end_tags( ?string $except_for_this_element = null ): void { 2777 2774 $elements_with_implied_end_tags = array( 2778 2775 'DD', … … 2810 2807 * @see https://html.spec.whatwg.org/#generate-implied-end-tags 2811 2808 */ 2812 private function generate_implied_end_tags_thoroughly() {2809 private function generate_implied_end_tags_thoroughly(): void { 2813 2810 $elements_with_implied_end_tags = array( 2814 2811 'CAPTION', … … 2852 2849 * @return bool Whether any formatting elements needed to be reconstructed. 2853 2850 */ 2854 private function reconstruct_active_formatting_elements() {2851 private function reconstruct_active_formatting_elements(): bool { 2855 2852 /* 2856 2853 * > If there are no entries in the list of active formatting elements, then there is nothing … … 3075 3072 * @see https://html.spec.whatwg.org/#adoption-agency-algorithm 3076 3073 */ 3077 private function run_adoption_agency_algorithm() {3074 private function run_adoption_agency_algorithm(): void { 3078 3075 $budget = 1000; 3079 3076 $subject = $this->get_tag(); … … 3183 3180 * @param WP_HTML_Token $token Name of bookmark pointing to element in original input HTML. 3184 3181 */ 3185 private function insert_html_element( $token ){3182 private function insert_html_element( WP_HTML_Token $token ): void { 3186 3183 $this->state->stack_of_open_elements->push( $token ); 3187 3184 } … … 3201 3198 * @return bool Whether the element of the given name is in the special category. 3202 3199 */ 3203 public static function is_special( $tag_name ) {3200 public static function is_special( $tag_name ): bool { 3204 3201 $tag_name = strtoupper( $tag_name ); 3205 3202 … … 3316 3313 * @return bool Whether the given tag is an HTML Void Element. 3317 3314 */ 3318 public static function is_void( $tag_name ) {3315 public static function is_void( $tag_name ): bool { 3319 3316 $tag_name = strtoupper( $tag_name ); 3320 3317 -
trunk/src/wp-includes/html-api/class-wp-html-span.php
r57179 r58769 50 50 * @param int $length Byte length of span. 51 51 */ 52 public function __construct( $start,$length ) {52 public function __construct( int $start, int $length ) { 53 53 $this->start = $start; 54 54 $this->length = $length; -
trunk/src/wp-includes/html-api/class-wp-html-stack-event.php
r58558 r58769 75 75 * @param string $provenance "virtual" or "real". 76 76 */ 77 public function __construct( $token, $operation,$provenance ) {77 public function __construct( WP_HTML_Token $token, string $operation, string $provenance ) { 78 78 $this->token = $token; 79 79 $this->operation = $operation; -
trunk/src/wp-includes/html-api/class-wp-html-tag-processor.php
r58740 r58769 785 785 * @return bool Whether a tag was matched. 786 786 */ 787 public function next_tag( $query = null ) {787 public function next_tag( $query = null ): bool { 788 788 $this->parse_query( $query ); 789 789 $already_found = 0; … … 833 833 * @return bool Whether a token was parsed. 834 834 */ 835 public function next_token() {835 public function next_token(): bool { 836 836 return $this->base_class_next_token(); 837 837 } … … 852 852 * @return bool Whether a token was parsed. 853 853 */ 854 private function base_class_next_token() {854 private function base_class_next_token(): bool { 855 855 $was_at = $this->bytes_already_parsed; 856 856 $this->after_tag(); … … 1034 1034 * @return bool Whether the parse paused at the start of an incomplete token. 1035 1035 */ 1036 public function paused_at_incomplete_token() {1036 public function paused_at_incomplete_token(): bool { 1037 1037 return self::STATE_INCOMPLETE_INPUT === $this->parser_state; 1038 1038 } … … 1113 1113 * @return bool|null Whether the matched tag contains the given class name, or null if not matched. 1114 1114 */ 1115 public function has_class( $wanted_class ) {1115 public function has_class( $wanted_class ): ?bool { 1116 1116 if ( self::STATE_MATCHED_TAG !== $this->parser_state ) { 1117 1117 return null; … … 1210 1210 * @return bool Whether the bookmark was successfully created. 1211 1211 */ 1212 public function set_bookmark( $name ) {1212 public function set_bookmark( $name ): bool { 1213 1213 // It only makes sense to set a bookmark if the parser has paused on a concrete token. 1214 1214 if ( … … 1243 1243 * @return bool Whether the bookmark already existed before removal. 1244 1244 */ 1245 public function release_bookmark( $name ) {1245 public function release_bookmark( $name ): bool { 1246 1246 if ( ! array_key_exists( $name, $this->bookmarks ) ) { 1247 1247 return false; … … 1263 1263 * @return bool Whether an end to the RAWTEXT region was found before the end of the document. 1264 1264 */ 1265 private function skip_rawtext( $tag_name ){1265 private function skip_rawtext( string $tag_name ): bool { 1266 1266 /* 1267 1267 * These two functions distinguish themselves on whether character references are … … 1282 1282 * @return bool Whether an end to the RCDATA region was found before the end of the document. 1283 1283 */ 1284 private function skip_rcdata( $tag_name ){1284 private function skip_rcdata( string $tag_name ): bool { 1285 1285 $html = $this->html; 1286 1286 $doc_length = strlen( $html ); … … 1370 1370 * @return bool Whether the script tag was closed before the end of the document. 1371 1371 */ 1372 private function skip_script_data() {1372 private function skip_script_data(): bool { 1373 1373 $state = 'unescaped'; 1374 1374 $html = $this->html; … … 1517 1517 * @return bool Whether a tag was found before the end of the document. 1518 1518 */ 1519 private function parse_next_tag() {1519 private function parse_next_tag(): bool { 1520 1520 $this->after_tag(); 1521 1521 … … 1907 1907 * @return bool Whether an attribute was found before the end of the document. 1908 1908 */ 1909 private function parse_next_attribute() {1909 private function parse_next_attribute(): bool { 1910 1910 $doc_length = strlen( $this->html ); 1911 1911 … … 2042 2042 * @since 6.2.0 2043 2043 */ 2044 private function skip_whitespace() {2044 private function skip_whitespace(): void { 2045 2045 $this->bytes_already_parsed += strspn( $this->html, " \t\f\r\n", $this->bytes_already_parsed ); 2046 2046 } … … 2051 2051 * @since 6.2.0 2052 2052 */ 2053 private function after_tag() {2053 private function after_tag(): void { 2054 2054 /* 2055 2055 * There could be lexical updates enqueued for an attribute that … … 2112 2112 * @see WP_HTML_Tag_Processor::$classname_updates 2113 2113 */ 2114 private function class_name_updates_to_attributes_updates() {2114 private function class_name_updates_to_attributes_updates(): void { 2115 2115 if ( count( $this->classname_updates ) === 0 ) { 2116 2116 return; … … 2257 2257 * @return int How many bytes the given pointer moved in response to the updates. 2258 2258 */ 2259 private function apply_attributes_updates( $shift_this_point ){2259 private function apply_attributes_updates( int $shift_this_point ): int { 2260 2260 if ( ! count( $this->lexical_updates ) ) { 2261 2261 return 0; … … 2354 2354 * @return bool Whether that bookmark exists. 2355 2355 */ 2356 public function has_bookmark( $bookmark_name ) {2356 public function has_bookmark( $bookmark_name ): bool { 2357 2357 return array_key_exists( $bookmark_name, $this->bookmarks ); 2358 2358 } … … 2369 2369 * @return bool Whether the internal cursor was successfully moved to the bookmark's location. 2370 2370 */ 2371 public function seek( $bookmark_name ) {2371 public function seek( $bookmark_name ): bool { 2372 2372 if ( ! array_key_exists( $bookmark_name, $this->bookmarks ) ) { 2373 2373 _doing_it_wrong( … … 2406 2406 * @return int Comparison value for string order. 2407 2407 */ 2408 private static function sort_start_ascending( $a, $b ){2408 private static function sort_start_ascending( WP_HTML_Text_Replacement $a, WP_HTML_Text_Replacement $b ): int { 2409 2409 $by_start = $a->start - $b->start; 2410 2410 if ( 0 !== $by_start ) { … … 2438 2438 * @return string|boolean|null Value of enqueued update if present, otherwise false. 2439 2439 */ 2440 private function get_enqueued_attribute_value( $comparable_name ) {2440 private function get_enqueued_attribute_value( string $comparable_name ) { 2441 2441 if ( self::STATE_MATCHED_TAG !== $this->parser_state ) { 2442 2442 return false; … … 2589 2589 * @return array|null List of attribute names, or `null` when no tag opener is matched. 2590 2590 */ 2591 public function get_attribute_names_with_prefix( $prefix ) {2591 public function get_attribute_names_with_prefix( $prefix ): ?array { 2592 2592 if ( 2593 2593 self::STATE_MATCHED_TAG !== $this->parser_state || … … 2624 2624 * @return string|null Name of currently matched tag in input HTML, or `null` if none found. 2625 2625 */ 2626 public function get_tag() {2626 public function get_tag(): ?string { 2627 2627 if ( null === $this->tag_name_starts_at ) { 2628 2628 return null; … … 2662 2662 * @return bool Whether the currently matched tag contains the self-closing flag. 2663 2663 */ 2664 public function has_self_closing_flag() {2664 public function has_self_closing_flag(): bool { 2665 2665 if ( self::STATE_MATCHED_TAG !== $this->parser_state ) { 2666 2666 return false; … … 2694 2694 * @return bool Whether the current tag is a tag closer. 2695 2695 */ 2696 public function is_tag_closer() {2696 public function is_tag_closer(): bool { 2697 2697 return ( 2698 2698 self::STATE_MATCHED_TAG === $this->parser_state && … … 2723 2723 * @return string|null What kind of token is matched, or null. 2724 2724 */ 2725 public function get_token_type() {2725 public function get_token_type(): ?string { 2726 2726 switch ( $this->parser_state ) { 2727 2727 case self::STATE_MATCHED_TAG: … … 2756 2756 * @return string|null Name of the matched token. 2757 2757 */ 2758 public function get_token_name() {2758 public function get_token_name(): ?string { 2759 2759 switch ( $this->parser_state ) { 2760 2760 case self::STATE_MATCHED_TAG: … … 2802 2802 * @return string|null 2803 2803 */ 2804 public function get_comment_type() {2804 public function get_comment_type(): ?string { 2805 2805 if ( self::STATE_COMMENT !== $this->parser_state ) { 2806 2806 return null; … … 2830 2830 * @return string 2831 2831 */ 2832 public function get_modifiable_text() {2832 public function get_modifiable_text(): string { 2833 2833 if ( null === $this->text_starts_at ) { 2834 2834 return ''; … … 2900 2900 * @return bool Whether an attribute value was set. 2901 2901 */ 2902 public function set_attribute( $name, $value ) {2902 public function set_attribute( $name, $value ): bool { 2903 2903 if ( 2904 2904 self::STATE_MATCHED_TAG !== $this->parser_state || … … 3043 3043 * @return bool Whether an attribute was removed. 3044 3044 */ 3045 public function remove_attribute( $name ) {3045 public function remove_attribute( $name ): bool { 3046 3046 if ( 3047 3047 self::STATE_MATCHED_TAG !== $this->parser_state || … … 3121 3121 * @return bool Whether the class was set to be added. 3122 3122 */ 3123 public function add_class( $class_name ) {3123 public function add_class( $class_name ): bool { 3124 3124 if ( 3125 3125 self::STATE_MATCHED_TAG !== $this->parser_state || … … 3142 3142 * @return bool Whether the class was set to be removed. 3143 3143 */ 3144 public function remove_class( $class_name ) {3144 public function remove_class( $class_name ): bool { 3145 3145 if ( 3146 3146 self::STATE_MATCHED_TAG !== $this->parser_state || … … 3166 3166 * @return string The processed HTML. 3167 3167 */ 3168 public function __toString() {3168 public function __toString(): string { 3169 3169 return $this->get_updated_html(); 3170 3170 } … … 3179 3179 * @return string The processed HTML. 3180 3180 */ 3181 public function get_updated_html() {3181 public function get_updated_html(): string { 3182 3182 $requires_no_updating = 0 === count( $this->classname_updates ) && 0 === count( $this->lexical_updates ); 3183 3183 … … 3301 3301 * @return bool Whether the given tag and its attribute match the search criteria. 3302 3302 */ 3303 private function matches() {3303 private function matches(): bool { 3304 3304 if ( $this->is_closing_tag && ! $this->stop_on_tag_closers ) { 3305 3305 return false; -
trunk/src/wp-includes/html-api/class-wp-html-text-replacement.php
r57179 r58769 57 57 * @param string $text Span of text to insert in document to replace existing content from start to end. 58 58 */ 59 public function __construct( $start, $length,$text ) {59 public function __construct( int $start, int $length, string $text ) { 60 60 $this->start = $start; 61 61 $this->length = $length; -
trunk/src/wp-includes/html-api/class-wp-html-token.php
r57163 r58769 73 73 * @since 6.4.0 74 74 * 75 * @param string $bookmark_name Name of bookmark corresponding to location in HTML where token is found.76 * @param string $node_name Name of node token represents; if uppercase, an HTML element; if lowercase, a special value like "marker".77 * @param bool $has_self_closing_flag Whether the source token contains the self-closing flag, regardless of whether it's valid.78 * @param callable $on_destroyFunction to call when destroying token, useful for releasing the bookmark.75 * @param string $bookmark_name Name of bookmark corresponding to location in HTML where token is found. 76 * @param string $node_name Name of node token represents; if uppercase, an HTML element; if lowercase, a special value like "marker". 77 * @param bool $has_self_closing_flag Whether the source token contains the self-closing flag, regardless of whether it's valid. 78 * @param callable|null $on_destroy Optional. Function to call when destroying token, useful for releasing the bookmark. 79 79 */ 80 public function __construct( $bookmark_name, $node_name, $has_self_closing_flag,$on_destroy = null ) {80 public function __construct( string $bookmark_name, string $node_name, bool $has_self_closing_flag, ?callable $on_destroy = null ) { 81 81 $this->bookmark_name = $bookmark_name; 82 82 $this->node_name = $node_name;
Note: See TracChangeset
for help on using the changeset viewer.