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)) {
|
||||
|
||||
36
vendor/symfony/contracts/Service/ServiceProviderInterface.php
vendored
Normal file
36
vendor/symfony/contracts/Service/ServiceProviderInterface.php
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
<?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\Contracts\Service;
|
||||
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
/**
|
||||
* A ServiceProviderInterface exposes the identifiers and the types of services provided by a container.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
* @author Mateusz Sip <mateusz.sip@gmail.com>
|
||||
*/
|
||||
interface ServiceProviderInterface extends ContainerInterface
|
||||
{
|
||||
/**
|
||||
* Returns an associative array of service types keyed by the identifiers provided by the current container.
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* * ['logger' => 'Psr\Log\LoggerInterface'] means the object provides a service named "logger" that implements Psr\Log\LoggerInterface
|
||||
* * ['foo' => '?'] means the container provides service name "foo" of unspecified type
|
||||
* * ['bar' => '?Bar\Baz'] means the container provides a service "bar" of type Bar\Baz|null
|
||||
*
|
||||
* @return string[] The provided service types, keyed by service names
|
||||
*/
|
||||
public function getProvidedServices(): array;
|
||||
}
|
||||
@@ -33,19 +33,19 @@ interface ServiceSubscriberInterface
|
||||
*
|
||||
* For mandatory dependencies:
|
||||
*
|
||||
* * array('logger' => 'Psr\Log\LoggerInterface') means the objects use the "logger" name
|
||||
* * ['logger' => 'Psr\Log\LoggerInterface'] means the objects use the "logger" name
|
||||
* internally to fetch a service which must implement Psr\Log\LoggerInterface.
|
||||
* * array('loggers' => 'Psr\Log\LoggerInterface[]') means the objects use the "loggers" name
|
||||
* * ['loggers' => 'Psr\Log\LoggerInterface[]'] means the objects use the "loggers" name
|
||||
* internally to fetch an iterable of Psr\Log\LoggerInterface instances.
|
||||
* * array('Psr\Log\LoggerInterface') is a shortcut for
|
||||
* * array('Psr\Log\LoggerInterface' => 'Psr\Log\LoggerInterface')
|
||||
* * ['Psr\Log\LoggerInterface'] is a shortcut for
|
||||
* * ['Psr\Log\LoggerInterface' => 'Psr\Log\LoggerInterface']
|
||||
*
|
||||
* otherwise:
|
||||
*
|
||||
* * array('logger' => '?Psr\Log\LoggerInterface') denotes an optional dependency
|
||||
* * array('loggers' => '?Psr\Log\LoggerInterface[]') denotes an optional iterable dependency
|
||||
* * array('?Psr\Log\LoggerInterface') is a shortcut for
|
||||
* * array('Psr\Log\LoggerInterface' => '?Psr\Log\LoggerInterface')
|
||||
* * ['logger' => '?Psr\Log\LoggerInterface'] denotes an optional dependency
|
||||
* * ['loggers' => '?Psr\Log\LoggerInterface[]'] denotes an optional iterable dependency
|
||||
* * ['?Psr\Log\LoggerInterface'] is a shortcut for
|
||||
* * ['Psr\Log\LoggerInterface' => '?Psr\Log\LoggerInterface']
|
||||
*
|
||||
* @return array The required service types, optionally keyed by service names
|
||||
*/
|
||||
|
||||
@@ -32,7 +32,7 @@ trait ServiceSubscriberTrait
|
||||
return $services;
|
||||
}
|
||||
|
||||
$services = \is_callable(array('parent', __FUNCTION__)) ? parent::getSubscribedServices() : array();
|
||||
$services = \is_callable(['parent', __FUNCTION__]) ? parent::getSubscribedServices() : [];
|
||||
|
||||
foreach ((new \ReflectionClass(self::class))->getMethods() as $method) {
|
||||
if ($method->isStatic() || $method->isAbstract() || $method->isGenerator() || $method->isInternal() || $method->getNumberOfRequiredParameters()) {
|
||||
@@ -54,7 +54,7 @@ trait ServiceSubscriberTrait
|
||||
{
|
||||
$this->container = $container;
|
||||
|
||||
if (\is_callable(array('parent', __FUNCTION__))) {
|
||||
if (\is_callable(['parent', __FUNCTION__])) {
|
||||
return parent::setContainer($container);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user