mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 02:08:21 +00:00
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:
@ -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");
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
Reference in New Issue
Block a user