From 4ffb0cdfa9914aefdddf9a925ca7a9f5fdb40e0d Mon Sep 17 00:00:00 2001 From: Mohan Raj Date: Thu, 5 Oct 2023 12:25:13 +0530 Subject: [PATCH] Fix PHPStan failures Errors: PHPStan: src/Configuration.php#L120 Dead catch - Dflydev\DotAccessData\Exception\MissingPathException is never thrown in the try block. PHPStan: src/Configuration.php#L193 Parameter 1 $data of method Dflydev\DotAccessData\Data::import() expects array, array given. --- src/Configuration.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Configuration.php b/src/Configuration.php index 6294367..a922446 100644 --- a/src/Configuration.php +++ b/src/Configuration.php @@ -117,8 +117,12 @@ public function get(string $key) $this->build(self::getTopLevelKey($key)); return $this->cache[$key] = $this->finalConfig->get($key); - } catch (InvalidPathException | MissingPathException $ex) { - throw new UnknownOptionException($ex->getMessage(), $key, (int) $ex->getCode(), $ex); + } catch (\Exception $ex) { + if ($ex instanceof InvalidPathException || $ex instanceof MissingPathException) { + throw new UnknownOptionException($ex->getMessage(), $key, (int) $ex->getCode(), $ex); + } + + throw $ex; } } @@ -186,6 +190,7 @@ private function build(string $topLevelKey): void $schema = $this->configSchemas[$topLevelKey]; $processor = new Processor(); + /** @var \StdClass $processed */ $processed = $processor->process(Expect::structure([$topLevelKey => $schema]), $userData); $this->raiseAnyDeprecationNotices($processor->getWarnings());