From 78fd641686c13d70ac80736ec2ba2efcb65ce299 Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Wed, 27 Nov 2024 10:06:41 +0900 Subject: [PATCH] Add dependency doctrine/cache ^1.0 check 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. --- docs/exmaple/ProdInjectorContext.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/exmaple/ProdInjectorContext.php b/docs/exmaple/ProdInjectorContext.php index 83241691..e0080cc5 100644 --- a/docs/exmaple/ProdInjectorContext.php +++ b/docs/exmaple/ProdInjectorContext.php @@ -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 @@ -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 } }