mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
GeneratorManager: fixed addGenerator() being case-sensitive when overwrite=true
this was caused by 083a1e1ff6b6ff5c0c1ba14250d2b026af103b90. This was discovered by a new PHPStan rule I'm working on, which disallows overwriting the values of parameter variables. During the refactor of this function to correct the error, another error appeared: Variable might not be defined. This is yet another excellent example of why mutability is bad.
This commit is contained in:
parent
e06eefeab0
commit
0a58fd5472
@ -72,7 +72,8 @@ final class GeneratorManager{
|
||||
public function addGenerator(string $class, string $name, \Closure $presetValidator, bool $overwrite = false) : void{
|
||||
Utils::testValidInstance($class, Generator::class);
|
||||
|
||||
if(!$overwrite and isset($this->list[$name = strtolower($name)])){
|
||||
$name = strtolower($name);
|
||||
if(!$overwrite and isset($this->list[$name])){
|
||||
throw new \InvalidArgumentException("Alias \"$name\" is already assigned");
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user