From ae2f06fff499a0e483100cfabf135e240a847ef6 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 ++++++++++-------- test.php | 0 3 files changed, 12 insertions(+), 13 deletions(-) delete mode 100644 test.php diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 25b43c3ea..953a06548 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 d0b69792d..10189a2e0 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); } } diff --git a/test.php b/test.php deleted file mode 100644 index e69de29bb..000000000