resolve($this->container); } $guard = DepthGuard::getInstance(); return $guard->call( $definition->getName(), fn () => $this->getDefinitionResolver($definition)->resolve($definition, $parameters) ); } /** * Check if a definition can be resolved. * * @param DefinitionInterface $definition object that defines how the value should be obtained * @param array $parameters optional parameters to use to build the entry */ public function isResolvable(DefinitionInterface $definition, array $parameters = []): bool { if ($definition instanceof SelfResolvingDefinitionInterface) { return $definition->isResolvable($this->container); } $guard = DepthGuard::getInstance(); return $guard->call( $definition->getName(), fn () => $this->getDefinitionResolver($definition)->isResolvable($definition, $parameters) ); } /** * Returns a resolver capable of handling the given definition. * * @throws RuntimeException no definition resolver was found for this type of definition */ private function getDefinitionResolver(DefinitionInterface $definition): ResolverInterface { return match (true) { $definition instanceof ObjectDefinition => $this->objectResolver ??= new ObjectResolver($this->container, $this), $definition instanceof FactoryDefinition => $this->factoryResolver ??= new FactoryResolver($this->container, $this), default => throw new RuntimeException('No definition resolver was configured for definition of type ' . get_class($definition)), }; } }