Eradicate all usages of strtoupper()

strtoupper() is an evil function whose behaviour depends on the system locale. mb_strtoupper() has more consistent behaviour.
This commit is contained in:
Dylan K. Taylor
2020-06-13 19:47:00 +01:00
parent a219b727f2
commit 097c260dbb
7 changed files with 15 additions and 15 deletions

View File

@ -34,8 +34,8 @@ use function gettype;
use function is_numeric;
use function is_object;
use function is_string;
use function mb_strtoupper;
use function str_replace;
use function strtoupper;
use function trim;
/**
@ -375,8 +375,8 @@ class ItemFactory{
if(is_numeric($b[0])){
$item = self::get((int) $b[0], $meta);
}elseif(defined(ItemIds::class . "::" . strtoupper($b[0]))){
$item = self::get(constant(ItemIds::class . "::" . strtoupper($b[0])), $meta);
}elseif(defined(ItemIds::class . "::" . mb_strtoupper($b[0]))){
$item = self::get(constant(ItemIds::class . "::" . mb_strtoupper($b[0])), $meta);
}else{
throw new \InvalidArgumentException("Unable to resolve \"" . $str . "\" to a valid item");
}

View File

@ -26,7 +26,7 @@ namespace pocketmine\item\enchantment;
use pocketmine\event\entity\EntityDamageEvent;
use function constant;
use function defined;
use function strtoupper;
use function mb_strtoupper;
/**
* Manages enchantment type data.
@ -161,7 +161,7 @@ class Enchantment{
}
public static function getEnchantmentByName(string $name) : ?Enchantment{
$const = Enchantment::class . "::" . strtoupper($name);
$const = Enchantment::class . "::" . mb_strtoupper($name);
if(defined($const)){
return self::getEnchantment(constant($const));
}