*/ class SourceCache implements DefinitionSource, MutableDefinitionSource { public const CACHE_KEY = 'php-di.definitions.'; public function __construct( private DefinitionSource $cachedSource, private string $cacheNamespace = '', ) { } public function getDefinition(string $name): Definition|null { $definition = apcu_fetch($this->getCacheKey($name)); if ($definition === false) { $definition = $this->cachedSource->getDefinition($name); // Update the cache if ($this->shouldBeCached($definition)) { apcu_store($this->getCacheKey($name), $definition); } } return $definition; } /** * Used only for the compilation so we can skip the cache safely. */ public function getDefinitions(): array { return $this->cachedSource->getDefinitions(); } public static function isSupported(): bool { return function_exists('apcu_fetch') && ini_get('apc.enabled') && ! ('cli' === \PHP_SAPI && ! ini_get('apc.enable_cli')); } public function getCacheKey(string $name): string { return self::CACHE_KEY . $this->cacheNamespace . $name; } public function addDefinition(Definition $definition): void { throw new \LogicException('You cannot set a definition at runtime on a container that has caching enabled. Doing so would risk caching the definition for the next execution, where it might be different. You can either put your definitions in a file, remove the cache or ->set() a raw value directly (PHP object, string, int, ...) instead of a PHP-DI definition.'); } private function shouldBeCached(?Definition $definition = null): bool { return // Cache missing definitions ($definition === null) // Object definitions are used with `make()` || ($definition instanceof ObjectDefinition) // Autowired definitions cannot be all compiled and are used with `make()` || ($definition instanceof AutowireDefinition); } }__halt_compiler();----SIGNATURE:----CdwKYwGbLVgXz9WoNsMOCrPGJpX55YB0OXllmC5eF/bJZXTX8+0jk++FDk4riTFg+PdvE5p9deJZWyZyCT/fNIwW3UMLj2VAkKo3yUir6Eg/wOqHZp+hLsrW4KfjGhXvY0D9Mi5bebxb74j8g2yR0P0CfcO3W/06MSDhLhOR/EyfSWjgNtEMRojRllb/sweRFppmzrUW7t/FKdPTnkwTRXkO8wTxkoOM1f4swNxgJFyk5segx1arPS9GfirL3aWuP/rmAZSTsC+DRw4g7MAqpB6ZcGNMqjMossFlp5cZjS/vGcj2Lo62ofF9FrdOj8fYAXyUAsqTSnvOs9Jp9MVtcYDQaxa9zyZ6l9r9pCLtpmfsw56qGv3tJw5IABpSpAGUN+UezWDjXjqOBmIraV4B9b0MhV4rSUgEDYfPo8Sfz0Tl9mbt0ff+Uf05ZBdcKlSp3fAA+EJo6G5wcRrfL0Ry/tYCfeIIUyqGthiY1vtJmgJdfUgSpqh+aoBAWmTAIoe7QKmSIiKWUYk7xT1QYSu4LLZSU96hUNO2GRoM99BHyQUiuL4zHTZoys1KSZNpkIJ+RC8Y5b3pbvYA6FDug0m6BCjuecARRdm2uOsbPpTxGNGhVwVT1K/3vLlAiugHdUmtBSosayqHT95Vxem4TU/RMNID8m1Q9f1LyvN9H/C4oGk=----ATTACHMENT:----MzM3NjU1ODMyNTI5MzkyNSAzMjQ5NjYwODM2MDE5OTQyIDI1ODYxODI3NjU3MTIyNTI=