mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-18 12:04:46 +00:00
Replace InvalidStateException usages with InvalidArgument or LogicException
This commit is contained in:
@@ -144,8 +144,7 @@ class Config{
|
||||
* @param mixed[] $default
|
||||
* @phpstan-param array<string, mixed> $default
|
||||
*
|
||||
* @throws \InvalidArgumentException if config type could not be auto-detected
|
||||
* @throws \InvalidStateException if config type is invalid
|
||||
* @throws \InvalidArgumentException if config type is invalid or could not be auto-detected
|
||||
*/
|
||||
private function load(string $file, int $type = Config::DETECT, array $default = []) : void{
|
||||
$this->file = $file;
|
||||
@@ -187,7 +186,7 @@ class Config{
|
||||
$config = array_fill_keys(self::parseList($content), true);
|
||||
break;
|
||||
default:
|
||||
throw new \InvalidStateException("Config type is unknown");
|
||||
throw new \InvalidArgumentException("Invalid config type specified");
|
||||
}
|
||||
$this->config = is_array($config) ? $config : $default;
|
||||
if($this->fillDefaults($default, $this->config) > 0){
|
||||
|
@@ -43,7 +43,7 @@ final class PromiseResolver{
|
||||
*/
|
||||
public function resolve($value) : void{
|
||||
if($this->shared->resolved){
|
||||
throw new \InvalidStateException("Promise has already been resolved/rejected");
|
||||
throw new \LogicException("Promise has already been resolved/rejected");
|
||||
}
|
||||
$this->shared->resolved = true;
|
||||
$this->shared->result = $value;
|
||||
@@ -56,7 +56,7 @@ final class PromiseResolver{
|
||||
|
||||
public function reject() : void{
|
||||
if($this->shared->resolved){
|
||||
throw new \InvalidStateException("Promise has already been resolved/rejected");
|
||||
throw new \LogicException("Promise has already been resolved/rejected");
|
||||
}
|
||||
$this->shared->resolved = true;
|
||||
foreach($this->shared->onFailure as $c){
|
||||
|
@@ -64,7 +64,7 @@ abstract class Terminal{
|
||||
|
||||
public static function hasFormattingCodes() : bool{
|
||||
if(self::$formattingCodes === null){
|
||||
throw new \InvalidStateException("Formatting codes have not been initialized");
|
||||
throw new \LogicException("Formatting codes have not been initialized");
|
||||
}
|
||||
return self::$formattingCodes;
|
||||
}
|
||||
|
Reference in New Issue
Block a user