Following up on T338103: Micro-optimize ApiResult::isMetadataKey with str_starts_with once we support PHP8+, and specifically:
ord() has (at least?) two known issues (not liking empty strings, and providing a string longer than 1 byte), as seen in various tasks that have been PHP 8.5 cleanup:
- T411397: Fix "ord(): Providing an empty string is deprecated" PHP 8.5 warning in Less_Parser
- T411214: Deprecated: ord(): Providing a string that is not one byte long is deprecated. Use ord($str[0]) instead in /var/www/wiki/mediawiki/core/includes/Api/ApiResult.php on line 792
- T411014: Deprecated: ord(): Providing a string that is not one byte long is deprecated. Use ord($str[0]) instead in /var/www/wiki/mediawiki/core/vendor/wikimedia/cldr-plural-rule-parser/src/Evaluator.php on line 95
- T410920: Deprecated: ord(): Providing an empty string is deprecated in /var/www/wiki/mediawiki/core/includes/Language/Language.php on line 2979
- T410912: Deprecated: ord(): Providing a string that is not one byte long is deprecated. Use ord($str[0]) instead
In our modern PHP world, performance optimisations gained by using ord() as per T338103 originally being filed, may be unnecessary, and we can use more readable code.