Skip to content

Commit

Permalink
Fix PHPStan failures
Browse files Browse the repository at this point in the history
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<string, mixed>, array given.
  • Loading branch information
praem90 authored Oct 5, 2023
1 parent 2c623e0 commit 4ffb0cd
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Check failure on line 120 in src/Configuration.php

View workflow job for this annotation

GitHub Actions / PHPCS

Referencing general \Exception; use \Throwable instead.
if ($ex instanceof InvalidPathException || $ex instanceof MissingPathException) {
throw new UnknownOptionException($ex->getMessage(), $key, (int) $ex->getCode(), $ex);
}

throw $ex;

Check failure on line 125 in src/Configuration.php

View workflow job for this annotation

GitHub Actions / PHPStan

Method League\Config\Configuration::get() throws checked exception Exception but it's missing from the PHPDoc @throws tag.
}
}

Expand Down Expand Up @@ -186,6 +190,7 @@ private function build(string $topLevelKey): void
$schema = $this->configSchemas[$topLevelKey];
$processor = new Processor();

/** @var \StdClass $processed */

Check failure on line 193 in src/Configuration.php

View workflow job for this annotation

GitHub Actions / PHPCS

Use assertion instead of inline documentation comment.
$processed = $processor->process(Expect::structure([$topLevelKey => $schema]), $userData);

Check failure on line 194 in src/Configuration.php

View workflow job for this annotation

GitHub Actions / Psalm

InvalidClass

src/Configuration.php:194:13: InvalidClass: Class, interface or enum StdClass has wrong casing (see https://psalm.dev/007)

$this->raiseAnyDeprecationNotices($processor->getWarnings());
Expand Down

0 comments on commit 4ffb0cd

Please sign in to comment.