WP_Token_Map::longest_first_then_alphabetical(string$a, string$b ): int
Since
6.6.0
Source
wp-includes/class-wp-token-map.php:805
Compares two strings, returning the longest, or whichever is first alphabetically if they are the same length.
Description
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.
Parameters
$astring
First string to compare.
$bstring
Second string to compare.
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.
Used by · 1
WP_Token_Map::from_array()Create a token map using an associative array of key/value pairs as the input.
805privatestaticfunctionlongest_first_then_alphabetical(string$a,string$b):int{806if($a===$b){807return0;808}809810$length_a=strlen($a);811$length_b=strlen($b);812813// Longer strings are less-than for comparison's sake.814if($length_a!==$length_b){815return$length_b-$length_a;816}817818returnstrcmp($a,$b);819}
History
Introduced in 6.6.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
Parsed data
Generated from the wordpress-develop 6.7.7 tag, from src/wp-includes/class-wp-token-map.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.