Changed source root directory

This commit is contained in:
2026-03-05 16:30:11 +01:00
parent dc85447ee1
commit 538f85d7a2
5868 changed files with 749734 additions and 99 deletions

View File

@@ -0,0 +1,40 @@
<?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 YoastSEO_Vendor\Symfony\Component\DependencyInjection\Argument;
/**
* @internal
*/
class RewindableGenerator implements \IteratorAggregate, \Countable
{
private $generator;
private $count;
/**
* @param int|callable $count
*/
public function __construct(callable $generator, $count)
{
$this->generator = $generator;
$this->count = $count;
}
public function getIterator() : \Traversable
{
$g = $this->generator;
return $g();
}
public function count() : int
{
if (\is_callable($count = $this->count)) {
$this->count = $count();
}
return $this->count;
}
}

View File

@@ -0,0 +1,49 @@
<?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 YoastSEO_Vendor\Symfony\Component\DependencyInjection\Argument;
use YoastSEO_Vendor\Symfony\Component\DependencyInjection\ServiceLocator as BaseServiceLocator;
/**
* @author Nicolas Grekas <p@tchwork.com>
*
* @internal
*/
class ServiceLocator extends \YoastSEO_Vendor\Symfony\Component\DependencyInjection\ServiceLocator
{
private $factory;
private $serviceMap;
private $serviceTypes;
public function __construct(\Closure $factory, array $serviceMap, ?array $serviceTypes = null)
{
$this->factory = $factory;
$this->serviceMap = $serviceMap;
$this->serviceTypes = $serviceTypes;
parent::__construct($serviceMap);
}
/**
* {@inheritdoc}
*
* @return mixed
*/
public function get(string $id)
{
return isset($this->serviceMap[$id]) ? ($this->factory)(...$this->serviceMap[$id]) : parent::get($id);
}
/**
* {@inheritdoc}
*/
public function getProvidedServices() : array
{
return $this->serviceTypes ?? ($this->serviceTypes = \array_map(function () {
return '?';
}, $this->serviceMap));
}
}

View File

@@ -0,0 +1,39 @@
<?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 YoastSEO_Vendor\Symfony\Component\DependencyInjection\Argument;
use YoastSEO_Vendor\Symfony\Component\DependencyInjection\Reference;
/**
* Represents a closure acting as a service locator.
*
* @author Nicolas Grekas <p@tchwork.com>
*/
class ServiceLocatorArgument implements \YoastSEO_Vendor\Symfony\Component\DependencyInjection\Argument\ArgumentInterface
{
use ReferenceSetArgumentTrait;
private $taggedIteratorArgument;
/**
* @param Reference[]|TaggedIteratorArgument $values
*/
public function __construct($values = [])
{
if ($values instanceof \YoastSEO_Vendor\Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument) {
$this->taggedIteratorArgument = $values;
$this->values = [];
} else {
$this->setValues($values);
}
}
public function getTaggedIteratorArgument() : ?\YoastSEO_Vendor\Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument
{
return $this->taggedIteratorArgument;
}
}

View File

@@ -0,0 +1,389 @@
<?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 YoastSEO_Vendor\Symfony\Component\DependencyInjection;
use YoastSEO_Vendor\Symfony\Component\DependencyInjection\Argument\RewindableGenerator;
use YoastSEO_Vendor\Symfony\Component\DependencyInjection\Argument\ServiceLocator as ArgumentServiceLocator;
use YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\EnvNotFoundException;
use YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\ParameterCircularReferenceException;
use YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\RuntimeException;
use YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException;
use YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
use YoastSEO_Vendor\Symfony\Component\DependencyInjection\ParameterBag\EnvPlaceholderParameterBag;
use YoastSEO_Vendor\Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
use YoastSEO_Vendor\Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use YoastSEO_Vendor\Symfony\Contracts\Service\ResetInterface;
// Help opcache.preload discover always-needed symbols
\class_exists(\YoastSEO_Vendor\Symfony\Component\DependencyInjection\Argument\RewindableGenerator::class);
\class_exists(\YoastSEO_Vendor\Symfony\Component\DependencyInjection\Argument\ServiceLocator::class);
/**
* Container is a dependency injection container.
*
* It gives access to object instances (services).
* Services and parameters are simple key/pair stores.
* The container can have four possible behaviors when a service
* does not exist (or is not initialized for the last case):
*
* * EXCEPTION_ON_INVALID_REFERENCE: Throws an exception at compilation time (the default)
* * NULL_ON_INVALID_REFERENCE: Returns null
* * IGNORE_ON_INVALID_REFERENCE: Ignores the wrapping command asking for the reference
* (for instance, ignore a setter if the service does not exist)
* * IGNORE_ON_UNINITIALIZED_REFERENCE: Ignores/returns null for uninitialized services or invalid references
* * RUNTIME_EXCEPTION_ON_INVALID_REFERENCE: Throws an exception at runtime
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
class Container implements \YoastSEO_Vendor\Symfony\Component\DependencyInjection\ContainerInterface, \YoastSEO_Vendor\Symfony\Contracts\Service\ResetInterface
{
protected $parameterBag;
protected $services = [];
protected $privates = [];
protected $fileMap = [];
protected $methodMap = [];
protected $factories = [];
protected $aliases = [];
protected $loading = [];
protected $resolving = [];
protected $syntheticIds = [];
private $envCache = [];
private $compiled = \false;
private $getEnv;
public function __construct(?\YoastSEO_Vendor\Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface $parameterBag = null)
{
$this->parameterBag = $parameterBag ?? new \YoastSEO_Vendor\Symfony\Component\DependencyInjection\ParameterBag\EnvPlaceholderParameterBag();
}
/**
* Compiles the container.
*
* This method does two things:
*
* * Parameter values are resolved;
* * The parameter bag is frozen.
*/
public function compile()
{
$this->parameterBag->resolve();
$this->parameterBag = new \YoastSEO_Vendor\Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag($this->parameterBag->all());
$this->compiled = \true;
}
/**
* Returns true if the container is compiled.
*
* @return bool
*/
public function isCompiled()
{
return $this->compiled;
}
/**
* Gets the service container parameter bag.
*
* @return ParameterBagInterface
*/
public function getParameterBag()
{
return $this->parameterBag;
}
/**
* Gets a parameter.
*
* @return array|bool|string|int|float|\UnitEnum|null
*
* @throws InvalidArgumentException if the parameter is not defined
*/
public function getParameter(string $name)
{
return $this->parameterBag->get($name);
}
/**
* @return bool
*/
public function hasParameter(string $name)
{
return $this->parameterBag->has($name);
}
/**
* Sets a parameter.
*
* @param string $name The parameter name
* @param array|bool|string|int|float|\UnitEnum|null $value The parameter value
*/
public function setParameter(string $name, $value)
{
$this->parameterBag->set($name, $value);
}
/**
* Sets a service.
*
* Setting a synthetic service to null resets it: has() returns false and get()
* behaves in the same way as if the service was never created.
*/
public function set(string $id, ?object $service)
{
// Runs the internal initializer; used by the dumped container to include always-needed files
if (isset($this->privates['service_container']) && $this->privates['service_container'] instanceof \Closure) {
$initialize = $this->privates['service_container'];
unset($this->privates['service_container']);
$initialize();
}
if ('service_container' === $id) {
throw new \YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException('You cannot set service "service_container".');
}
if (!(isset($this->fileMap[$id]) || isset($this->methodMap[$id]))) {
if (isset($this->syntheticIds[$id]) || !isset($this->getRemovedIds()[$id])) {
// no-op
} elseif (null === $service) {
throw new \YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('The "%s" service is private, you cannot unset it.', $id));
} else {
throw new \YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('The "%s" service is private, you cannot replace it.', $id));
}
} elseif (isset($this->services[$id])) {
throw new \YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('The "%s" service is already initialized, you cannot replace it.', $id));
}
if (isset($this->aliases[$id])) {
unset($this->aliases[$id]);
}
if (null === $service) {
unset($this->services[$id]);
return;
}
$this->services[$id] = $service;
}
/**
* Returns true if the given service is defined.
*
* @param string $id The service identifier
*
* @return bool
*/
public function has(string $id)
{
if (isset($this->aliases[$id])) {
$id = $this->aliases[$id];
}
if (isset($this->services[$id])) {
return \true;
}
if ('service_container' === $id) {
return \true;
}
return isset($this->fileMap[$id]) || isset($this->methodMap[$id]);
}
/**
* Gets a service.
*
* @return object|null
*
* @throws ServiceCircularReferenceException When a circular reference is detected
* @throws ServiceNotFoundException When the service is not defined
* @throws \Exception if an exception has been thrown when the service has been resolved
*
* @see Reference
*/
public function get(string $id, int $invalidBehavior = 1)
{
return $this->services[$id] ?? $this->services[$id = $this->aliases[$id] ?? $id] ?? ('service_container' === $id ? $this : ($this->factories[$id] ?? [$this, 'make'])($id, $invalidBehavior));
}
/**
* Creates a service.
*
* As a separate method to allow "get()" to use the really fast `??` operator.
*/
private function make(string $id, int $invalidBehavior)
{
if (isset($this->loading[$id])) {
throw new \YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException($id, \array_merge(\array_keys($this->loading), [$id]));
}
$this->loading[$id] = \true;
try {
if (isset($this->fileMap[$id])) {
return 4 === $invalidBehavior ? null : $this->load($this->fileMap[$id]);
} elseif (isset($this->methodMap[$id])) {
return 4 === $invalidBehavior ? null : $this->{$this->methodMap[$id]}();
}
} catch (\Exception $e) {
unset($this->services[$id]);
throw $e;
} finally {
unset($this->loading[$id]);
}
if (1 === $invalidBehavior) {
if (!$id) {
throw new \YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException($id);
}
if (isset($this->syntheticIds[$id])) {
throw new \YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException($id, null, null, [], \sprintf('The "%s" service is synthetic, it needs to be set at boot time before it can be used.', $id));
}
if (isset($this->getRemovedIds()[$id])) {
throw new \YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException($id, null, null, [], \sprintf('The "%s" service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly and use dependency injection instead.', $id));
}
$alternatives = [];
foreach ($this->getServiceIds() as $knownId) {
if ('' === $knownId || '.' === $knownId[0]) {
continue;
}
$lev = \levenshtein($id, $knownId);
if ($lev <= \strlen($id) / 3 || \str_contains($knownId, $id)) {
$alternatives[] = $knownId;
}
}
throw new \YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException($id, null, null, $alternatives);
}
return null;
}
/**
* Returns true if the given service has actually been initialized.
*
* @return bool
*/
public function initialized(string $id)
{
if (isset($this->aliases[$id])) {
$id = $this->aliases[$id];
}
if ('service_container' === $id) {
return \false;
}
return isset($this->services[$id]);
}
/**
* {@inheritdoc}
*/
public function reset()
{
$services = $this->services + $this->privates;
foreach ($services as $service) {
try {
if ($service instanceof \YoastSEO_Vendor\Symfony\Contracts\Service\ResetInterface) {
$service->reset();
}
} catch (\Throwable $e) {
continue;
}
}
$this->services = $this->factories = $this->privates = [];
}
/**
* Gets all service ids.
*
* @return string[]
*/
public function getServiceIds()
{
return \array_map('strval', \array_unique(\array_merge(['service_container'], \array_keys($this->fileMap), \array_keys($this->methodMap), \array_keys($this->aliases), \array_keys($this->services))));
}
/**
* Gets service ids that existed at compile time.
*
* @return array
*/
public function getRemovedIds()
{
return [];
}
/**
* Camelizes a string.
*
* @return string
*/
public static function camelize(string $id)
{
return \strtr(\ucwords(\strtr($id, ['_' => ' ', '.' => '_ ', '\\' => '_ '])), [' ' => '']);
}
/**
* A string to underscore.
*
* @return string
*/
public static function underscore(string $id)
{
return \strtolower(\preg_replace(['/([A-Z]+)([A-Z][a-z])/', '/([a-z\\d])([A-Z])/'], ['\\1_\\2', '\\1_\\2'], \str_replace('_', '.', $id)));
}
/**
* Creates a service by requiring its factory file.
*/
protected function load(string $file)
{
return require $file;
}
/**
* Fetches a variable from the environment.
*
* @return mixed
*
* @throws EnvNotFoundException When the environment variable is not found and has no default value
*/
protected function getEnv(string $name)
{
if (isset($this->resolving[$envName = "env({$name})"])) {
throw new \YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\ParameterCircularReferenceException(\array_keys($this->resolving));
}
if (isset($this->envCache[$name]) || \array_key_exists($name, $this->envCache)) {
return $this->envCache[$name];
}
if (!$this->has($id = 'container.env_var_processors_locator')) {
$this->set($id, new \YoastSEO_Vendor\Symfony\Component\DependencyInjection\ServiceLocator([]));
}
if (!$this->getEnv) {
$this->getEnv = \Closure::fromCallable([$this, 'getEnv']);
}
$processors = $this->get($id);
if (\false !== ($i = \strpos($name, ':'))) {
$prefix = \substr($name, 0, $i);
$localName = \substr($name, 1 + $i);
} else {
$prefix = 'string';
$localName = $name;
}
$processor = $processors->has($prefix) ? $processors->get($prefix) : new \YoastSEO_Vendor\Symfony\Component\DependencyInjection\EnvVarProcessor($this);
if (\false === $i) {
$prefix = '';
}
$this->resolving[$envName] = \true;
try {
return $this->envCache[$name] = $processor->getEnv($prefix, $localName, $this->getEnv);
} finally {
unset($this->resolving[$envName]);
}
}
/**
* @param string|false $registry
* @param string|bool $load
*
* @return mixed
*
* @internal
*/
protected final function getService($registry, string $id, ?string $method, $load)
{
if ('service_container' === $id) {
return $this;
}
if (\is_string($load)) {
throw new \YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\RuntimeException($load);
}
if (null === $method) {
return \false !== $registry ? $this->{$registry}[$id] ?? null : null;
}
if (\false !== $registry) {
return $this->{$registry}[$id] ?? ($this->{$registry}[$id] = $load ? $this->load($method) : $this->{$method}());
}
if (!$load) {
return $this->{$method}();
}
return ($factory = $this->factories[$id] ?? $this->factories['service_container'][$id] ?? null) ? $factory() : $this->load($method);
}
private function __clone()
{
}
}

View File

@@ -0,0 +1,75 @@
<?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 YoastSEO_Vendor\Symfony\Component\DependencyInjection;
use YoastSEO_Vendor\Psr\Container\ContainerInterface as PsrContainerInterface;
use YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException;
use YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
/**
* ContainerInterface is the interface implemented by service container classes.
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
interface ContainerInterface extends \YoastSEO_Vendor\Psr\Container\ContainerInterface
{
public const RUNTIME_EXCEPTION_ON_INVALID_REFERENCE = 0;
public const EXCEPTION_ON_INVALID_REFERENCE = 1;
public const NULL_ON_INVALID_REFERENCE = 2;
public const IGNORE_ON_INVALID_REFERENCE = 3;
public const IGNORE_ON_UNINITIALIZED_REFERENCE = 4;
/**
* Sets a service.
*/
public function set(string $id, ?object $service);
/**
* Gets a service.
*
* @param string $id The service identifier
* @param int $invalidBehavior The behavior when the service does not exist
*
* @return object|null
*
* @throws ServiceCircularReferenceException When a circular reference is detected
* @throws ServiceNotFoundException When the service is not defined
*
* @see Reference
*/
public function get(string $id, int $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE);
/**
* @return bool
*/
public function has(string $id);
/**
* Check for whether or not a service has been initialized.
*
* @return bool
*/
public function initialized(string $id);
/**
* @return array|bool|string|int|float|\UnitEnum|null
*
* @throws InvalidArgumentException if the parameter is not defined
*/
public function getParameter(string $name);
/**
* @return bool
*/
public function hasParameter(string $name);
/**
* Sets a parameter.
*
* @param string $name The parameter name
* @param array|bool|string|int|float|\UnitEnum|null $value The parameter value
*/
public function setParameter(string $name, $value);
}

View File

@@ -0,0 +1,20 @@
<?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 YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception;
/**
* This exception is thrown when an environment variable is not found.
*
* @author Nicolas Grekas <p@tchwork.com>
*/
class EnvNotFoundException extends \YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
{
}

View File

@@ -0,0 +1,22 @@
<?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 YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception;
use YoastSEO_Vendor\Psr\Container\ContainerExceptionInterface;
/**
* Base ExceptionInterface for Dependency Injection component.
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Bulat Shakirzyanov <bulat@theopenskyproject.com>
*/
interface ExceptionInterface extends \YoastSEO_Vendor\Psr\Container\ContainerExceptionInterface, \Throwable
{
}

View File

@@ -0,0 +1,20 @@
<?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 YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception;
/**
* Base InvalidArgumentException for Dependency Injection component.
*
* @author Bulat Shakirzyanov <bulat@theopenskyproject.com>
*/
class InvalidArgumentException extends \InvalidArgumentException implements \YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\ExceptionInterface
{
}

View File

@@ -0,0 +1,18 @@
<?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 YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception;
/**
* Base LogicException for Dependency Injection component.
*/
class LogicException extends \LogicException implements \YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\ExceptionInterface
{
}

View File

@@ -0,0 +1,30 @@
<?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 YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception;
/**
* This exception is thrown when a circular reference in a parameter is detected.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class ParameterCircularReferenceException extends \YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\RuntimeException
{
private $parameters;
public function __construct(array $parameters, ?\Throwable $previous = null)
{
parent::__construct(\sprintf('Circular reference detected for parameter "%s" ("%s" > "%s").', $parameters[0], \implode('" > "', $parameters), $parameters[0]), 0, $previous);
$this->parameters = $parameters;
}
public function getParameters()
{
return $this->parameters;
}
}

View File

@@ -0,0 +1,20 @@
<?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 YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception;
/**
* Base RuntimeException for Dependency Injection component.
*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
class RuntimeException extends \RuntimeException implements \YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\ExceptionInterface
{
}

View 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 YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception;
/**
* This exception is thrown when a circular reference is detected.
*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
class ServiceCircularReferenceException extends \YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\RuntimeException
{
private $serviceId;
private $path;
public function __construct(string $serviceId, array $path, ?\Throwable $previous = null)
{
parent::__construct(\sprintf('Circular reference detected for service "%s", path: "%s".', $serviceId, \implode(' -> ', $path)), 0, $previous);
$this->serviceId = $serviceId;
$this->path = $path;
}
public function getServiceId()
{
return $this->serviceId;
}
public function getPath()
{
return $this->path;
}
}

View File

@@ -0,0 +1,58 @@
<?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 YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception;
use YoastSEO_Vendor\Psr\Container\NotFoundExceptionInterface;
/**
* This exception is thrown when a non-existent service is requested.
*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
class ServiceNotFoundException extends \YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException implements \YoastSEO_Vendor\Psr\Container\NotFoundExceptionInterface
{
private $id;
private $sourceId;
private $alternatives;
public function __construct(string $id, ?string $sourceId = null, ?\Throwable $previous = null, array $alternatives = [], ?string $msg = null)
{
if (null !== $msg) {
// no-op
} elseif (null === $sourceId) {
$msg = \sprintf('You have requested a non-existent service "%s".', $id);
} else {
$msg = \sprintf('The service "%s" has a dependency on a non-existent service "%s".', $sourceId, $id);
}
if ($alternatives) {
if (1 == \count($alternatives)) {
$msg .= ' Did you mean this: "';
} else {
$msg .= ' Did you mean one of these: "';
}
$msg .= \implode('", "', $alternatives) . '"?';
}
parent::__construct($msg, 0, $previous);
$this->id = $id;
$this->sourceId = $sourceId;
$this->alternatives = $alternatives;
}
public function getId()
{
return $this->id;
}
public function getSourceId()
{
return $this->sourceId;
}
public function getAlternatives()
{
return $this->alternatives;
}
}

View File

@@ -0,0 +1,137 @@
<?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 YoastSEO_Vendor\Symfony\Component\DependencyInjection\ParameterBag;
use YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\RuntimeException;
/**
* @author Nicolas Grekas <p@tchwork.com>
*/
class EnvPlaceholderParameterBag extends \YoastSEO_Vendor\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag
{
private $envPlaceholderUniquePrefix;
private $envPlaceholders = [];
private $unusedEnvPlaceholders = [];
private $providedTypes = [];
private static $counter = 0;
/**
* {@inheritdoc}
*/
public function get(string $name)
{
if (\str_starts_with($name, 'env(') && \str_ends_with($name, ')') && 'env()' !== $name) {
$env = \substr($name, 4, -1);
if (isset($this->envPlaceholders[$env])) {
foreach ($this->envPlaceholders[$env] as $placeholder) {
return $placeholder;
// return first result
}
}
if (isset($this->unusedEnvPlaceholders[$env])) {
foreach ($this->unusedEnvPlaceholders[$env] as $placeholder) {
return $placeholder;
// return first result
}
}
if (!\preg_match('/^(?:[-.\\w]*+:)*+\\w++$/', $env)) {
throw new \YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Invalid %s name: only "word" characters are allowed.', $name));
}
if ($this->has($name) && null !== ($defaultValue = parent::get($name)) && !\is_string($defaultValue)) {
throw new \YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('The default value of an env() parameter must be a string or null, but "%s" given to "%s".', \get_debug_type($defaultValue), $name));
}
$uniqueName = \md5($name . '_' . self::$counter++);
$placeholder = \sprintf('%s_%s_%s', $this->getEnvPlaceholderUniquePrefix(), \strtr($env, ':-.', '___'), $uniqueName);
$this->envPlaceholders[$env][$placeholder] = $placeholder;
return $placeholder;
}
return parent::get($name);
}
/**
* Gets the common env placeholder prefix for env vars created by this bag.
*/
public function getEnvPlaceholderUniquePrefix() : string
{
if (null === $this->envPlaceholderUniquePrefix) {
$reproducibleEntropy = \unserialize(\serialize($this->parameters));
\array_walk_recursive($reproducibleEntropy, function (&$v) {
$v = null;
});
$this->envPlaceholderUniquePrefix = 'env_' . \substr(\md5(\serialize($reproducibleEntropy)), -16);
}
return $this->envPlaceholderUniquePrefix;
}
/**
* Returns the map of env vars used in the resolved parameter values to their placeholders.
*
* @return string[][] A map of env var names to their placeholders
*/
public function getEnvPlaceholders()
{
return $this->envPlaceholders;
}
public function getUnusedEnvPlaceholders() : array
{
return $this->unusedEnvPlaceholders;
}
public function clearUnusedEnvPlaceholders()
{
$this->unusedEnvPlaceholders = [];
}
/**
* Merges the env placeholders of another EnvPlaceholderParameterBag.
*/
public function mergeEnvPlaceholders(self $bag)
{
if ($newPlaceholders = $bag->getEnvPlaceholders()) {
$this->envPlaceholders += $newPlaceholders;
foreach ($newPlaceholders as $env => $placeholders) {
$this->envPlaceholders[$env] += $placeholders;
}
}
if ($newUnusedPlaceholders = $bag->getUnusedEnvPlaceholders()) {
$this->unusedEnvPlaceholders += $newUnusedPlaceholders;
foreach ($newUnusedPlaceholders as $env => $placeholders) {
$this->unusedEnvPlaceholders[$env] += $placeholders;
}
}
}
/**
* Maps env prefixes to their corresponding PHP types.
*/
public function setProvidedTypes(array $providedTypes)
{
$this->providedTypes = $providedTypes;
}
/**
* Gets the PHP types corresponding to env() parameter prefixes.
*
* @return string[][]
*/
public function getProvidedTypes()
{
return $this->providedTypes;
}
/**
* {@inheritdoc}
*/
public function resolve()
{
if ($this->resolved) {
return;
}
parent::resolve();
foreach ($this->envPlaceholders as $env => $placeholders) {
if ($this->has($name = "env({$env})") && null !== ($default = $this->parameters[$name]) && !\is_string($default)) {
throw new \YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('The default value of env parameter "%s" must be a string or null, "%s" given.', $env, \get_debug_type($default)));
}
}
}
}

View 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 YoastSEO_Vendor\Symfony\Component\DependencyInjection\ParameterBag;
use YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\LogicException;
/**
* Holds read-only parameters.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class FrozenParameterBag extends \YoastSEO_Vendor\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag
{
/**
* For performance reasons, the constructor assumes that
* all keys are already lowercased.
*
* This is always the case when used internally.
*
* @param array $parameters An array of parameters
*/
public function __construct(array $parameters = [])
{
$this->parameters = $parameters;
$this->resolved = \true;
}
/**
* {@inheritdoc}
*/
public function clear()
{
throw new \YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\LogicException('Impossible to call clear() on a frozen ParameterBag.');
}
/**
* {@inheritdoc}
*/
public function add(array $parameters)
{
throw new \YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\LogicException('Impossible to call add() on a frozen ParameterBag.');
}
/**
* {@inheritdoc}
*/
public function set(string $name, $value)
{
throw new \YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\LogicException('Impossible to call set() on a frozen ParameterBag.');
}
/**
* {@inheritdoc}
*/
public function remove(string $name)
{
throw new \YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\LogicException('Impossible to call remove() on a frozen ParameterBag.');
}
}

View File

@@ -0,0 +1,234 @@
<?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 YoastSEO_Vendor\Symfony\Component\DependencyInjection\ParameterBag;
use YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\ParameterCircularReferenceException;
use YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;
use YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\RuntimeException;
/**
* Holds parameters.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class ParameterBag implements \YoastSEO_Vendor\Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface
{
protected $parameters = [];
protected $resolved = \false;
public function __construct(array $parameters = [])
{
$this->add($parameters);
}
/**
* {@inheritdoc}
*/
public function clear()
{
$this->parameters = [];
}
/**
* {@inheritdoc}
*/
public function add(array $parameters)
{
foreach ($parameters as $key => $value) {
$this->set($key, $value);
}
}
/**
* {@inheritdoc}
*/
public function all()
{
return $this->parameters;
}
/**
* {@inheritdoc}
*/
public function get(string $name)
{
if (!\array_key_exists($name, $this->parameters)) {
if (!$name) {
throw new \YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException($name);
}
$alternatives = [];
foreach ($this->parameters as $key => $parameterValue) {
$lev = \levenshtein($name, $key);
if ($lev <= \strlen($name) / 3 || \str_contains($key, $name)) {
$alternatives[] = $key;
}
}
$nonNestedAlternative = null;
if (!\count($alternatives) && \str_contains($name, '.')) {
$namePartsLength = \array_map('strlen', \explode('.', $name));
$key = \substr($name, 0, -1 * (1 + \array_pop($namePartsLength)));
while (\count($namePartsLength)) {
if ($this->has($key)) {
if (\is_array($this->get($key))) {
$nonNestedAlternative = $key;
}
break;
}
$key = \substr($key, 0, -1 * (1 + \array_pop($namePartsLength)));
}
}
throw new \YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException($name, null, null, null, $alternatives, $nonNestedAlternative);
}
return $this->parameters[$name];
}
/**
* {@inheritdoc}
*/
public function set(string $name, $value)
{
$this->parameters[$name] = $value;
}
/**
* {@inheritdoc}
*/
public function has(string $name)
{
return \array_key_exists($name, $this->parameters);
}
/**
* {@inheritdoc}
*/
public function remove(string $name)
{
unset($this->parameters[$name]);
}
/**
* {@inheritdoc}
*/
public function resolve()
{
if ($this->resolved) {
return;
}
$parameters = [];
foreach ($this->parameters as $key => $value) {
try {
$value = $this->resolveValue($value);
$parameters[$key] = $this->unescapeValue($value);
} catch (\YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException $e) {
$e->setSourceKey($key);
throw $e;
}
}
$this->parameters = $parameters;
$this->resolved = \true;
}
/**
* Replaces parameter placeholders (%name%) by their values.
*
* @param mixed $value A value
* @param array $resolving An array of keys that are being resolved (used internally to detect circular references)
*
* @return mixed
*
* @throws ParameterNotFoundException if a placeholder references a parameter that does not exist
* @throws ParameterCircularReferenceException if a circular reference if detected
* @throws RuntimeException when a given parameter has a type problem
*/
public function resolveValue($value, array $resolving = [])
{
if (\is_array($value)) {
$args = [];
foreach ($value as $k => $v) {
$args[\is_string($k) ? $this->resolveValue($k, $resolving) : $k] = $this->resolveValue($v, $resolving);
}
return $args;
}
if (!\is_string($value) || 2 > \strlen($value)) {
return $value;
}
return $this->resolveString($value, $resolving);
}
/**
* Resolves parameters inside a string.
*
* @param array $resolving An array of keys that are being resolved (used internally to detect circular references)
*
* @return mixed
*
* @throws ParameterNotFoundException if a placeholder references a parameter that does not exist
* @throws ParameterCircularReferenceException if a circular reference if detected
* @throws RuntimeException when a given parameter has a type problem
*/
public function resolveString(string $value, array $resolving = [])
{
// we do this to deal with non string values (Boolean, integer, ...)
// as the preg_replace_callback throw an exception when trying
// a non-string in a parameter value
if (\preg_match('/^%([^%\\s]+)%$/', $value, $match)) {
$key = $match[1];
if (isset($resolving[$key])) {
throw new \YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\ParameterCircularReferenceException(\array_keys($resolving));
}
$resolving[$key] = \true;
return $this->resolved ? $this->get($key) : $this->resolveValue($this->get($key), $resolving);
}
return \preg_replace_callback('/%%|%([^%\\s]+)%/', function ($match) use($resolving, $value) {
// skip %%
if (!isset($match[1])) {
return '%%';
}
$key = $match[1];
if (isset($resolving[$key])) {
throw new \YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\ParameterCircularReferenceException(\array_keys($resolving));
}
$resolved = $this->get($key);
if (!\is_string($resolved) && !\is_numeric($resolved)) {
throw new \YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('A string value must be composed of strings and/or numbers, but found parameter "%s" of type "%s" inside string value "%s".', $key, \get_debug_type($resolved), $value));
}
$resolved = (string) $resolved;
$resolving[$key] = \true;
return $this->isResolved() ? $resolved : $this->resolveString($resolved, $resolving);
}, $value);
}
public function isResolved()
{
return $this->resolved;
}
/**
* {@inheritdoc}
*/
public function escapeValue($value)
{
if (\is_string($value)) {
return \str_replace('%', '%%', $value);
}
if (\is_array($value)) {
$result = [];
foreach ($value as $k => $v) {
$result[$k] = $this->escapeValue($v);
}
return $result;
}
return $value;
}
/**
* {@inheritdoc}
*/
public function unescapeValue($value)
{
if (\is_string($value)) {
return \str_replace('%%', '%', $value);
}
if (\is_array($value)) {
$result = [];
foreach ($value as $k => $v) {
$result[$k] = $this->unescapeValue($v);
}
return $result;
}
return $value;
}
}

View File

@@ -0,0 +1,94 @@
<?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 YoastSEO_Vendor\Symfony\Component\DependencyInjection\ParameterBag;
use YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\LogicException;
use YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;
/**
* ParameterBagInterface is the interface implemented by objects that manage service container parameters.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
interface ParameterBagInterface
{
/**
* Clears all parameters.
*
* @throws LogicException if the ParameterBagInterface cannot be cleared
*/
public function clear();
/**
* Adds parameters to the service container parameters.
*
* @throws LogicException if the parameter cannot be added
*/
public function add(array $parameters);
/**
* Gets the service container parameters.
*
* @return array
*/
public function all();
/**
* Gets a service container parameter.
*
* @return array|bool|string|int|float|\UnitEnum|null
*
* @throws ParameterNotFoundException if the parameter is not defined
*/
public function get(string $name);
/**
* Removes a parameter.
*/
public function remove(string $name);
/**
* Sets a service container parameter.
*
* @param array|bool|string|int|float|\UnitEnum|null $value The parameter value
*
* @throws LogicException if the parameter cannot be set
*/
public function set(string $name, $value);
/**
* Returns true if a parameter name is defined.
*
* @return bool
*/
public function has(string $name);
/**
* Replaces parameter placeholders (%name%) by their values for all parameters.
*/
public function resolve();
/**
* Replaces parameter placeholders (%name%) by their values.
*
* @param mixed $value A value
*
* @throws ParameterNotFoundException if a placeholder references a parameter that does not exist
*/
public function resolveValue($value);
/**
* Escape parameter placeholders %.
*
* @param mixed $value
*
* @return mixed
*/
public function escapeValue($value);
/**
* Unescape parameter placeholders %.
*
* @param mixed $value
*
* @return mixed
*/
public function unescapeValue($value);
}

View File

@@ -0,0 +1,129 @@
<?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 YoastSEO_Vendor\Symfony\Component\DependencyInjection;
use YoastSEO_Vendor\Psr\Container\ContainerExceptionInterface;
use YoastSEO_Vendor\Psr\Container\NotFoundExceptionInterface;
use YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\RuntimeException;
use YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException;
use YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
use YoastSEO_Vendor\Symfony\Contracts\Service\ServiceLocatorTrait;
use YoastSEO_Vendor\Symfony\Contracts\Service\ServiceProviderInterface;
use YoastSEO_Vendor\Symfony\Contracts\Service\ServiceSubscriberInterface;
/**
* @author Robin Chalas <robin.chalas@gmail.com>
* @author Nicolas Grekas <p@tchwork.com>
*/
class ServiceLocator implements \YoastSEO_Vendor\Symfony\Contracts\Service\ServiceProviderInterface
{
use ServiceLocatorTrait {
get as private doGet;
}
private $externalId;
private $container;
/**
* {@inheritdoc}
*
* @return mixed
*/
public function get(string $id)
{
if (!$this->externalId) {
return $this->doGet($id);
}
try {
return $this->doGet($id);
} catch (\YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\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->setAccessible(\true);
$r->setValue($e, $message);
throw $e;
}
}
public function __invoke(string $id)
{
return isset($this->factories[$id]) ? $this->get($id) : null;
}
/**
* @internal
*
* @return static
*/
public function withContext(string $externalId, \YoastSEO_Vendor\Symfony\Component\DependencyInjection\Container $container) : self
{
$locator = clone $this;
$locator->externalId = $externalId;
$locator->container = $container;
return $locator;
}
private function createNotFoundException(string $id) : \YoastSEO_Vendor\Psr\Container\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 \YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\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']) ? \get_class($class[3]['object']) : 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 (\YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\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, \YoastSEO_Vendor\Symfony\Contracts\Service\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 \YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException($id, \end($this->loading) ?: null, null, [], \implode(' ', $msg));
}
private function createCircularReferenceException(string $id, array $path) : \YoastSEO_Vendor\Psr\Container\ContainerExceptionInterface
{
return new \YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\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) : '');
}
}

View File

@@ -0,0 +1,27 @@
<?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.
*/
if (!function_exists('trigger_deprecation')) {
/**
* Triggers a silenced deprecation notice.
*
* @param string $package The name of the Composer package that is triggering the deprecation
* @param string $version The version of the package that introduced the deprecation
* @param string $message The message of the deprecation
* @param mixed ...$args Values to insert in the message using printf() formatting
*
* @author Nicolas Grekas <p@tchwork.com>
*/
function trigger_deprecation(string $package, string $version, string $message, ...$args): void
{
@trigger_error(($package || $version ? "Since $package $version: " : '').($args ? vsprintf($message, $args) : $message), \E_USER_DEPRECATED);
}
}

View File

@@ -0,0 +1,29 @@
<?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 YoastSEO_Vendor\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
{
public function reset();
}

View File

@@ -0,0 +1,113 @@
<?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 YoastSEO_Vendor\Symfony\Contracts\Service;
use YoastSEO_Vendor\Psr\Container\ContainerExceptionInterface;
use YoastSEO_Vendor\Psr\Container\NotFoundExceptionInterface;
// Help opcache.preload discover always-needed symbols
\class_exists(\YoastSEO_Vendor\Psr\Container\ContainerExceptionInterface::class);
\class_exists(\YoastSEO_Vendor\Psr\Container\NotFoundExceptionInterface::class);
/**
* A trait to help implement ServiceProviderInterface.
*
* @author Robin Chalas <robin.chalas@gmail.com>
* @author Nicolas Grekas <p@tchwork.com>
*/
trait ServiceLocatorTrait
{
private $factories;
private $loading = [];
private $providedTypes;
/**
* @param callable[] $factories
*/
public function __construct(array $factories)
{
$this->factories = $factories;
}
/**
* {@inheritdoc}
*
* @return bool
*/
public function has(string $id)
{
return isset($this->factories[$id]);
}
/**
* {@inheritdoc}
*
* @return mixed
*/
public function get(string $id)
{
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]);
}
}
/**
* {@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 instanceof \ReflectionNamedType ? $type->getName() : $type) : '?';
}
}
}
return $this->providedTypes;
}
private function createNotFoundException(string $id) : \YoastSEO_Vendor\Psr\Container\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 \YoastSEO_Vendor\Psr\Container\NotFoundExceptionInterface
{
};
}
private function createCircularReferenceException(string $id, array $path) : \YoastSEO_Vendor\Psr\Container\ContainerExceptionInterface
{
return new class(\sprintf('Circular reference detected for service "%s", path: "%s".', $id, \implode(' -> ', $path))) extends \RuntimeException implements \YoastSEO_Vendor\Psr\Container\ContainerExceptionInterface
{
};
}
}

View File

@@ -0,0 +1,34 @@
<?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 YoastSEO_Vendor\Symfony\Contracts\Service;
use YoastSEO_Vendor\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 \YoastSEO_Vendor\Psr\Container\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;
}