mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 08:17:34 +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:
parent
a219b727f2
commit
097c260dbb
@ -50,6 +50,7 @@ use function is_object;
|
||||
use function is_resource;
|
||||
use function is_string;
|
||||
use function json_encode;
|
||||
use function mb_strtoupper;
|
||||
use function min;
|
||||
use function mkdir;
|
||||
use function preg_match;
|
||||
@ -58,7 +59,6 @@ use function round;
|
||||
use function spl_object_hash;
|
||||
use function sprintf;
|
||||
use function strlen;
|
||||
use function strtoupper;
|
||||
use function substr;
|
||||
use const JSON_PRETTY_PRINT;
|
||||
use const JSON_UNESCAPED_SLASHES;
|
||||
@ -127,7 +127,7 @@ class MemoryManager{
|
||||
if($m <= 0){
|
||||
$defaultMemory = 0;
|
||||
}else{
|
||||
switch(strtoupper($matches[2])){
|
||||
switch(mb_strtoupper($matches[2])){
|
||||
case "K":
|
||||
$defaultMemory = $m / 1024;
|
||||
break;
|
||||
|
@ -31,7 +31,7 @@ use pocketmine\event\player\PlayerExhaustEvent;
|
||||
use pocketmine\utils\Color;
|
||||
use function constant;
|
||||
use function defined;
|
||||
use function strtoupper;
|
||||
use function mb_strtoupper;
|
||||
|
||||
class Effect{
|
||||
public const SPEED = 1;
|
||||
@ -102,7 +102,7 @@ class Effect{
|
||||
}
|
||||
|
||||
public static function getEffectByName(string $name) : ?Effect{
|
||||
$const = self::class . "::" . strtoupper($name);
|
||||
$const = self::class . "::" . mb_strtoupper($name);
|
||||
if(defined($const)){
|
||||
return self::getEffect(constant($const));
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ namespace pocketmine\event;
|
||||
|
||||
use function constant;
|
||||
use function defined;
|
||||
use function strtoupper;
|
||||
use function mb_strtoupper;
|
||||
|
||||
/**
|
||||
* List of event priorities
|
||||
@ -79,7 +79,7 @@ abstract class EventPriority{
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public static function fromString(string $name) : int{
|
||||
$name = strtoupper($name);
|
||||
$name = mb_strtoupper($name);
|
||||
$const = self::class . "::" . $name;
|
||||
if($name !== "ALL" and defined($const)){
|
||||
return constant($const);
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -29,12 +29,12 @@ use function array_values;
|
||||
use function constant;
|
||||
use function defined;
|
||||
use function is_array;
|
||||
use function mb_strtoupper;
|
||||
use function phpversion;
|
||||
use function preg_match;
|
||||
use function str_replace;
|
||||
use function stripos;
|
||||
use function strlen;
|
||||
use function strtoupper;
|
||||
use function substr;
|
||||
use function version_compare;
|
||||
use function yaml_parse;
|
||||
@ -147,7 +147,7 @@ class PluginDescription{
|
||||
$this->prefix = (string) ($plugin["prefix"] ?? $this->prefix);
|
||||
|
||||
if(isset($plugin["load"])){
|
||||
$order = strtoupper($plugin["load"]);
|
||||
$order = mb_strtoupper($plugin["load"]);
|
||||
if(!defined(PluginLoadOrder::class . "::" . $order)){
|
||||
throw new PluginException("Invalid PluginDescription load");
|
||||
}else{
|
||||
|
@ -59,12 +59,12 @@ use function is_dir;
|
||||
use function is_string;
|
||||
use function is_subclass_of;
|
||||
use function iterator_to_array;
|
||||
use function mb_strtoupper;
|
||||
use function mkdir;
|
||||
use function shuffle;
|
||||
use function stripos;
|
||||
use function strpos;
|
||||
use function strtolower;
|
||||
use function strtoupper;
|
||||
use const DIRECTORY_SEPARATOR;
|
||||
|
||||
/**
|
||||
@ -379,7 +379,7 @@ class PluginManager{
|
||||
if($version !== $serverString){
|
||||
$pluginApi = array_pad(explode("-", $version, 2), 2, ""); //0 = version, 1 = suffix (optional)
|
||||
|
||||
if(strtoupper($pluginApi[1]) !== strtoupper($serverApi[1])){ //Different release phase (alpha vs. beta) or phase build (alpha.1 vs alpha.2)
|
||||
if(mb_strtoupper($pluginApi[1]) !== mb_strtoupper($serverApi[1])){ //Different release phase (alpha vs. beta) or phase build (alpha.1 vs alpha.2)
|
||||
continue;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user