first commit
This commit is contained in:
25
vendor/symfony/service-contracts/Attribute/Required.php
vendored
Normal file
25
vendor/symfony/service-contracts/Attribute/Required.php
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
<?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\Attribute;
|
||||
|
||||
/**
|
||||
* A required dependency.
|
||||
*
|
||||
* This attribute indicates that a property holds a required dependency. The annotated property or method should be
|
||||
* considered during the instantiation process of the containing class.
|
||||
*
|
||||
* @author Alexander M. Turek <me@derrabus.de>
|
||||
*/
|
||||
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY)]
|
||||
final class Required
|
||||
{
|
||||
}
|
47
vendor/symfony/service-contracts/Attribute/SubscribedService.php
vendored
Normal file
47
vendor/symfony/service-contracts/Attribute/SubscribedService.php
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
<?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\Attribute;
|
||||
|
||||
use Symfony\Contracts\Service\ServiceSubscriberInterface;
|
||||
use Symfony\Contracts\Service\ServiceSubscriberTrait;
|
||||
|
||||
/**
|
||||
* For use as the return value for {@see ServiceSubscriberInterface}.
|
||||
*
|
||||
* @example new SubscribedService('http_client', HttpClientInterface::class, false, new Target('githubApi'))
|
||||
*
|
||||
* Use with {@see ServiceSubscriberTrait} to mark a method's return type
|
||||
* as a subscribed service.
|
||||
*
|
||||
* @author Kevin Bond <kevinbond@gmail.com>
|
||||
*/
|
||||
#[\Attribute(\Attribute::TARGET_METHOD)]
|
||||
final class SubscribedService
|
||||
{
|
||||
/** @var object[] */
|
||||
public array $attributes;
|
||||
|
||||
/**
|
||||
* @param string|null $key The key to use for the service
|
||||
* @param class-string|null $type The service class
|
||||
* @param bool $nullable Whether the service is optional
|
||||
* @param object|object[] $attributes One or more dependency injection attributes to use
|
||||
*/
|
||||
public function __construct(
|
||||
public ?string $key = null,
|
||||
public ?string $type = null,
|
||||
public bool $nullable = false,
|
||||
array|object $attributes = [],
|
||||
) {
|
||||
$this->attributes = \is_array($attributes) ? $attributes : [$attributes];
|
||||
}
|
||||
}
|
5
vendor/symfony/service-contracts/CHANGELOG.md
vendored
Normal file
5
vendor/symfony/service-contracts/CHANGELOG.md
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
CHANGELOG
|
||||
=========
|
||||
|
||||
The changelog is maintained for all Symfony contracts at the following URL:
|
||||
https://github.com/symfony/contracts/blob/main/CHANGELOG.md
|
19
vendor/symfony/service-contracts/LICENSE
vendored
Normal file
19
vendor/symfony/service-contracts/LICENSE
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
Copyright (c) 2018-present Fabien Potencier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
9
vendor/symfony/service-contracts/README.md
vendored
Normal file
9
vendor/symfony/service-contracts/README.md
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
Symfony Service Contracts
|
||||
=========================
|
||||
|
||||
A set of abstractions extracted out of the Symfony components.
|
||||
|
||||
Can be used to build on semantics that the Symfony components proved useful and
|
||||
that already have battle tested implementations.
|
||||
|
||||
See https://github.com/symfony/contracts/blob/main/README.md for more information.
|
33
vendor/symfony/service-contracts/ResetInterface.php
vendored
Normal file
33
vendor/symfony/service-contracts/ResetInterface.php
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
<?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;
|
||||
|
||||
/**
|
||||
* Provides a way to reset an object to its initial state.
|
||||
*
|
||||
* When calling the "reset()" method on an object, it should be put back to its
|
||||
* initial state. This usually means clearing any internal buffers and forwarding
|
||||
* the call to internal dependencies. All properties of the object should be put
|
||||
* back to the same state it had when it was first ready to use.
|
||||
*
|
||||
* This method could be called, for example, to recycle objects that are used as
|
||||
* services, so that they can be used to handle several requests in the same
|
||||
* process loop (note that we advise making your services stateless instead of
|
||||
* implementing this interface when possible.)
|
||||
*/
|
||||
interface ResetInterface
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function reset();
|
||||
}
|
115
vendor/symfony/service-contracts/ServiceLocatorTrait.php
vendored
Normal file
115
vendor/symfony/service-contracts/ServiceLocatorTrait.php
vendored
Normal file
@ -0,0 +1,115 @@
|
||||
<?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\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
// Help opcache.preload discover always-needed symbols
|
||||
class_exists(ContainerExceptionInterface::class);
|
||||
class_exists(NotFoundExceptionInterface::class);
|
||||
|
||||
/**
|
||||
* A trait to help implement ServiceProviderInterface.
|
||||
*
|
||||
* @author Robin Chalas <robin.chalas@gmail.com>
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
trait ServiceLocatorTrait
|
||||
{
|
||||
private array $factories;
|
||||
private array $loading = [];
|
||||
private array $providedTypes;
|
||||
|
||||
/**
|
||||
* @param array<string, callable> $factories
|
||||
*/
|
||||
public function __construct(array $factories)
|
||||
{
|
||||
$this->factories = $factories;
|
||||
}
|
||||
|
||||
public function has(string $id): bool
|
||||
{
|
||||
return isset($this->factories[$id]);
|
||||
}
|
||||
|
||||
public function get(string $id): mixed
|
||||
{
|
||||
if (!isset($this->factories[$id])) {
|
||||
throw $this->createNotFoundException($id);
|
||||
}
|
||||
|
||||
if (isset($this->loading[$id])) {
|
||||
$ids = array_values($this->loading);
|
||||
$ids = \array_slice($this->loading, array_search($id, $ids));
|
||||
$ids[] = $id;
|
||||
|
||||
throw $this->createCircularReferenceException($id, $ids);
|
||||
}
|
||||
|
||||
$this->loading[$id] = $id;
|
||||
try {
|
||||
return $this->factories[$id]($this);
|
||||
} finally {
|
||||
unset($this->loading[$id]);
|
||||
}
|
||||
}
|
||||
|
||||
public function getProvidedServices(): array
|
||||
{
|
||||
if (!isset($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 instanceof \ReflectionNamedType ? $type->getName() : $type) : '?';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->providedTypes;
|
||||
}
|
||||
|
||||
private function createNotFoundException(string $id): NotFoundExceptionInterface
|
||||
{
|
||||
if (!$alternatives = array_keys($this->factories)) {
|
||||
$message = 'is empty...';
|
||||
} else {
|
||||
$last = array_pop($alternatives);
|
||||
if ($alternatives) {
|
||||
$message = sprintf('only knows about the "%s" and "%s" services.', implode('", "', $alternatives), $last);
|
||||
} else {
|
||||
$message = sprintf('only knows about the "%s" service.', $last);
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->loading) {
|
||||
$message = sprintf('The service "%s" has a dependency on a non-existent service "%s". This locator %s', end($this->loading), $id, $message);
|
||||
} else {
|
||||
$message = sprintf('Service "%s" not found: the current service locator %s', $id, $message);
|
||||
}
|
||||
|
||||
return new class($message) extends \InvalidArgumentException implements NotFoundExceptionInterface {
|
||||
};
|
||||
}
|
||||
|
||||
private function createCircularReferenceException(string $id, array $path): ContainerExceptionInterface
|
||||
{
|
||||
return new class(sprintf('Circular reference detected for service "%s", path: "%s".', $id, implode(' -> ', $path))) extends \RuntimeException implements ContainerExceptionInterface {
|
||||
};
|
||||
}
|
||||
}
|
45
vendor/symfony/service-contracts/ServiceProviderInterface.php
vendored
Normal file
45
vendor/symfony/service-contracts/ServiceProviderInterface.php
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
<?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>
|
||||
*
|
||||
* @template-covariant T of mixed
|
||||
*/
|
||||
interface ServiceProviderInterface extends ContainerInterface
|
||||
{
|
||||
/**
|
||||
* @return T
|
||||
*/
|
||||
public function get(string $id): mixed;
|
||||
|
||||
public function has(string $id): bool;
|
||||
|
||||
/**
|
||||
* 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 array<string, string> The provided service types, keyed by service names
|
||||
*/
|
||||
public function getProvidedServices(): array;
|
||||
}
|
62
vendor/symfony/service-contracts/ServiceSubscriberInterface.php
vendored
Normal file
62
vendor/symfony/service-contracts/ServiceSubscriberInterface.php
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
<?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 Symfony\Contracts\Service\Attribute\SubscribedService;
|
||||
|
||||
/**
|
||||
* A ServiceSubscriber exposes its dependencies via the static {@link getSubscribedServices} method.
|
||||
*
|
||||
* The getSubscribedServices method returns an array of service types required by such instances,
|
||||
* optionally keyed by the service names used internally. Service types that start with an interrogation
|
||||
* mark "?" are optional, while the other ones are mandatory service dependencies.
|
||||
*
|
||||
* The injected service locators SHOULD NOT allow access to any other services not specified by the method.
|
||||
*
|
||||
* It is expected that ServiceSubscriber instances consume PSR-11-based service locators internally.
|
||||
* This interface does not dictate any injection method for these service locators, although constructor
|
||||
* injection is recommended.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
interface ServiceSubscriberInterface
|
||||
{
|
||||
/**
|
||||
* Returns an array of service types (or {@see SubscribedService} objects) required
|
||||
* by such instances, optionally keyed by the service names used internally.
|
||||
*
|
||||
* For mandatory dependencies:
|
||||
*
|
||||
* * ['logger' => 'Psr\Log\LoggerInterface'] means the objects use the "logger" name
|
||||
* internally to fetch a service which must implement Psr\Log\LoggerInterface.
|
||||
* * ['loggers' => 'Psr\Log\LoggerInterface[]'] means the objects use the "loggers" name
|
||||
* internally to fetch an iterable of Psr\Log\LoggerInterface instances.
|
||||
* * ['Psr\Log\LoggerInterface'] is a shortcut for
|
||||
* * ['Psr\Log\LoggerInterface' => 'Psr\Log\LoggerInterface']
|
||||
*
|
||||
* otherwise:
|
||||
*
|
||||
* * ['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']
|
||||
*
|
||||
* additionally, an array of {@see SubscribedService}'s can be returned:
|
||||
*
|
||||
* * [new SubscribedService('logger', Psr\Log\LoggerInterface::class)]
|
||||
* * [new SubscribedService(type: Psr\Log\LoggerInterface::class, nullable: true)]
|
||||
* * [new SubscribedService('http_client', HttpClientInterface::class, attributes: new Target('githubApi'))]
|
||||
*
|
||||
* @return string[]|SubscribedService[] The required service types, optionally keyed by service names
|
||||
*/
|
||||
public static function getSubscribedServices(): array;
|
||||
}
|
78
vendor/symfony/service-contracts/ServiceSubscriberTrait.php
vendored
Normal file
78
vendor/symfony/service-contracts/ServiceSubscriberTrait.php
vendored
Normal file
@ -0,0 +1,78 @@
|
||||
<?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;
|
||||
use Symfony\Contracts\Service\Attribute\Required;
|
||||
use Symfony\Contracts\Service\Attribute\SubscribedService;
|
||||
|
||||
/**
|
||||
* Implementation of ServiceSubscriberInterface that determines subscribed services from
|
||||
* method return types. Service ids are available as "ClassName::methodName".
|
||||
*
|
||||
* @author Kevin Bond <kevinbond@gmail.com>
|
||||
*/
|
||||
trait ServiceSubscriberTrait
|
||||
{
|
||||
/** @var ContainerInterface */
|
||||
protected $container;
|
||||
|
||||
public static function getSubscribedServices(): array
|
||||
{
|
||||
$services = method_exists(get_parent_class(self::class) ?: '', __FUNCTION__) ? parent::getSubscribedServices() : [];
|
||||
|
||||
foreach ((new \ReflectionClass(self::class))->getMethods() as $method) {
|
||||
if (self::class !== $method->getDeclaringClass()->name) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!$attribute = $method->getAttributes(SubscribedService::class)[0] ?? null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($method->isStatic() || $method->isAbstract() || $method->isGenerator() || $method->isInternal() || $method->getNumberOfRequiredParameters()) {
|
||||
throw new \LogicException(sprintf('Cannot use "%s" on method "%s::%s()" (can only be used on non-static, non-abstract methods with no parameters).', SubscribedService::class, self::class, $method->name));
|
||||
}
|
||||
|
||||
if (!$returnType = $method->getReturnType()) {
|
||||
throw new \LogicException(sprintf('Cannot use "%s" on methods without a return type in "%s::%s()".', SubscribedService::class, $method->name, self::class));
|
||||
}
|
||||
|
||||
/* @var SubscribedService $attribute */
|
||||
$attribute = $attribute->newInstance();
|
||||
$attribute->key ??= self::class.'::'.$method->name;
|
||||
$attribute->type ??= $returnType instanceof \ReflectionNamedType ? $returnType->getName() : (string) $returnType;
|
||||
$attribute->nullable = $returnType->allowsNull();
|
||||
|
||||
if ($attribute->attributes) {
|
||||
$services[] = $attribute;
|
||||
} else {
|
||||
$services[$attribute->key] = ($attribute->nullable ? '?' : '').$attribute->type;
|
||||
}
|
||||
}
|
||||
|
||||
return $services;
|
||||
}
|
||||
|
||||
#[Required]
|
||||
public function setContainer(ContainerInterface $container): ?ContainerInterface
|
||||
{
|
||||
$ret = null;
|
||||
if (method_exists(get_parent_class(self::class) ?: '', __FUNCTION__)) {
|
||||
$ret = parent::setContainer($container);
|
||||
}
|
||||
|
||||
$this->container = $container;
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
23
vendor/symfony/service-contracts/Test/ServiceLocatorTest.php
vendored
Normal file
23
vendor/symfony/service-contracts/Test/ServiceLocatorTest.php
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
<?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\Test;
|
||||
|
||||
class_alias(ServiceLocatorTestCase::class, ServiceLocatorTest::class);
|
||||
|
||||
if (false) {
|
||||
/**
|
||||
* @deprecated since PHPUnit 9.6
|
||||
*/
|
||||
class ServiceLocatorTest
|
||||
{
|
||||
}
|
||||
}
|
92
vendor/symfony/service-contracts/Test/ServiceLocatorTestCase.php
vendored
Normal file
92
vendor/symfony/service-contracts/Test/ServiceLocatorTestCase.php
vendored
Normal file
@ -0,0 +1,92 @@
|
||||
<?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\Test;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Symfony\Contracts\Service\ServiceLocatorTrait;
|
||||
|
||||
abstract class ServiceLocatorTestCase extends TestCase
|
||||
{
|
||||
protected function getServiceLocator(array $factories): ContainerInterface
|
||||
{
|
||||
return new class($factories) implements ContainerInterface {
|
||||
use ServiceLocatorTrait;
|
||||
};
|
||||
}
|
||||
|
||||
public function testHas()
|
||||
{
|
||||
$locator = $this->getServiceLocator([
|
||||
'foo' => fn () => 'bar',
|
||||
'bar' => fn () => 'baz',
|
||||
fn () => 'dummy',
|
||||
]);
|
||||
|
||||
$this->assertTrue($locator->has('foo'));
|
||||
$this->assertTrue($locator->has('bar'));
|
||||
$this->assertFalse($locator->has('dummy'));
|
||||
}
|
||||
|
||||
public function testGet()
|
||||
{
|
||||
$locator = $this->getServiceLocator([
|
||||
'foo' => fn () => 'bar',
|
||||
'bar' => fn () => 'baz',
|
||||
]);
|
||||
|
||||
$this->assertSame('bar', $locator->get('foo'));
|
||||
$this->assertSame('baz', $locator->get('bar'));
|
||||
}
|
||||
|
||||
public function testGetDoesNotMemoize()
|
||||
{
|
||||
$i = 0;
|
||||
$locator = $this->getServiceLocator([
|
||||
'foo' => function () use (&$i) {
|
||||
++$i;
|
||||
|
||||
return 'bar';
|
||||
},
|
||||
]);
|
||||
|
||||
$this->assertSame('bar', $locator->get('foo'));
|
||||
$this->assertSame('bar', $locator->get('foo'));
|
||||
$this->assertSame(2, $i);
|
||||
}
|
||||
|
||||
public function testThrowsOnUndefinedInternalService()
|
||||
{
|
||||
if (!$this->getExpectedException()) {
|
||||
$this->expectException(\Psr\Container\NotFoundExceptionInterface::class);
|
||||
$this->expectExceptionMessage('The service "foo" has a dependency on a non-existent service "bar". This locator only knows about the "foo" service.');
|
||||
}
|
||||
$locator = $this->getServiceLocator([
|
||||
'foo' => function () use (&$locator) { return $locator->get('bar'); },
|
||||
]);
|
||||
|
||||
$locator->get('foo');
|
||||
}
|
||||
|
||||
public function testThrowsOnCircularReference()
|
||||
{
|
||||
$this->expectException(\Psr\Container\ContainerExceptionInterface::class);
|
||||
$this->expectExceptionMessage('Circular reference detected for service "bar", path: "bar -> baz -> bar".');
|
||||
$locator = $this->getServiceLocator([
|
||||
'foo' => function () use (&$locator) { return $locator->get('bar'); },
|
||||
'bar' => function () use (&$locator) { return $locator->get('baz'); },
|
||||
'baz' => function () use (&$locator) { return $locator->get('bar'); },
|
||||
]);
|
||||
|
||||
$locator->get('foo');
|
||||
}
|
||||
}
|
41
vendor/symfony/service-contracts/composer.json
vendored
Normal file
41
vendor/symfony/service-contracts/composer.json
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
{
|
||||
"name": "symfony/service-contracts",
|
||||
"type": "library",
|
||||
"description": "Generic abstractions related to writing services",
|
||||
"keywords": ["abstractions", "contracts", "decoupling", "interfaces", "interoperability", "standards"],
|
||||
"homepage": "https://symfony.com",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nicolas Grekas",
|
||||
"email": "p@tchwork.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=8.1",
|
||||
"psr/container": "^1.1|^2.0"
|
||||
},
|
||||
"conflict": {
|
||||
"ext-psr": "<1.1|>=2"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": { "Symfony\\Contracts\\Service\\": "" },
|
||||
"exclude-from-classmap": [
|
||||
"/Test/"
|
||||
]
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-main": "3.4-dev"
|
||||
},
|
||||
"thanks": {
|
||||
"name": "symfony/contracts",
|
||||
"url": "https://github.com/symfony/contracts"
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user