mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-30 14:08:46 +02:00
N°6934 - Symfony 6.4 - upgrade Symfony bundles to 6.4 (#580)
* Update Symfony lib to version ~6.4.0 * Update code missing return type * Add an iTop general configuration entry to store application secret (Symfony mandatory parameter) * Use dependency injection in ExceptionListener & UserProvider classes
This commit is contained in:
@@ -23,22 +23,21 @@ 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
|
||||
class ServiceLocator implements ServiceProviderInterface, \Countable
|
||||
{
|
||||
use ServiceLocatorTrait {
|
||||
get as private doGet;
|
||||
}
|
||||
|
||||
private $externalId;
|
||||
private $container;
|
||||
private ?string $externalId = null;
|
||||
private ?Container $container = null;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function get(string $id)
|
||||
public function get(string $id): mixed
|
||||
{
|
||||
if (!$this->externalId) {
|
||||
return $this->doGet($id);
|
||||
@@ -55,13 +54,15 @@ class ServiceLocator implements ServiceProviderInterface
|
||||
}
|
||||
|
||||
$r = new \ReflectionProperty($e, 'message');
|
||||
$r->setAccessible(true);
|
||||
$r->setValue($e, $message);
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function __invoke(string $id)
|
||||
{
|
||||
return isset($this->factories[$id]) ? $this->get($id) : null;
|
||||
@@ -69,10 +70,8 @@ class ServiceLocator implements ServiceProviderInterface
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function withContext(string $externalId, Container $container): self
|
||||
public function withContext(string $externalId, Container $container): static
|
||||
{
|
||||
$locator = clone $this;
|
||||
$locator->externalId = $externalId;
|
||||
@@ -81,6 +80,11 @@ class ServiceLocator implements ServiceProviderInterface
|
||||
return $locator;
|
||||
}
|
||||
|
||||
public function count(): int
|
||||
{
|
||||
return \count($this->getProvidedServices());
|
||||
}
|
||||
|
||||
private function createNotFoundException(string $id): NotFoundExceptionInterface
|
||||
{
|
||||
if ($this->loading) {
|
||||
@@ -90,7 +94,7 @@ class ServiceLocator implements ServiceProviderInterface
|
||||
}
|
||||
|
||||
$class = debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT | \DEBUG_BACKTRACE_IGNORE_ARGS, 4);
|
||||
$class = isset($class[3]['object']) ? \get_class($class[3]['object']) : null;
|
||||
$class = isset($class[3]['object']) ? $class[3]['object']::class : null;
|
||||
$externalId = $this->externalId ?: $class;
|
||||
|
||||
$msg = [];
|
||||
|
||||
Reference in New Issue
Block a user