updated packages
This commit is contained in:
@@ -15,7 +15,7 @@ use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* A trait to help implement PSR-11 service locators.
|
||||
* A trait to help implement ServiceProviderInterface.
|
||||
*
|
||||
* @author Robin Chalas <robin.chalas@gmail.com>
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
@@ -23,7 +23,8 @@ use Psr\Container\NotFoundExceptionInterface;
|
||||
trait ServiceLocatorTrait
|
||||
{
|
||||
private $factories;
|
||||
private $loading = array();
|
||||
private $loading = [];
|
||||
private $providedTypes;
|
||||
|
||||
/**
|
||||
* @param callable[] $factories
|
||||
@@ -66,6 +67,28 @@ trait ServiceLocatorTrait
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getProvidedServices(): array
|
||||
{
|
||||
if (null === $this->providedTypes) {
|
||||
$this->providedTypes = [];
|
||||
|
||||
foreach ($this->factories as $name => $factory) {
|
||||
if (!\is_callable($factory)) {
|
||||
$this->providedTypes[$name] = '?';
|
||||
} else {
|
||||
$type = (new \ReflectionFunction($factory))->getReturnType();
|
||||
|
||||
$this->providedTypes[$name] = $type ? ($type->allowsNull() ? '?' : '').$type->getName() : '?';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->providedTypes;
|
||||
}
|
||||
|
||||
private function createNotFoundException(string $id): NotFoundExceptionInterface
|
||||
{
|
||||
if (!$alternatives = array_keys($this->factories)) {
|
||||
|
||||
Reference in New Issue
Block a user