From 72d98d471e8ff8aa15700bcc9dfbdc0b643c3115 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Fri, 25 Aug 2023 16:16:28 -0700 Subject: [PATCH] PhpStormCompilePass - Generate hints for `Civi::cache()` The `cache()` method just returns objects from the container, so it can come from the same metadata. --- .../phpstorm/Civi/PhpStorm/PhpStormCompilePass.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tools/extensions/phpstorm/Civi/PhpStorm/PhpStormCompilePass.php b/tools/extensions/phpstorm/Civi/PhpStorm/PhpStormCompilePass.php index debe9f8d5e..fe6ecf3b17 100644 --- a/tools/extensions/phpstorm/Civi/PhpStorm/PhpStormCompilePass.php +++ b/tools/extensions/phpstorm/Civi/PhpStorm/PhpStormCompilePass.php @@ -19,8 +19,17 @@ class PhpStormCompilePass implements CompilerPassInterface { return; } + $services = $this->findServices($container); + $caches = []; + foreach ($services as $serviceId => $type) { + if (preg_match('/^cache\./', $serviceId)) { + $caches[substr($serviceId, 6)] = $type; + } + } + $builder = new PhpStormMetadata('services', __CLASS__); - $builder->addOverrideMap('\Civi::service()', $this->findServices($container)); + $builder->addOverrideMap('\Civi::service()', $services); + $builder->addOverrideMap('\Civi::cache()', $caches); $builder->write(); } -- 2.25.1