Skip to content

Commit

Permalink
Add dependency doctrine/cache ^1.0 check
Browse files Browse the repository at this point in the history
Removed an obsolete import that was no longer used in ProdInjectorContext. Added a check to ensure the ApcuCache class exists before attempting to instantiate it, with a runtime exception for cases where the class is missing.
  • Loading branch information
koriym committed Nov 27, 2024
1 parent 2e68149 commit 78fd641
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions docs/exmaple/ProdInjectorContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Doctrine\Common\Cache\CacheProvider;
use Ray\Compiler\AbstractInjectorContext;
use Ray\Compiler\DiCompileModule;
use Ray\Compiler\FakeCarModule;
use Ray\Di\AbstractModule;

final class ProdInjectorContext extends AbstractInjectorContext
Expand All @@ -23,6 +22,10 @@ public function __invoke(): AbstractModule

public function getCache(): CacheProvider
{
return new ApcuCache();
if (! class_exists(ApcuCache::class)) {
throw new \RuntimeException('doctrine/cache ^1.0 is required for ProdInjectorContext.');
}

return new ApcuCache(); // @phpstan-ignore-line
}
}

0 comments on commit 78fd641

Please sign in to comment.