Changeset 58769 for trunk/src/wp-includes/class-wp-token-map.php
- Timestamp:
- 07/19/2024 11:42:14 PM (10 months ago)
- File:
-
- 1 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;
Note: See TracChangeset
for help on using the changeset viewer.