WP_Token_Map::longest_first_then_alphabetical()
Compares two strings, returning the longest, or whichever is first alphabetically if they are the same length.
This is an important sort when building the token map because it should not form a match on a substring of a longer potential match. For example, it should not detect Cap when matching against the string CapitalDifferentialD.
Метод класса: WP_Token_Map{}
Хуков нет.
Возвращает
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.
Использование
$result = WP_Token_Map::longest_first_then_alphabetical( $a, $b );
- $a(строка) (обязательный)
- First string to compare.
- $b(строка) (обязательный)
- Second string to compare.
Список изменений
С версии 6.6.0 | Введена. |
Код WP_Token_Map::longest_first_then_alphabetical() WP Token Map::longest first then alphabetical WP 6.6.2
private static function longest_first_then_alphabetical( $a, $b ) { if ( $a === $b ) { return 0; } $length_a = strlen( $a ); $length_b = strlen( $b ); // Longer strings are less-than for comparison's sake. if ( $length_a !== $length_b ) { return $length_b - $length_a; } return strcmp( $a, $b ); }