__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\DependencyInjection;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException;
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
use Symfony\Contracts\Service\ServiceLocatorTrait;
use Symfony\Contracts\Service\ServiceProviderInterface;
use Symfony\Contracts\Service\ServiceSubscriberInterface;
/**
* @author Robin Chalas <robin.chalas@gmail.com>
* @author Nicolas Grekas <p@tchwork.com>
*
* @template-covariant T of mixed
*
* @implements ServiceProviderInterface<T>
*/
class ServiceLocator implements ServiceProviderInterface, \Countable
{
use ServiceLocatorTrait {
get as private doGet;
}
private ?string $externalId = null;
private ?Container $container = null;
public function get(string $id): mixed
{
if (!$this->externalId) {
return $this->doGet($id);
}
try {
return $this->doGet($id);
} catch (RuntimeException $e) {
$what = sprintf('service "%s" required by "%s"', $id, $this->externalId);
$message = preg_replace('/service "\.service_locator\.[^"]++"/', $what, $e->getMessage());
if ($e->getMessage() === $message) {
$message = sprintf('Cannot resolve %s: %s', $what, $message);
}
$r = new \ReflectionProperty($e, 'message');
$r->setValue($e, $message);
throw $e;
}
}
/**
* @return mixed
*/
public function __invoke(string $id)
{
return isset($this->factories[$id]) ? $this->get($id) : null;
}
/**
* @internal
*/
public function withContext(string $externalId, Container $container): static
{
$locator = clone $this;
$locator->externalId = $externalId;
$locator->container = $container;
return $locator;
}
public function count(): int
{
return \count($this->getProvidedServices());
}
private function createNotFoundException(string $id): NotFoundExceptionInterface
{
if ($this->loading) {
$msg = sprintf('The service "%s" has a dependency on a non-existent service "%s". This locator %s', end($this->loading), $id, $this->formatAlternatives());
return new ServiceNotFoundException($id, end($this->loading) ?: null, null, [], $msg);
}
$class = debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT | \DEBUG_BACKTRACE_IGNORE_ARGS, 4);
$class = isset($class[3]['object']) ? $class[3]['object']::class : null;
$externalId = $this->externalId ?: $class;
$msg = [];
$msg[] = sprintf('Service "%s" not found:', $id);
if (!$this->container) {
$class = null;
} elseif ($this->container->has($id) || isset($this->container->getRemovedIds()[$id])) {
$msg[] = 'even though it exists in the app\'s container,';
} else {
try {
$this->container->get($id);
$class = null;
} catch (ServiceNotFoundException $e) {
if ($e->getAlternatives()) {
$msg[] = sprintf('did you mean %s? Anyway,', $this->formatAlternatives($e->getAlternatives(), 'or'));
} else {
$class = null;
}
}
}
if ($externalId) {
$msg[] = sprintf('the container inside "%s" is a smaller service locator that %s', $externalId, $this->formatAlternatives());
} else {
$msg[] = sprintf('the current service locator %s', $this->formatAlternatives());
}
if (!$class) {
// no-op
} elseif (is_subclass_of($class, ServiceSubscriberInterface::class)) {
$msg[] = sprintf('Unless you need extra laziness, try using dependency injection instead. Otherwise, you need to declare it using "%s::getSubscribedServices()".', preg_replace('/([^\\\\]++\\\\)++/', '', $class));
} else {
$msg[] = 'Try using dependency injection instead.';
}
return new ServiceNotFoundException($id, end($this->loading) ?: null, null, [], implode(' ', $msg));
}
private function createCircularReferenceException(string $id, array $path): ContainerExceptionInterface
{
return new ServiceCircularReferenceException($id, $path);
}
private function formatAlternatives(?array $alternatives = null, string $separator = 'and'): string
{
$format = '"%s"%s';
if (null === $alternatives) {
if (!$alternatives = array_keys($this->factories)) {
return 'is empty...';
}
$format = sprintf('only knows about the %s service%s.', $format, 1 < \count($alternatives) ? 's' : '');
}
$last = array_pop($alternatives);
return sprintf($format, $alternatives ? implode('", "', $alternatives) : $last, $alternatives ? sprintf(' %s "%s"', $separator, $last) : '');
}
}
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| Argument | Folder | 0755 |
|
|
| Attribute | Folder | 0755 |
|
|
| Compiler | Folder | 0755 |
|
|
| Config | Folder | 0755 |
|
|
| Dumper | Folder | 0755 |
|
|
| Exception | Folder | 0755 |
|
|
| Extension | Folder | 0755 |
|
|
| LazyProxy | Folder | 0755 |
|
|
| Loader | Folder | 0755 |
|
|
| ParameterBag | Folder | 0755 |
|
|
| Alias.php | File | 2.9 KB | 0644 |
|
| ChildDefinition.php | File | 2.56 KB | 0644 |
|
| Container.php | File | 13.6 KB | 0644 |
|
| ContainerAwareInterface.php | File | 681 B | 0644 |
|
| ContainerAwareTrait.php | File | 1.06 KB | 0644 |
|
| ContainerBuilder.php | File | 59.07 KB | 0644 |
|
| ContainerInterface.php | File | 2.28 KB | 0644 |
|
| Definition.php | File | 20.17 KB | 0644 |
|
| EnvVarLoaderInterface.php | File | 654 B | 0644 |
|
| EnvVarProcessor.php | File | 13.01 KB | 0644 |
|
| EnvVarProcessorInterface.php | File | 1.24 KB | 0644 |
|
| ExpressionLanguage.php | File | 1.05 KB | 0644 |
|
| ExpressionLanguageProvider.php | File | 2.12 KB | 0644 |
|
| Parameter.php | File | 601 B | 0644 |
|
| Reference.php | File | 945 B | 0644 |
|
| ReverseContainer.php | File | 2.4 KB | 0644 |
|
| ServiceLocator.php | File | 5.3 KB | 0644 |
|
| TaggedContainerInterface.php | File | 688 B | 0644 |
|
| TypedReference.php | File | 1.54 KB | 0644 |
|
| Variable.php | File | 692 B | 0644 |
|
| autoload.php | File | 25.98 KB | 0644 |
|