*/ private static function words(string $input): array { // Insert underscore before transitions from lowercase/digit to uppercase $input = preg_replace('/([a-z\d])([A-Z])/', '$1_$2', $input) ?? $input; // Insert underscore before transitions from a run of uppercase into mixed (e.g. HTMLParser → HTML_Parser) $input = preg_replace('/([A-Z]+)([A-Z][a-z])/', '$1_$2', $input) ?? $input; // Split on underscores, hyphens, and whitespace $words = preg_split('/[_\-\s]+/', $input) ?: []; return array_values(array_filter( array_map('mb_strtolower', $words), static fn(string $w): bool => $w !== '', )); } }