From 0c470fb4a831f5a6a2545e3e8161bbe28c5273f4 Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Tue, 7 Jan 2025 21:08:47 +0400 Subject: [PATCH] Fix psalm issues --- psalm-baseline.xml | 7 ++----- src/Config/RelationConfig.php | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 25b43c3e..953a0654 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -229,8 +229,8 @@ - config[$type][self::LOADER])]]> - config[$type][self::RELATION])]]> + new Autowire($loader) + new Autowire($relation) @@ -297,9 +297,6 @@ ], )]]> - - $alias - $class $class diff --git a/src/Config/RelationConfig.php b/src/Config/RelationConfig.php index d0b69792..10189a2e 100644 --- a/src/Config/RelationConfig.php +++ b/src/Config/RelationConfig.php @@ -61,19 +61,21 @@ public static function getDefault(): self public function getLoader(int|string $type): Autowire { - if (!isset($this->config[$type][self::LOADER])) { - throw new ConfigException("Unable to get relation loader `{$type}`."); - } + $loader = $this->config[$type][self::LOADER] ?? throw new ConfigException( + "Unable to get relation loader `{$type}`.", + ); - return new Autowire($this->config[$type][self::LOADER]); + \assert(\is_string($loader) && $loader !== ''); + return new Autowire($loader); } public function getRelation(int|string $type): Autowire { - if (!isset($this->config[$type][self::RELATION])) { - throw new ConfigException("Unable to get relation `{$type}`."); - } + $relation = $this->config[$type][self::RELATION] ?? throw new ConfigException( + "Unable to get relation `{$type}`.", + ); - return new Autowire($this->config[$type][self::RELATION]); + \assert(\is_string($relation) && $relation !== ''); + return new Autowire($relation); } }