Skip to content

Commit

Permalink
Fixed ReflectionStorage never type for PHP 8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
vudaltsov committed Feb 5, 2024
1 parent b5bd5eb commit 6bb63dd
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/ReflectionStorage/ReflectionStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ public function __construct(
private readonly bool $detectChanges = true,
) {}

private static function throwingLoader(): never
{
throw new \LogicException('Reflection loader must not be called twice.');
}

/**
* @param class-string $class
* @param non-empty-string $name
Expand Down Expand Up @@ -87,7 +92,7 @@ public function get(string $class, string $name, \Closure $loader): object

$loader();

return $this->get($class, $name, static fn(): never => throw new ReflectionException(sprintf('%s with name %s not found.', $class, $name)));
return $this->get($class, $name, self::throwingLoader(...));
}

/**
Expand Down

0 comments on commit 6bb63dd

Please sign in to comment.