Replace InvalidStateException usages with InvalidArgument or LogicException

This commit is contained in:
Dylan K. Taylor
2021-11-02 16:05:54 +00:00
parent 4eef458d29
commit e34364412b
15 changed files with 24 additions and 30 deletions

View File

@@ -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){

View File

@@ -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){

View File

@@ -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;
}