diff --git a/symfony/cache-contracts/CHANGELOG.md b/symfony/cache-contracts/CHANGELOG.md
new file mode 100644
index 0000000000000000000000000000000000000000..7932e26132d319374a768a73230e78c12535987c
--- /dev/null
+++ b/symfony/cache-contracts/CHANGELOG.md
@@ -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
diff --git a/symfony/cache-contracts/CacheInterface.php b/symfony/cache-contracts/CacheInterface.php
new file mode 100644
index 0000000000000000000000000000000000000000..3e4aaf65c48d1a1ce82723847dd68e0180d5c286
--- /dev/null
+++ b/symfony/cache-contracts/CacheInterface.php
@@ -0,0 +1,59 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Contracts\Cache;
+
+use Psr\Cache\CacheItemInterface;
+use Psr\Cache\InvalidArgumentException;
+
+/**
+ * Covers most simple to advanced caching needs.
+ *
+ * @author Nicolas Grekas
+ */
+interface CacheInterface
+{
+ /**
+ * Fetches a value from the pool or computes it if not found.
+ *
+ * On cache misses, a callback is called that should return the missing value.
+ * This callback is given a PSR-6 CacheItemInterface instance corresponding to the
+ * requested key, that could be used e.g. for expiration control. It could also
+ * be an ItemInterface instance when its additional features are needed.
+ *
+ * @template T
+ *
+ * @param string $key The key of the item to retrieve from the cache
+ * @param (callable(CacheItemInterface,bool):T)|(callable(ItemInterface,bool):T)|CallbackInterface $callback
+ * @param float|null $beta A float that, as it grows, controls the likeliness of triggering
+ * early expiration. 0 disables it, INF forces immediate expiration.
+ * The default (or providing null) is implementation dependent but should
+ * typically be 1.0, which should provide optimal stampede protection.
+ * See https://en.wikipedia.org/wiki/Cache_stampede#Probabilistic_early_expiration
+ * @param array &$metadata The metadata of the cached item {@see ItemInterface::getMetadata()}
+ *
+ * @return T
+ *
+ * @throws InvalidArgumentException When $key is not valid or when $beta is negative
+ */
+ public function get(string $key, callable $callback, ?float $beta = null, ?array &$metadata = null): mixed;
+
+ /**
+ * Removes an item from the pool.
+ *
+ * @param string $key The key to delete
+ *
+ * @return bool True if the item was successfully removed, false if there was any error
+ *
+ * @throws InvalidArgumentException When $key is not valid
+ */
+ public function delete(string $key): bool;
+}
diff --git a/symfony/cache-contracts/CacheTrait.php b/symfony/cache-contracts/CacheTrait.php
new file mode 100644
index 0000000000000000000000000000000000000000..4c5449b9d7c721689f8574beefafc85c39a7f1dd
--- /dev/null
+++ b/symfony/cache-contracts/CacheTrait.php
@@ -0,0 +1,72 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Contracts\Cache;
+
+use Psr\Cache\CacheItemPoolInterface;
+use Psr\Cache\InvalidArgumentException;
+use Psr\Log\LoggerInterface;
+
+// Help opcache.preload discover always-needed symbols
+class_exists(InvalidArgumentException::class);
+
+/**
+ * An implementation of CacheInterface for PSR-6 CacheItemPoolInterface classes.
+ *
+ * @author Nicolas Grekas
+ */
+trait CacheTrait
+{
+ public function get(string $key, callable $callback, ?float $beta = null, ?array &$metadata = null): mixed
+ {
+ return $this->doGet($this, $key, $callback, $beta, $metadata);
+ }
+
+ public function delete(string $key): bool
+ {
+ return $this->deleteItem($key);
+ }
+
+ private function doGet(CacheItemPoolInterface $pool, string $key, callable $callback, ?float $beta, ?array &$metadata = null, ?LoggerInterface $logger = null): mixed
+ {
+ if (0 > $beta ??= 1.0) {
+ throw new class(\sprintf('Argument "$beta" provided to "%s::get()" must be a positive number, %f given.', static::class, $beta)) extends \InvalidArgumentException implements InvalidArgumentException {};
+ }
+
+ $item = $pool->getItem($key);
+ $recompute = !$item->isHit() || \INF === $beta;
+ $metadata = $item instanceof ItemInterface ? $item->getMetadata() : [];
+
+ if (!$recompute && $metadata) {
+ $expiry = $metadata[ItemInterface::METADATA_EXPIRY] ?? false;
+ $ctime = $metadata[ItemInterface::METADATA_CTIME] ?? false;
+
+ if ($recompute = $ctime && $expiry && $expiry <= ($now = microtime(true)) - $ctime / 1000 * $beta * log(random_int(1, \PHP_INT_MAX) / \PHP_INT_MAX)) {
+ // force applying defaultLifetime to expiry
+ $item->expiresAt(null);
+ $logger?->info('Item "{key}" elected for early recomputation {delta}s before its expiration', [
+ 'key' => $key,
+ 'delta' => \sprintf('%.1f', $expiry - $now),
+ ]);
+ }
+ }
+
+ if ($recompute) {
+ $save = true;
+ $item->set($callback($item, $save));
+ if ($save) {
+ $pool->save($item);
+ }
+ }
+
+ return $item->get();
+ }
+}
diff --git a/symfony/cache-contracts/CallbackInterface.php b/symfony/cache-contracts/CallbackInterface.php
new file mode 100644
index 0000000000000000000000000000000000000000..15941e9c9d7d3b5754074cf3205b91a080be8c32
--- /dev/null
+++ b/symfony/cache-contracts/CallbackInterface.php
@@ -0,0 +1,32 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Contracts\Cache;
+
+use Psr\Cache\CacheItemInterface;
+
+/**
+ * Computes and returns the cached value of an item.
+ *
+ * @author Nicolas Grekas
+ *
+ * @template T
+ */
+interface CallbackInterface
+{
+ /**
+ * @param CacheItemInterface|ItemInterface $item The item to compute the value for
+ * @param bool &$save Should be set to false when the value should not be saved in the pool
+ *
+ * @return T The computed value for the passed item
+ */
+ public function __invoke(CacheItemInterface $item, bool &$save): mixed;
+}
diff --git a/symfony/cache-contracts/ItemInterface.php b/symfony/cache-contracts/ItemInterface.php
new file mode 100644
index 0000000000000000000000000000000000000000..8c4c51253eef74a3e54cbd73aad0d558c229e256
--- /dev/null
+++ b/symfony/cache-contracts/ItemInterface.php
@@ -0,0 +1,65 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Contracts\Cache;
+
+use Psr\Cache\CacheException;
+use Psr\Cache\CacheItemInterface;
+use Psr\Cache\InvalidArgumentException;
+
+/**
+ * Augments PSR-6's CacheItemInterface with support for tags and metadata.
+ *
+ * @author Nicolas Grekas
+ */
+interface ItemInterface extends CacheItemInterface
+{
+ /**
+ * References the Unix timestamp stating when the item will expire.
+ */
+ public const METADATA_EXPIRY = 'expiry';
+
+ /**
+ * References the time the item took to be created, in milliseconds.
+ */
+ public const METADATA_CTIME = 'ctime';
+
+ /**
+ * References the list of tags that were assigned to the item, as string[].
+ */
+ public const METADATA_TAGS = 'tags';
+
+ /**
+ * Reserved characters that cannot be used in a key or tag.
+ */
+ public const RESERVED_CHARACTERS = '{}()/\@:';
+
+ /**
+ * Adds a tag to a cache item.
+ *
+ * Tags are strings that follow the same validation rules as keys.
+ *
+ * @param string|string[] $tags A tag or array of tags
+ *
+ * @return $this
+ *
+ * @throws InvalidArgumentException When $tag is not valid
+ * @throws CacheException When the item comes from a pool that is not tag-aware
+ */
+ public function tag(string|iterable $tags): static;
+
+ /**
+ * Returns a list of metadata info that were saved alongside with the cached value.
+ *
+ * See ItemInterface::METADATA_* consts for keys potentially found in the returned array.
+ */
+ public function getMetadata(): array;
+}
diff --git a/symfony/cache-contracts/LICENSE b/symfony/cache-contracts/LICENSE
new file mode 100644
index 0000000000000000000000000000000000000000..7536caeae80d886b8bf52199ed380549bf0b4236
--- /dev/null
+++ b/symfony/cache-contracts/LICENSE
@@ -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.
diff --git a/symfony/cache-contracts/NamespacedPoolInterface.php b/symfony/cache-contracts/NamespacedPoolInterface.php
new file mode 100644
index 0000000000000000000000000000000000000000..cd67bc09bc88222d9efb81c6778dd0a3d8eec14e
--- /dev/null
+++ b/symfony/cache-contracts/NamespacedPoolInterface.php
@@ -0,0 +1,31 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Contracts\Cache;
+
+use Psr\Cache\InvalidArgumentException;
+
+/**
+ * Enables namespace-based invalidation by prefixing keys with backend-native namespace separators.
+ *
+ * Note that calling `withSubNamespace()` MUST NOT mutate the pool, but return a new instance instead.
+ *
+ * When tags are used, they MUST ignore sub-namespaces.
+ *
+ * @author Nicolas Grekas
+ */
+interface NamespacedPoolInterface
+{
+ /**
+ * @throws InvalidArgumentException If the namespace contains characters found in ItemInterface's RESERVED_CHARACTERS
+ */
+ public function withSubNamespace(string $namespace): static;
+}
diff --git a/symfony/cache-contracts/README.md b/symfony/cache-contracts/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..ffe0833afa360d6219973d0972b0f2b242d80c15
--- /dev/null
+++ b/symfony/cache-contracts/README.md
@@ -0,0 +1,9 @@
+Symfony Cache 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.
diff --git a/symfony/cache-contracts/TagAwareCacheInterface.php b/symfony/cache-contracts/TagAwareCacheInterface.php
new file mode 100644
index 0000000000000000000000000000000000000000..8e0b6be822944e0e64d2a7ea6bdcd137d4b5a016
--- /dev/null
+++ b/symfony/cache-contracts/TagAwareCacheInterface.php
@@ -0,0 +1,38 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Contracts\Cache;
+
+use Psr\Cache\InvalidArgumentException;
+
+/**
+ * Allows invalidating cached items using tags.
+ *
+ * @author Nicolas Grekas
+ */
+interface TagAwareCacheInterface extends CacheInterface
+{
+ /**
+ * Invalidates cached items using tags.
+ *
+ * When implemented on a PSR-6 pool, invalidation should not apply
+ * to deferred items. Instead, they should be committed as usual.
+ * This allows replacing old tagged values by new ones without
+ * race conditions.
+ *
+ * @param string[] $tags An array of tags to invalidate
+ *
+ * @return bool True on success
+ *
+ * @throws InvalidArgumentException When $tags is not valid
+ */
+ public function invalidateTags(array $tags): bool;
+}
diff --git a/symfony/cache-contracts/composer.json b/symfony/cache-contracts/composer.json
new file mode 100644
index 0000000000000000000000000000000000000000..b713c29017a4f8c856c3fedf99b4a0774eae0d7a
--- /dev/null
+++ b/symfony/cache-contracts/composer.json
@@ -0,0 +1,35 @@
+{
+ "name": "symfony/cache-contracts",
+ "type": "library",
+ "description": "Generic abstractions related to caching",
+ "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/cache": "^3.0"
+ },
+ "autoload": {
+ "psr-4": { "Symfony\\Contracts\\Cache\\": "" }
+ },
+ "minimum-stability": "dev",
+ "extra": {
+ "branch-alias": {
+ "dev-main": "3.6-dev"
+ },
+ "thanks": {
+ "name": "symfony/contracts",
+ "url": "https://github.com/symfony/contracts"
+ }
+ }
+}
diff --git a/symfony/cache/Adapter/AbstractAdapter.php b/symfony/cache/Adapter/AbstractAdapter.php
new file mode 100644
index 0000000000000000000000000000000000000000..bf04ae08cb3746cbbaf00ef2729dfd6c64fb3197
--- /dev/null
+++ b/symfony/cache/Adapter/AbstractAdapter.php
@@ -0,0 +1,188 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Adapter;
+
+use Psr\Log\LoggerAwareInterface;
+use Psr\Log\LoggerInterface;
+use Symfony\Component\Cache\CacheItem;
+use Symfony\Component\Cache\Exception\InvalidArgumentException;
+use Symfony\Component\Cache\ResettableInterface;
+use Symfony\Component\Cache\Traits\AbstractAdapterTrait;
+use Symfony\Component\Cache\Traits\ContractsTrait;
+use Symfony\Contracts\Cache\CacheInterface;
+
+/**
+ * @author Nicolas Grekas
+ */
+abstract class AbstractAdapter implements AdapterInterface, CacheInterface, LoggerAwareInterface, ResettableInterface
+{
+ use AbstractAdapterTrait;
+ use ContractsTrait;
+
+ /**
+ * @internal
+ */
+ protected const NS_SEPARATOR = ':';
+
+ private static bool $apcuSupported;
+
+ protected function __construct(string $namespace = '', int $defaultLifetime = 0)
+ {
+ $this->namespace = '' === $namespace ? '' : CacheItem::validateKey($namespace).static::NS_SEPARATOR;
+ $this->defaultLifetime = $defaultLifetime;
+ if (null !== $this->maxIdLength && \strlen($namespace) > $this->maxIdLength - 24) {
+ throw new InvalidArgumentException(\sprintf('Namespace must be %d chars max, %d given ("%s").', $this->maxIdLength - 24, \strlen($namespace), $namespace));
+ }
+ self::$createCacheItem ??= \Closure::bind(
+ static function ($key, $value, $isHit) {
+ $item = new CacheItem();
+ $item->key = $key;
+ $item->value = $value;
+ $item->isHit = $isHit;
+ $item->unpack();
+
+ return $item;
+ },
+ null,
+ CacheItem::class
+ );
+ self::$mergeByLifetime ??= \Closure::bind(
+ static function ($deferred, $namespace, &$expiredIds, $getId, $defaultLifetime) {
+ $byLifetime = [];
+ $now = microtime(true);
+ $expiredIds = [];
+
+ foreach ($deferred as $key => $item) {
+ $key = (string) $key;
+ if (null === $item->expiry) {
+ $ttl = 0 < $defaultLifetime ? $defaultLifetime : 0;
+ } elseif (!$item->expiry) {
+ $ttl = 0;
+ } elseif (0 >= $ttl = (int) (0.1 + $item->expiry - $now)) {
+ $expiredIds[] = $getId($key);
+ continue;
+ }
+ $byLifetime[$ttl][$getId($key)] = $item->pack();
+ }
+
+ return $byLifetime;
+ },
+ null,
+ CacheItem::class
+ );
+ }
+
+ /**
+ * Returns the best possible adapter that your runtime supports.
+ *
+ * Using ApcuAdapter makes system caches compatible with read-only filesystems.
+ */
+ public static function createSystemCache(string $namespace, int $defaultLifetime, string $version, string $directory, ?LoggerInterface $logger = null): AdapterInterface
+ {
+ $opcache = new PhpFilesAdapter($namespace, $defaultLifetime, $directory, true);
+ if (null !== $logger) {
+ $opcache->setLogger($logger);
+ }
+
+ if (!self::$apcuSupported ??= ApcuAdapter::isSupported()) {
+ return $opcache;
+ }
+
+ if ('cli' === \PHP_SAPI && !filter_var(\ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOL)) {
+ return $opcache;
+ }
+
+ $apcu = new ApcuAdapter($namespace, intdiv($defaultLifetime, 5), $version);
+ if (null !== $logger) {
+ $apcu->setLogger($logger);
+ }
+
+ return new ChainAdapter([$apcu, $opcache]);
+ }
+
+ public static function createConnection(#[\SensitiveParameter] string $dsn, array $options = []): mixed
+ {
+ if (str_starts_with($dsn, 'redis:') || str_starts_with($dsn, 'rediss:')) {
+ return RedisAdapter::createConnection($dsn, $options);
+ }
+ if (str_starts_with($dsn, 'memcached:')) {
+ return MemcachedAdapter::createConnection($dsn, $options);
+ }
+ if (str_starts_with($dsn, 'couchbase:')) {
+ if (CouchbaseBucketAdapter::isSupported()) {
+ return CouchbaseBucketAdapter::createConnection($dsn, $options);
+ }
+
+ return CouchbaseCollectionAdapter::createConnection($dsn, $options);
+ }
+
+ throw new InvalidArgumentException('Unsupported DSN: it does not start with "redis[s]:", "memcached:" nor "couchbase:".');
+ }
+
+ public function commit(): bool
+ {
+ $ok = true;
+ $byLifetime = (self::$mergeByLifetime)($this->deferred, $this->namespace, $expiredIds, $this->getId(...), $this->defaultLifetime);
+ $retry = $this->deferred = [];
+
+ if ($expiredIds) {
+ try {
+ $this->doDelete($expiredIds);
+ } catch (\Exception $e) {
+ $ok = false;
+ CacheItem::log($this->logger, 'Failed to delete expired items: '.$e->getMessage(), ['exception' => $e, 'cache-adapter' => get_debug_type($this)]);
+ }
+ }
+ foreach ($byLifetime as $lifetime => $values) {
+ try {
+ $e = $this->doSave($values, $lifetime);
+ } catch (\Exception $e) {
+ }
+ if (true === $e || [] === $e) {
+ continue;
+ }
+ if (\is_array($e) || 1 === \count($values)) {
+ foreach (\is_array($e) ? $e : array_keys($values) as $id) {
+ $ok = false;
+ $v = $values[$id];
+ $type = get_debug_type($v);
+ $message = \sprintf('Failed to save key "{key}" of type %s%s', $type, $e instanceof \Exception ? ': '.$e->getMessage() : '.');
+ CacheItem::log($this->logger, $message, ['key' => substr($id, \strlen($this->namespace)), 'exception' => $e instanceof \Exception ? $e : null, 'cache-adapter' => get_debug_type($this)]);
+ }
+ } else {
+ foreach ($values as $id => $v) {
+ $retry[$lifetime][] = $id;
+ }
+ }
+ }
+
+ // When bulk-save failed, retry each item individually
+ foreach ($retry as $lifetime => $ids) {
+ foreach ($ids as $id) {
+ try {
+ $v = $byLifetime[$lifetime][$id];
+ $e = $this->doSave([$id => $v], $lifetime);
+ } catch (\Exception $e) {
+ }
+ if (true === $e || [] === $e) {
+ continue;
+ }
+ $ok = false;
+ $type = get_debug_type($v);
+ $message = \sprintf('Failed to save key "{key}" of type %s%s', $type, $e instanceof \Exception ? ': '.$e->getMessage() : '.');
+ CacheItem::log($this->logger, $message, ['key' => substr($id, \strlen($this->namespace)), 'exception' => $e instanceof \Exception ? $e : null, 'cache-adapter' => get_debug_type($this)]);
+ }
+ }
+
+ return $ok;
+ }
+}
diff --git a/symfony/cache/Adapter/AbstractTagAwareAdapter.php b/symfony/cache/Adapter/AbstractTagAwareAdapter.php
new file mode 100644
index 0000000000000000000000000000000000000000..a1af6141b959f4960c91b790356ba6469a235d98
--- /dev/null
+++ b/symfony/cache/Adapter/AbstractTagAwareAdapter.php
@@ -0,0 +1,320 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Adapter;
+
+use Psr\Log\LoggerAwareInterface;
+use Symfony\Component\Cache\CacheItem;
+use Symfony\Component\Cache\Exception\InvalidArgumentException;
+use Symfony\Component\Cache\ResettableInterface;
+use Symfony\Component\Cache\Traits\AbstractAdapterTrait;
+use Symfony\Component\Cache\Traits\ContractsTrait;
+use Symfony\Contracts\Cache\TagAwareCacheInterface;
+
+/**
+ * Abstract for native TagAware adapters.
+ *
+ * To keep info on tags, the tags are both serialized as part of cache value and provided as tag ids
+ * to Adapters on operations when needed for storage to doSave(), doDelete() & doInvalidate().
+ *
+ * @author Nicolas Grekas
+ * @author André Rømcke
+ *
+ * @internal
+ */
+abstract class AbstractTagAwareAdapter implements TagAwareAdapterInterface, TagAwareCacheInterface, LoggerAwareInterface, ResettableInterface
+{
+ use AbstractAdapterTrait;
+ use ContractsTrait;
+
+ private const TAGS_PREFIX = "\1tags\1";
+
+ protected function __construct(string $namespace = '', int $defaultLifetime = 0)
+ {
+ $this->namespace = '' === $namespace ? '' : CacheItem::validateKey($namespace).':';
+ $this->defaultLifetime = $defaultLifetime;
+ if (null !== $this->maxIdLength && \strlen($namespace) > $this->maxIdLength - 24) {
+ throw new InvalidArgumentException(\sprintf('Namespace must be %d chars max, %d given ("%s").', $this->maxIdLength - 24, \strlen($namespace), $namespace));
+ }
+ self::$createCacheItem ??= \Closure::bind(
+ static function ($key, $value, $isHit) {
+ $item = new CacheItem();
+ $item->key = $key;
+ $item->isTaggable = true;
+ // If structure does not match what we expect return item as is (no value and not a hit)
+ if (!\is_array($value) || !\array_key_exists('value', $value)) {
+ return $item;
+ }
+ $item->isHit = $isHit;
+ // Extract value, tags and meta data from the cache value
+ $item->value = $value['value'];
+ $item->metadata[CacheItem::METADATA_TAGS] = isset($value['tags']) ? array_combine($value['tags'], $value['tags']) : [];
+ if (isset($value['meta'])) {
+ // For compactness these values are packed, & expiry is offset to reduce size
+ $v = unpack('Ve/Nc', $value['meta']);
+ $item->metadata[CacheItem::METADATA_EXPIRY] = $v['e'] + CacheItem::METADATA_EXPIRY_OFFSET;
+ $item->metadata[CacheItem::METADATA_CTIME] = $v['c'];
+ }
+
+ return $item;
+ },
+ null,
+ CacheItem::class
+ );
+ self::$mergeByLifetime ??= \Closure::bind(
+ static function ($deferred, &$expiredIds, $getId, $tagPrefix, $defaultLifetime) {
+ $byLifetime = [];
+ $now = microtime(true);
+ $expiredIds = [];
+
+ foreach ($deferred as $key => $item) {
+ $key = (string) $key;
+ if (null === $item->expiry) {
+ $ttl = 0 < $defaultLifetime ? $defaultLifetime : 0;
+ } elseif (!$item->expiry) {
+ $ttl = 0;
+ } elseif (0 >= $ttl = (int) (0.1 + $item->expiry - $now)) {
+ $expiredIds[] = $getId($key);
+ continue;
+ }
+ // Store Value and Tags on the cache value
+ if (isset(($metadata = $item->newMetadata)[CacheItem::METADATA_TAGS])) {
+ $value = ['value' => $item->value, 'tags' => $metadata[CacheItem::METADATA_TAGS]];
+ unset($metadata[CacheItem::METADATA_TAGS]);
+ } else {
+ $value = ['value' => $item->value, 'tags' => []];
+ }
+
+ if ($metadata) {
+ // For compactness, expiry and creation duration are packed, using magic numbers as separators
+ $value['meta'] = pack('VN', (int) (0.1 + $metadata[CacheItem::METADATA_EXPIRY] - CacheItem::METADATA_EXPIRY_OFFSET), $metadata[CacheItem::METADATA_CTIME]);
+ }
+
+ // Extract tag changes, these should be removed from values in doSave()
+ $value['tag-operations'] = ['add' => [], 'remove' => []];
+ $oldTags = $item->metadata[CacheItem::METADATA_TAGS] ?? [];
+ foreach (array_diff_key($value['tags'], $oldTags) as $addedTag) {
+ $value['tag-operations']['add'][] = $getId($tagPrefix.$addedTag);
+ }
+ foreach (array_diff_key($oldTags, $value['tags']) as $removedTag) {
+ $value['tag-operations']['remove'][] = $getId($tagPrefix.$removedTag);
+ }
+ $value['tags'] = array_keys($value['tags']);
+
+ $byLifetime[$ttl][$getId($key)] = $value;
+ $item->metadata = $item->newMetadata;
+ }
+
+ return $byLifetime;
+ },
+ null,
+ CacheItem::class
+ );
+ }
+
+ /**
+ * Persists several cache items immediately.
+ *
+ * @param array $values The values to cache, indexed by their cache identifier
+ * @param int $lifetime The lifetime of the cached values, 0 for persisting until manual cleaning
+ * @param array[] $addTagData Hash where key is tag id, and array value is list of cache id's to add to tag
+ * @param array[] $removeTagData Hash where key is tag id, and array value is list of cache id's to remove to tag
+ *
+ * @return array The identifiers that failed to be cached or a boolean stating if caching succeeded or not
+ */
+ abstract protected function doSave(array $values, int $lifetime, array $addTagData = [], array $removeTagData = []): array;
+
+ /**
+ * Removes multiple items from the pool and their corresponding tags.
+ *
+ * @param array $ids An array of identifiers that should be removed from the pool
+ */
+ abstract protected function doDelete(array $ids): bool;
+
+ /**
+ * Removes relations between tags and deleted items.
+ *
+ * @param array $tagData Array of tag => key identifiers that should be removed from the pool
+ */
+ abstract protected function doDeleteTagRelations(array $tagData): bool;
+
+ /**
+ * Invalidates cached items using tags.
+ *
+ * @param string[] $tagIds An array of tags to invalidate, key is tag and value is tag id
+ */
+ abstract protected function doInvalidate(array $tagIds): bool;
+
+ /**
+ * Delete items and yields the tags they were bound to.
+ */
+ protected function doDeleteYieldTags(array $ids): iterable
+ {
+ foreach ($this->doFetch($ids) as $id => $value) {
+ yield $id => \is_array($value) && \is_array($value['tags'] ?? null) ? $value['tags'] : [];
+ }
+
+ $this->doDelete($ids);
+ }
+
+ public function commit(): bool
+ {
+ $ok = true;
+ $byLifetime = (self::$mergeByLifetime)($this->deferred, $expiredIds, $this->getId(...), self::TAGS_PREFIX, $this->defaultLifetime);
+ $retry = $this->deferred = [];
+
+ if ($expiredIds) {
+ // Tags are not cleaned up in this case, however that is done on invalidateTags().
+ try {
+ $this->doDelete($expiredIds);
+ } catch (\Exception $e) {
+ $ok = false;
+ CacheItem::log($this->logger, 'Failed to delete expired items: '.$e->getMessage(), ['exception' => $e, 'cache-adapter' => get_debug_type($this)]);
+ }
+ }
+ foreach ($byLifetime as $lifetime => $values) {
+ try {
+ $values = $this->extractTagData($values, $addTagData, $removeTagData);
+ $e = $this->doSave($values, $lifetime, $addTagData, $removeTagData);
+ } catch (\Exception $e) {
+ }
+ if (true === $e || [] === $e) {
+ continue;
+ }
+ if (\is_array($e) || 1 === \count($values)) {
+ foreach (\is_array($e) ? $e : array_keys($values) as $id) {
+ $ok = false;
+ $v = $values[$id];
+ $type = get_debug_type($v);
+ $message = \sprintf('Failed to save key "{key}" of type %s%s', $type, $e instanceof \Exception ? ': '.$e->getMessage() : '.');
+ CacheItem::log($this->logger, $message, ['key' => substr($id, \strlen($this->namespace)), 'exception' => $e instanceof \Exception ? $e : null, 'cache-adapter' => get_debug_type($this)]);
+ }
+ } else {
+ foreach ($values as $id => $v) {
+ $retry[$lifetime][] = $id;
+ }
+ }
+ }
+
+ // When bulk-save failed, retry each item individually
+ foreach ($retry as $lifetime => $ids) {
+ foreach ($ids as $id) {
+ try {
+ $v = $byLifetime[$lifetime][$id];
+ $values = $this->extractTagData([$id => $v], $addTagData, $removeTagData);
+ $e = $this->doSave($values, $lifetime, $addTagData, $removeTagData);
+ } catch (\Exception $e) {
+ }
+ if (true === $e || [] === $e) {
+ continue;
+ }
+ $ok = false;
+ $type = get_debug_type($v);
+ $message = \sprintf('Failed to save key "{key}" of type %s%s', $type, $e instanceof \Exception ? ': '.$e->getMessage() : '.');
+ CacheItem::log($this->logger, $message, ['key' => substr($id, \strlen($this->namespace)), 'exception' => $e instanceof \Exception ? $e : null, 'cache-adapter' => get_debug_type($this)]);
+ }
+ }
+
+ return $ok;
+ }
+
+ public function deleteItems(array $keys): bool
+ {
+ if (!$keys) {
+ return true;
+ }
+
+ $ok = true;
+ $ids = [];
+ $tagData = [];
+
+ foreach ($keys as $key) {
+ $ids[$key] = $this->getId($key);
+ unset($this->deferred[$key]);
+ }
+
+ try {
+ foreach ($this->doDeleteYieldTags(array_values($ids)) as $id => $tags) {
+ foreach ($tags as $tag) {
+ $tagData[$this->getId(self::TAGS_PREFIX.$tag)][] = $id;
+ }
+ }
+ } catch (\Exception) {
+ $ok = false;
+ }
+
+ try {
+ if ((!$tagData || $this->doDeleteTagRelations($tagData)) && $ok) {
+ return true;
+ }
+ } catch (\Exception) {
+ }
+
+ // When bulk-delete failed, retry each item individually
+ foreach ($ids as $key => $id) {
+ try {
+ $e = null;
+ if ($this->doDelete([$id])) {
+ continue;
+ }
+ } catch (\Exception $e) {
+ }
+ $message = 'Failed to delete key "{key}"'.($e instanceof \Exception ? ': '.$e->getMessage() : '.');
+ CacheItem::log($this->logger, $message, ['key' => $key, 'exception' => $e, 'cache-adapter' => get_debug_type($this)]);
+ $ok = false;
+ }
+
+ return $ok;
+ }
+
+ public function invalidateTags(array $tags): bool
+ {
+ if (!$tags) {
+ return false;
+ }
+
+ $tagIds = [];
+ foreach (array_unique($tags) as $tag) {
+ $tagIds[] = $this->getId(self::TAGS_PREFIX.$tag);
+ }
+
+ try {
+ if ($this->doInvalidate($tagIds)) {
+ return true;
+ }
+ } catch (\Exception $e) {
+ CacheItem::log($this->logger, 'Failed to invalidate tags: '.$e->getMessage(), ['exception' => $e, 'cache-adapter' => get_debug_type($this)]);
+ }
+
+ return false;
+ }
+
+ /**
+ * Extracts tags operation data from $values set in mergeByLifetime, and returns values without it.
+ */
+ private function extractTagData(array $values, ?array &$addTagData, ?array &$removeTagData): array
+ {
+ $addTagData = $removeTagData = [];
+ foreach ($values as $id => $value) {
+ foreach ($value['tag-operations']['add'] as $tag => $tagId) {
+ $addTagData[$tagId][] = $id;
+ }
+
+ foreach ($value['tag-operations']['remove'] as $tag => $tagId) {
+ $removeTagData[$tagId][] = $id;
+ }
+
+ unset($values[$id]['tag-operations']);
+ }
+
+ return $values;
+ }
+}
diff --git a/symfony/cache/Adapter/AdapterInterface.php b/symfony/cache/Adapter/AdapterInterface.php
new file mode 100644
index 0000000000000000000000000000000000000000..e55672093f16b3882bb3b5943dc883113a48d941
--- /dev/null
+++ b/symfony/cache/Adapter/AdapterInterface.php
@@ -0,0 +1,35 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Adapter;
+
+use Psr\Cache\CacheItemPoolInterface;
+use Symfony\Component\Cache\CacheItem;
+
+// Help opcache.preload discover always-needed symbols
+class_exists(CacheItem::class);
+
+/**
+ * Interface for adapters managing instances of Symfony's CacheItem.
+ *
+ * @author Kévin Dunglas
+ */
+interface AdapterInterface extends CacheItemPoolInterface
+{
+ public function getItem(mixed $key): CacheItem;
+
+ /**
+ * @return iterable
+ */
+ public function getItems(array $keys = []): iterable;
+
+ public function clear(string $prefix = ''): bool;
+}
diff --git a/symfony/cache/Adapter/ApcuAdapter.php b/symfony/cache/Adapter/ApcuAdapter.php
new file mode 100644
index 0000000000000000000000000000000000000000..50ce8448e3532ca52c9bbd2801798579355843bf
--- /dev/null
+++ b/symfony/cache/Adapter/ApcuAdapter.php
@@ -0,0 +1,110 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Adapter;
+
+use Symfony\Component\Cache\CacheItem;
+use Symfony\Component\Cache\Exception\CacheException;
+use Symfony\Component\Cache\Marshaller\MarshallerInterface;
+
+/**
+ * @author Nicolas Grekas
+ */
+class ApcuAdapter extends AbstractAdapter
+{
+ private ?MarshallerInterface $marshaller;
+
+ /**
+ * @throws CacheException if APCu is not enabled
+ */
+ public function __construct(string $namespace = '', int $defaultLifetime = 0, ?string $version = null, ?MarshallerInterface $marshaller = null)
+ {
+ if (!static::isSupported()) {
+ throw new CacheException('APCu is not enabled.');
+ }
+ if ('cli' === \PHP_SAPI) {
+ ini_set('apc.use_request_time', 0);
+ }
+ parent::__construct($namespace, $defaultLifetime);
+
+ if (null !== $version) {
+ CacheItem::validateKey($version);
+
+ if (!apcu_exists($version.'@'.$namespace)) {
+ $this->doClear($namespace);
+ apcu_add($version.'@'.$namespace, null);
+ }
+ }
+
+ $this->marshaller = $marshaller;
+ }
+
+ /**
+ * @return bool
+ */
+ public static function isSupported()
+ {
+ return \function_exists('apcu_fetch') && filter_var(\ini_get('apc.enabled'), \FILTER_VALIDATE_BOOL);
+ }
+
+ protected function doFetch(array $ids): iterable
+ {
+ $unserializeCallbackHandler = ini_set('unserialize_callback_func', __CLASS__.'::handleUnserializeCallback');
+ try {
+ $values = [];
+ foreach (apcu_fetch($ids, $ok) ?: [] as $k => $v) {
+ if (null !== $v || $ok) {
+ $values[$k] = null !== $this->marshaller ? $this->marshaller->unmarshall($v) : $v;
+ }
+ }
+
+ return $values;
+ } catch (\Error $e) {
+ throw new \ErrorException($e->getMessage(), $e->getCode(), \E_ERROR, $e->getFile(), $e->getLine());
+ } finally {
+ ini_set('unserialize_callback_func', $unserializeCallbackHandler);
+ }
+ }
+
+ protected function doHave(string $id): bool
+ {
+ return apcu_exists($id);
+ }
+
+ protected function doClear(string $namespace): bool
+ {
+ return isset($namespace[0]) && class_exists(\APCUIterator::class, false) && ('cli' !== \PHP_SAPI || filter_var(\ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOL))
+ ? apcu_delete(new \APCUIterator(\sprintf('/^%s/', preg_quote($namespace, '/')), \APC_ITER_KEY))
+ : apcu_clear_cache();
+ }
+
+ protected function doDelete(array $ids): bool
+ {
+ foreach ($ids as $id) {
+ apcu_delete($id);
+ }
+
+ return true;
+ }
+
+ protected function doSave(array $values, int $lifetime): array|bool
+ {
+ if (null !== $this->marshaller && (!$values = $this->marshaller->marshall($values, $failed))) {
+ return $failed;
+ }
+
+ if (false === $failures = apcu_store($values, null, $lifetime)) {
+ $failures = $values;
+ }
+
+ return array_keys($failures);
+ }
+}
diff --git a/symfony/cache/Adapter/ArrayAdapter.php b/symfony/cache/Adapter/ArrayAdapter.php
new file mode 100644
index 0000000000000000000000000000000000000000..38e19cbddd77ac43ccdd5a8e2f47370da43e884a
--- /dev/null
+++ b/symfony/cache/Adapter/ArrayAdapter.php
@@ -0,0 +1,368 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Adapter;
+
+use Psr\Cache\CacheItemInterface;
+use Psr\Log\LoggerAwareInterface;
+use Psr\Log\LoggerAwareTrait;
+use Symfony\Component\Cache\CacheItem;
+use Symfony\Component\Cache\Exception\InvalidArgumentException;
+use Symfony\Component\Cache\ResettableInterface;
+use Symfony\Contracts\Cache\CacheInterface;
+
+/**
+ * An in-memory cache storage.
+ *
+ * Acts as a least-recently-used (LRU) storage when configured with a maximum number of items.
+ *
+ * @author Nicolas Grekas
+ */
+class ArrayAdapter implements AdapterInterface, CacheInterface, LoggerAwareInterface, ResettableInterface
+{
+ use LoggerAwareTrait;
+
+ private bool $storeSerialized;
+ private array $values = [];
+ private array $tags = [];
+ private array $expiries = [];
+ private int $defaultLifetime;
+ private float $maxLifetime;
+ private int $maxItems;
+
+ private static \Closure $createCacheItem;
+
+ /**
+ * @param bool $storeSerialized Disabling serialization can lead to cache corruptions when storing mutable values but increases performance otherwise
+ */
+ public function __construct(int $defaultLifetime = 0, bool $storeSerialized = true, float $maxLifetime = 0, int $maxItems = 0)
+ {
+ if (0 > $maxLifetime) {
+ throw new InvalidArgumentException(\sprintf('Argument $maxLifetime must be positive, %F passed.', $maxLifetime));
+ }
+
+ if (0 > $maxItems) {
+ throw new InvalidArgumentException(\sprintf('Argument $maxItems must be a positive integer, %d passed.', $maxItems));
+ }
+
+ $this->defaultLifetime = $defaultLifetime;
+ $this->storeSerialized = $storeSerialized;
+ $this->maxLifetime = $maxLifetime;
+ $this->maxItems = $maxItems;
+ self::$createCacheItem ??= \Closure::bind(
+ static function ($key, $value, $isHit, $tags) {
+ $item = new CacheItem();
+ $item->key = $key;
+ $item->value = $value;
+ $item->isHit = $isHit;
+ if (null !== $tags) {
+ $item->metadata[CacheItem::METADATA_TAGS] = $tags;
+ }
+
+ return $item;
+ },
+ null,
+ CacheItem::class
+ );
+ }
+
+ public function get(string $key, callable $callback, ?float $beta = null, ?array &$metadata = null): mixed
+ {
+ $item = $this->getItem($key);
+ $metadata = $item->getMetadata();
+
+ // ArrayAdapter works in memory, we don't care about stampede protection
+ if (\INF === $beta || !$item->isHit()) {
+ $save = true;
+ $item->set($callback($item, $save));
+ if ($save) {
+ $this->save($item);
+ }
+ }
+
+ return $item->get();
+ }
+
+ public function delete(string $key): bool
+ {
+ return $this->deleteItem($key);
+ }
+
+ public function hasItem(mixed $key): bool
+ {
+ if (\is_string($key) && isset($this->expiries[$key]) && $this->expiries[$key] > microtime(true)) {
+ if ($this->maxItems) {
+ // Move the item last in the storage
+ $value = $this->values[$key];
+ unset($this->values[$key]);
+ $this->values[$key] = $value;
+ }
+
+ return true;
+ }
+ \assert('' !== CacheItem::validateKey($key));
+
+ return isset($this->expiries[$key]) && !$this->deleteItem($key);
+ }
+
+ public function getItem(mixed $key): CacheItem
+ {
+ if (!$isHit = $this->hasItem($key)) {
+ $value = null;
+
+ if (!$this->maxItems) {
+ // Track misses in non-LRU mode only
+ $this->values[$key] = null;
+ }
+ } else {
+ $value = $this->storeSerialized ? $this->unfreeze($key, $isHit) : $this->values[$key];
+ }
+
+ return (self::$createCacheItem)($key, $value, $isHit, $this->tags[$key] ?? null);
+ }
+
+ public function getItems(array $keys = []): iterable
+ {
+ \assert(self::validateKeys($keys));
+
+ return $this->generateItems($keys, microtime(true), self::$createCacheItem);
+ }
+
+ public function deleteItem(mixed $key): bool
+ {
+ \assert('' !== CacheItem::validateKey($key));
+ unset($this->values[$key], $this->tags[$key], $this->expiries[$key]);
+
+ return true;
+ }
+
+ public function deleteItems(array $keys): bool
+ {
+ foreach ($keys as $key) {
+ $this->deleteItem($key);
+ }
+
+ return true;
+ }
+
+ public function save(CacheItemInterface $item): bool
+ {
+ if (!$item instanceof CacheItem) {
+ return false;
+ }
+ $item = (array) $item;
+ $key = $item["\0*\0key"];
+ $value = $item["\0*\0value"];
+ $expiry = $item["\0*\0expiry"];
+
+ $now = microtime(true);
+
+ if (null !== $expiry) {
+ if (!$expiry) {
+ $expiry = \PHP_INT_MAX;
+ } elseif ($expiry <= $now) {
+ $this->deleteItem($key);
+
+ return true;
+ }
+ }
+ if ($this->storeSerialized && null === $value = $this->freeze($value, $key)) {
+ return false;
+ }
+ if (null === $expiry && 0 < $this->defaultLifetime) {
+ $expiry = $this->defaultLifetime;
+ $expiry = $now + ($expiry > ($this->maxLifetime ?: $expiry) ? $this->maxLifetime : $expiry);
+ } elseif ($this->maxLifetime && (null === $expiry || $expiry > $now + $this->maxLifetime)) {
+ $expiry = $now + $this->maxLifetime;
+ }
+
+ if ($this->maxItems) {
+ unset($this->values[$key], $this->tags[$key]);
+
+ // Iterate items and vacuum expired ones while we are at it
+ foreach ($this->values as $k => $v) {
+ if ($this->expiries[$k] > $now && \count($this->values) < $this->maxItems) {
+ break;
+ }
+
+ unset($this->values[$k], $this->tags[$k], $this->expiries[$k]);
+ }
+ }
+
+ $this->values[$key] = $value;
+ $this->expiries[$key] = $expiry ?? \PHP_INT_MAX;
+
+ if (null === $this->tags[$key] = $item["\0*\0newMetadata"][CacheItem::METADATA_TAGS] ?? null) {
+ unset($this->tags[$key]);
+ }
+
+ return true;
+ }
+
+ public function saveDeferred(CacheItemInterface $item): bool
+ {
+ return $this->save($item);
+ }
+
+ public function commit(): bool
+ {
+ return true;
+ }
+
+ public function clear(string $prefix = ''): bool
+ {
+ if ('' !== $prefix) {
+ $now = microtime(true);
+
+ foreach ($this->values as $key => $value) {
+ if (!isset($this->expiries[$key]) || $this->expiries[$key] <= $now || str_starts_with($key, $prefix)) {
+ unset($this->values[$key], $this->tags[$key], $this->expiries[$key]);
+ }
+ }
+
+ if ($this->values) {
+ return true;
+ }
+ }
+
+ $this->values = $this->tags = $this->expiries = [];
+
+ return true;
+ }
+
+ /**
+ * Returns all cached values, with cache miss as null.
+ */
+ public function getValues(): array
+ {
+ if (!$this->storeSerialized) {
+ return $this->values;
+ }
+
+ $values = $this->values;
+ foreach ($values as $k => $v) {
+ if (null === $v || 'N;' === $v) {
+ continue;
+ }
+ if (!\is_string($v) || !isset($v[2]) || ':' !== $v[1]) {
+ $values[$k] = serialize($v);
+ }
+ }
+
+ return $values;
+ }
+
+ /**
+ * @return void
+ */
+ public function reset()
+ {
+ $this->clear();
+ }
+
+ private function generateItems(array $keys, float $now, \Closure $f): \Generator
+ {
+ foreach ($keys as $i => $key) {
+ if (!$isHit = isset($this->expiries[$key]) && ($this->expiries[$key] > $now || !$this->deleteItem($key))) {
+ $value = null;
+
+ if (!$this->maxItems) {
+ // Track misses in non-LRU mode only
+ $this->values[$key] = null;
+ }
+ } else {
+ if ($this->maxItems) {
+ // Move the item last in the storage
+ $value = $this->values[$key];
+ unset($this->values[$key]);
+ $this->values[$key] = $value;
+ }
+
+ $value = $this->storeSerialized ? $this->unfreeze($key, $isHit) : $this->values[$key];
+ }
+ unset($keys[$i]);
+
+ yield $key => $f($key, $value, $isHit, $this->tags[$key] ?? null);
+ }
+
+ foreach ($keys as $key) {
+ yield $key => $f($key, null, false);
+ }
+ }
+
+ private function freeze($value, string $key): string|int|float|bool|array|\UnitEnum|null
+ {
+ if (null === $value) {
+ return 'N;';
+ }
+ if (\is_string($value)) {
+ // Serialize strings if they could be confused with serialized objects or arrays
+ if ('N;' === $value || (isset($value[2]) && ':' === $value[1])) {
+ return serialize($value);
+ }
+ } elseif (!\is_scalar($value)) {
+ try {
+ $serialized = serialize($value);
+ } catch (\Exception $e) {
+ if (!isset($this->expiries[$key])) {
+ unset($this->values[$key]);
+ }
+ $type = get_debug_type($value);
+ $message = \sprintf('Failed to save key "{key}" of type %s: %s', $type, $e->getMessage());
+ CacheItem::log($this->logger, $message, ['key' => $key, 'exception' => $e, 'cache-adapter' => get_debug_type($this)]);
+
+ return null;
+ }
+ // Keep value serialized if it contains any objects or any internal references
+ if ('C' === $serialized[0] || 'O' === $serialized[0] || preg_match('/;[OCRr]:[1-9]/', $serialized)) {
+ return $serialized;
+ }
+ }
+
+ return $value;
+ }
+
+ private function unfreeze(string $key, bool &$isHit): mixed
+ {
+ if ('N;' === $value = $this->values[$key]) {
+ return null;
+ }
+ if (\is_string($value) && isset($value[2]) && ':' === $value[1]) {
+ try {
+ $value = unserialize($value);
+ } catch (\Exception $e) {
+ CacheItem::log($this->logger, 'Failed to unserialize key "{key}": '.$e->getMessage(), ['key' => $key, 'exception' => $e, 'cache-adapter' => get_debug_type($this)]);
+ $value = false;
+ }
+ if (false === $value) {
+ $value = null;
+ $isHit = false;
+
+ if (!$this->maxItems) {
+ $this->values[$key] = null;
+ }
+ }
+ }
+
+ return $value;
+ }
+
+ private function validateKeys(array $keys): bool
+ {
+ foreach ($keys as $key) {
+ if (!\is_string($key) || !isset($this->expiries[$key])) {
+ CacheItem::validateKey($key);
+ }
+ }
+
+ return true;
+ }
+}
diff --git a/symfony/cache/Adapter/ChainAdapter.php b/symfony/cache/Adapter/ChainAdapter.php
new file mode 100644
index 0000000000000000000000000000000000000000..1d187f65cf1a684bba4107aadd7bfd131f924121
--- /dev/null
+++ b/symfony/cache/Adapter/ChainAdapter.php
@@ -0,0 +1,294 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Adapter;
+
+use Psr\Cache\CacheItemInterface;
+use Psr\Cache\CacheItemPoolInterface;
+use Symfony\Component\Cache\CacheItem;
+use Symfony\Component\Cache\Exception\InvalidArgumentException;
+use Symfony\Component\Cache\PruneableInterface;
+use Symfony\Component\Cache\ResettableInterface;
+use Symfony\Component\Cache\Traits\ContractsTrait;
+use Symfony\Contracts\Cache\CacheInterface;
+use Symfony\Contracts\Service\ResetInterface;
+
+/**
+ * Chains several adapters together.
+ *
+ * Cached items are fetched from the first adapter having them in its data store.
+ * They are saved and deleted in all adapters at once.
+ *
+ * @author Kévin Dunglas
+ */
+class ChainAdapter implements AdapterInterface, CacheInterface, PruneableInterface, ResettableInterface
+{
+ use ContractsTrait;
+
+ private array $adapters = [];
+ private int $adapterCount;
+ private int $defaultLifetime;
+
+ private static \Closure $syncItem;
+
+ /**
+ * @param CacheItemPoolInterface[] $adapters The ordered list of adapters used to fetch cached items
+ * @param int $defaultLifetime The default lifetime of items propagated from lower adapters to upper ones
+ */
+ public function __construct(array $adapters, int $defaultLifetime = 0)
+ {
+ if (!$adapters) {
+ throw new InvalidArgumentException('At least one adapter must be specified.');
+ }
+
+ foreach ($adapters as $adapter) {
+ if (!$adapter instanceof CacheItemPoolInterface) {
+ throw new InvalidArgumentException(\sprintf('The class "%s" does not implement the "%s" interface.', get_debug_type($adapter), CacheItemPoolInterface::class));
+ }
+ if ('cli' === \PHP_SAPI && $adapter instanceof ApcuAdapter && !filter_var(\ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOL)) {
+ continue; // skip putting APCu in the chain when the backend is disabled
+ }
+
+ if ($adapter instanceof AdapterInterface) {
+ $this->adapters[] = $adapter;
+ } else {
+ $this->adapters[] = new ProxyAdapter($adapter);
+ }
+ }
+ $this->adapterCount = \count($this->adapters);
+ $this->defaultLifetime = $defaultLifetime;
+
+ self::$syncItem ??= \Closure::bind(
+ static function ($sourceItem, $item, $defaultLifetime, $sourceMetadata = null) {
+ $sourceItem->isTaggable = false;
+ $sourceMetadata ??= $sourceItem->metadata;
+
+ $item->value = $sourceItem->value;
+ $item->isHit = $sourceItem->isHit;
+ $item->metadata = $item->newMetadata = $sourceItem->metadata = $sourceMetadata;
+
+ if (isset($item->metadata[CacheItem::METADATA_EXPIRY])) {
+ $item->expiresAt(\DateTimeImmutable::createFromFormat('U.u', \sprintf('%.6F', $item->metadata[CacheItem::METADATA_EXPIRY])));
+ } elseif (0 < $defaultLifetime) {
+ $item->expiresAfter($defaultLifetime);
+ }
+
+ return $item;
+ },
+ null,
+ CacheItem::class
+ );
+ }
+
+ public function get(string $key, callable $callback, ?float $beta = null, ?array &$metadata = null): mixed
+ {
+ $doSave = true;
+ $callback = static function (CacheItem $item, bool &$save) use ($callback, &$doSave) {
+ $value = $callback($item, $save);
+ $doSave = $save;
+
+ return $value;
+ };
+
+ $wrap = function (?CacheItem $item = null, bool &$save = true) use ($key, $callback, $beta, &$wrap, &$doSave, &$metadata) {
+ static $lastItem;
+ static $i = 0;
+ $adapter = $this->adapters[$i];
+ if (isset($this->adapters[++$i])) {
+ $callback = $wrap;
+ $beta = \INF === $beta ? \INF : 0;
+ }
+ if ($adapter instanceof CacheInterface && $i !== $this->adapterCount) {
+ $value = $adapter->get($key, $callback, $beta, $metadata);
+ } else {
+ $value = $this->doGet($adapter, $key, $callback, $beta, $metadata);
+ }
+ if (null !== $item) {
+ (self::$syncItem)($lastItem ??= $item, $item, $this->defaultLifetime, $metadata);
+ }
+ $save = $doSave;
+
+ return $value;
+ };
+
+ return $wrap();
+ }
+
+ public function getItem(mixed $key): CacheItem
+ {
+ $syncItem = self::$syncItem;
+ $misses = [];
+
+ foreach ($this->adapters as $i => $adapter) {
+ $item = $adapter->getItem($key);
+
+ if ($item->isHit()) {
+ while (0 <= --$i) {
+ $this->adapters[$i]->save($syncItem($item, $misses[$i], $this->defaultLifetime));
+ }
+
+ return $item;
+ }
+
+ $misses[$i] = $item;
+ }
+
+ return $item;
+ }
+
+ public function getItems(array $keys = []): iterable
+ {
+ return $this->generateItems($this->adapters[0]->getItems($keys), 0);
+ }
+
+ private function generateItems(iterable $items, int $adapterIndex): \Generator
+ {
+ $missing = [];
+ $misses = [];
+ $nextAdapterIndex = $adapterIndex + 1;
+ $nextAdapter = $this->adapters[$nextAdapterIndex] ?? null;
+
+ foreach ($items as $k => $item) {
+ if (!$nextAdapter || $item->isHit()) {
+ yield $k => $item;
+ } else {
+ $missing[] = $k;
+ $misses[$k] = $item;
+ }
+ }
+
+ if ($missing) {
+ $syncItem = self::$syncItem;
+ $adapter = $this->adapters[$adapterIndex];
+ $items = $this->generateItems($nextAdapter->getItems($missing), $nextAdapterIndex);
+
+ foreach ($items as $k => $item) {
+ if ($item->isHit()) {
+ $adapter->save($syncItem($item, $misses[$k], $this->defaultLifetime));
+ }
+
+ yield $k => $item;
+ }
+ }
+ }
+
+ public function hasItem(mixed $key): bool
+ {
+ foreach ($this->adapters as $adapter) {
+ if ($adapter->hasItem($key)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public function clear(string $prefix = ''): bool
+ {
+ $cleared = true;
+ $i = $this->adapterCount;
+
+ while ($i--) {
+ if ($this->adapters[$i] instanceof AdapterInterface) {
+ $cleared = $this->adapters[$i]->clear($prefix) && $cleared;
+ } else {
+ $cleared = $this->adapters[$i]->clear() && $cleared;
+ }
+ }
+
+ return $cleared;
+ }
+
+ public function deleteItem(mixed $key): bool
+ {
+ $deleted = true;
+ $i = $this->adapterCount;
+
+ while ($i--) {
+ $deleted = $this->adapters[$i]->deleteItem($key) && $deleted;
+ }
+
+ return $deleted;
+ }
+
+ public function deleteItems(array $keys): bool
+ {
+ $deleted = true;
+ $i = $this->adapterCount;
+
+ while ($i--) {
+ $deleted = $this->adapters[$i]->deleteItems($keys) && $deleted;
+ }
+
+ return $deleted;
+ }
+
+ public function save(CacheItemInterface $item): bool
+ {
+ $saved = true;
+ $i = $this->adapterCount;
+
+ while ($i--) {
+ $saved = $this->adapters[$i]->save($item) && $saved;
+ }
+
+ return $saved;
+ }
+
+ public function saveDeferred(CacheItemInterface $item): bool
+ {
+ $saved = true;
+ $i = $this->adapterCount;
+
+ while ($i--) {
+ $saved = $this->adapters[$i]->saveDeferred($item) && $saved;
+ }
+
+ return $saved;
+ }
+
+ public function commit(): bool
+ {
+ $committed = true;
+ $i = $this->adapterCount;
+
+ while ($i--) {
+ $committed = $this->adapters[$i]->commit() && $committed;
+ }
+
+ return $committed;
+ }
+
+ public function prune(): bool
+ {
+ $pruned = true;
+
+ foreach ($this->adapters as $adapter) {
+ if ($adapter instanceof PruneableInterface) {
+ $pruned = $adapter->prune() && $pruned;
+ }
+ }
+
+ return $pruned;
+ }
+
+ /**
+ * @return void
+ */
+ public function reset()
+ {
+ foreach ($this->adapters as $adapter) {
+ if ($adapter instanceof ResetInterface) {
+ $adapter->reset();
+ }
+ }
+ }
+}
diff --git a/symfony/cache/Adapter/CouchbaseBucketAdapter.php b/symfony/cache/Adapter/CouchbaseBucketAdapter.php
new file mode 100644
index 0000000000000000000000000000000000000000..18136da17eab63bf4fc2478ab3d9d7bd057a8a92
--- /dev/null
+++ b/symfony/cache/Adapter/CouchbaseBucketAdapter.php
@@ -0,0 +1,232 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Adapter;
+
+use Symfony\Component\Cache\Exception\CacheException;
+use Symfony\Component\Cache\Exception\InvalidArgumentException;
+use Symfony\Component\Cache\Marshaller\DefaultMarshaller;
+use Symfony\Component\Cache\Marshaller\MarshallerInterface;
+
+/**
+ * @author Antonio Jose Cerezo Aranda
+ */
+class CouchbaseBucketAdapter extends AbstractAdapter
+{
+ private const THIRTY_DAYS_IN_SECONDS = 2592000;
+ private const MAX_KEY_LENGTH = 250;
+ private const KEY_NOT_FOUND = 13;
+ private const VALID_DSN_OPTIONS = [
+ 'operationTimeout',
+ 'configTimeout',
+ 'configNodeTimeout',
+ 'n1qlTimeout',
+ 'httpTimeout',
+ 'configDelay',
+ 'htconfigIdleTimeout',
+ 'durabilityInterval',
+ 'durabilityTimeout',
+ ];
+
+ private \CouchbaseBucket $bucket;
+ private MarshallerInterface $marshaller;
+
+ public function __construct(\CouchbaseBucket $bucket, string $namespace = '', int $defaultLifetime = 0, ?MarshallerInterface $marshaller = null)
+ {
+ if (!static::isSupported()) {
+ throw new CacheException('Couchbase >= 2.6.0 < 3.0.0 is required.');
+ }
+
+ $this->maxIdLength = static::MAX_KEY_LENGTH;
+
+ $this->bucket = $bucket;
+
+ parent::__construct($namespace, $defaultLifetime);
+ $this->enableVersioning();
+ $this->marshaller = $marshaller ?? new DefaultMarshaller();
+ }
+
+ public static function createConnection(#[\SensitiveParameter] array|string $servers, array $options = []): \CouchbaseBucket
+ {
+ if (\is_string($servers)) {
+ $servers = [$servers];
+ }
+
+ if (!static::isSupported()) {
+ throw new CacheException('Couchbase >= 2.6.0 < 3.0.0 is required.');
+ }
+
+ set_error_handler(static fn ($type, $msg, $file, $line) => throw new \ErrorException($msg, 0, $type, $file, $line));
+
+ $dsnPattern = '/^(?couchbase(?:s)?)\:\/\/(?:(?[^\:]+)\:(?[^\@]{6,})@)?'
+ .'(?[^\:]+(?:\:\d+)?)(?:\/(?[^\?]+))(?:\?(?.*))?$/i';
+
+ $newServers = [];
+ $protocol = 'couchbase';
+ try {
+ $options = self::initOptions($options);
+ $username = $options['username'];
+ $password = $options['password'];
+
+ foreach ($servers as $dsn) {
+ if (!str_starts_with($dsn, 'couchbase:')) {
+ throw new InvalidArgumentException('Invalid Couchbase DSN: it does not start with "couchbase:".');
+ }
+
+ preg_match($dsnPattern, $dsn, $matches);
+
+ $username = $matches['username'] ?: $username;
+ $password = $matches['password'] ?: $password;
+ $protocol = $matches['protocol'] ?: $protocol;
+
+ if (isset($matches['options'])) {
+ $optionsInDsn = self::getOptions($matches['options']);
+
+ foreach ($optionsInDsn as $parameter => $value) {
+ $options[$parameter] = $value;
+ }
+ }
+
+ $newServers[] = $matches['host'];
+ }
+
+ $connectionString = $protocol.'://'.implode(',', $newServers);
+
+ $client = new \CouchbaseCluster($connectionString);
+ $client->authenticateAs($username, $password);
+
+ $bucket = $client->openBucket($matches['bucketName']);
+
+ unset($options['username'], $options['password']);
+ foreach ($options as $option => $value) {
+ if (!empty($value)) {
+ $bucket->$option = $value;
+ }
+ }
+
+ return $bucket;
+ } finally {
+ restore_error_handler();
+ }
+ }
+
+ public static function isSupported(): bool
+ {
+ return \extension_loaded('couchbase') && version_compare(phpversion('couchbase'), '2.6.0', '>=') && version_compare(phpversion('couchbase'), '3.0', '<');
+ }
+
+ private static function getOptions(string $options): array
+ {
+ $results = [];
+ $optionsInArray = explode('&', $options);
+
+ foreach ($optionsInArray as $option) {
+ [$key, $value] = explode('=', $option);
+
+ if (\in_array($key, static::VALID_DSN_OPTIONS, true)) {
+ $results[$key] = $value;
+ }
+ }
+
+ return $results;
+ }
+
+ private static function initOptions(array $options): array
+ {
+ $options['username'] ??= '';
+ $options['password'] ??= '';
+ $options['operationTimeout'] ??= 0;
+ $options['configTimeout'] ??= 0;
+ $options['configNodeTimeout'] ??= 0;
+ $options['n1qlTimeout'] ??= 0;
+ $options['httpTimeout'] ??= 0;
+ $options['configDelay'] ??= 0;
+ $options['htconfigIdleTimeout'] ??= 0;
+ $options['durabilityInterval'] ??= 0;
+ $options['durabilityTimeout'] ??= 0;
+
+ return $options;
+ }
+
+ protected function doFetch(array $ids): iterable
+ {
+ $resultsCouchbase = $this->bucket->get($ids);
+
+ $results = [];
+ foreach ($resultsCouchbase as $key => $value) {
+ if (null !== $value->error) {
+ continue;
+ }
+ $results[$key] = $this->marshaller->unmarshall($value->value);
+ }
+
+ return $results;
+ }
+
+ protected function doHave(string $id): bool
+ {
+ return false !== $this->bucket->get($id);
+ }
+
+ protected function doClear(string $namespace): bool
+ {
+ if ('' === $namespace) {
+ $this->bucket->manager()->flush();
+
+ return true;
+ }
+
+ return false;
+ }
+
+ protected function doDelete(array $ids): bool
+ {
+ $results = $this->bucket->remove(array_values($ids));
+
+ foreach ($results as $key => $result) {
+ if (null !== $result->error && static::KEY_NOT_FOUND !== $result->error->getCode()) {
+ continue;
+ }
+ unset($results[$key]);
+ }
+
+ return 0 === \count($results);
+ }
+
+ protected function doSave(array $values, int $lifetime): array|bool
+ {
+ if (!$values = $this->marshaller->marshall($values, $failed)) {
+ return $failed;
+ }
+
+ $lifetime = $this->normalizeExpiry($lifetime);
+
+ $ko = [];
+ foreach ($values as $key => $value) {
+ $result = $this->bucket->upsert($key, $value, ['expiry' => $lifetime]);
+
+ if (null !== $result->error) {
+ $ko[$key] = $result;
+ }
+ }
+
+ return [] === $ko ? true : $ko;
+ }
+
+ private function normalizeExpiry(int $expiry): int
+ {
+ if ($expiry && $expiry > static::THIRTY_DAYS_IN_SECONDS) {
+ $expiry += time();
+ }
+
+ return $expiry;
+ }
+}
diff --git a/symfony/cache/Adapter/CouchbaseCollectionAdapter.php b/symfony/cache/Adapter/CouchbaseCollectionAdapter.php
new file mode 100644
index 0000000000000000000000000000000000000000..a1cfb08432a46ca38d14e24c7bfd14ae845b778f
--- /dev/null
+++ b/symfony/cache/Adapter/CouchbaseCollectionAdapter.php
@@ -0,0 +1,199 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Adapter;
+
+use Couchbase\Bucket;
+use Couchbase\Cluster;
+use Couchbase\ClusterOptions;
+use Couchbase\Collection;
+use Couchbase\DocumentNotFoundException;
+use Couchbase\UpsertOptions;
+use Symfony\Component\Cache\Exception\CacheException;
+use Symfony\Component\Cache\Exception\InvalidArgumentException;
+use Symfony\Component\Cache\Marshaller\DefaultMarshaller;
+use Symfony\Component\Cache\Marshaller\MarshallerInterface;
+
+/**
+ * @author Antonio Jose Cerezo Aranda
+ */
+class CouchbaseCollectionAdapter extends AbstractAdapter
+{
+ private const MAX_KEY_LENGTH = 250;
+
+ private Collection $connection;
+ private MarshallerInterface $marshaller;
+
+ public function __construct(Collection $connection, string $namespace = '', int $defaultLifetime = 0, ?MarshallerInterface $marshaller = null)
+ {
+ if (!static::isSupported()) {
+ throw new CacheException('Couchbase >= 3.0.5 < 4.0.0 is required.');
+ }
+
+ $this->maxIdLength = static::MAX_KEY_LENGTH;
+
+ $this->connection = $connection;
+
+ parent::__construct($namespace, $defaultLifetime);
+ $this->enableVersioning();
+ $this->marshaller = $marshaller ?? new DefaultMarshaller();
+ }
+
+ public static function createConnection(#[\SensitiveParameter] array|string $dsn, array $options = []): Bucket|Collection
+ {
+ if (\is_string($dsn)) {
+ $dsn = [$dsn];
+ }
+
+ if (!static::isSupported()) {
+ throw new CacheException('Couchbase >= 3.0.5 < 4.0.0 is required.');
+ }
+
+ set_error_handler(static fn ($type, $msg, $file, $line) => throw new \ErrorException($msg, 0, $type, $file, $line));
+
+ $dsnPattern = '/^(?couchbase(?:s)?)\:\/\/(?:(?[^\:]+)\:(?[^\@]{6,})@)?'
+ .'(?[^\:]+(?:\:\d+)?)(?:\/(?[^\/\?]+))(?:(?:\/(?[^\/]+))'
+ .'(?:\/(?[^\/\?]+)))?(?:\/)?(?:\?(?.*))?$/i';
+
+ $newServers = [];
+ $protocol = 'couchbase';
+ try {
+ $username = $options['username'] ?? '';
+ $password = $options['password'] ?? '';
+
+ foreach ($dsn as $server) {
+ if (!str_starts_with($server, 'couchbase:')) {
+ throw new InvalidArgumentException('Invalid Couchbase DSN: it does not start with "couchbase:".');
+ }
+
+ preg_match($dsnPattern, $server, $matches);
+
+ $username = $matches['username'] ?: $username;
+ $password = $matches['password'] ?: $password;
+ $protocol = $matches['protocol'] ?: $protocol;
+
+ if (isset($matches['options'])) {
+ $optionsInDsn = self::getOptions($matches['options']);
+
+ foreach ($optionsInDsn as $parameter => $value) {
+ $options[$parameter] = $value;
+ }
+ }
+
+ $newServers[] = $matches['host'];
+ }
+
+ $option = isset($matches['options']) ? '?'.$matches['options'] : '';
+ $connectionString = $protocol.'://'.implode(',', $newServers).$option;
+
+ $clusterOptions = new ClusterOptions();
+ $clusterOptions->credentials($username, $password);
+
+ $client = new Cluster($connectionString, $clusterOptions);
+
+ $bucket = $client->bucket($matches['bucketName']);
+ $collection = $bucket->defaultCollection();
+ if (!empty($matches['scopeName'])) {
+ $scope = $bucket->scope($matches['scopeName']);
+ $collection = $scope->collection($matches['collectionName']);
+ }
+
+ return $collection;
+ } finally {
+ restore_error_handler();
+ }
+ }
+
+ public static function isSupported(): bool
+ {
+ return \extension_loaded('couchbase') && version_compare(phpversion('couchbase'), '3.0.5', '>=') && version_compare(phpversion('couchbase'), '4.0', '<');
+ }
+
+ private static function getOptions(string $options): array
+ {
+ $results = [];
+ $optionsInArray = explode('&', $options);
+
+ foreach ($optionsInArray as $option) {
+ [$key, $value] = explode('=', $option);
+
+ $results[$key] = $value;
+ }
+
+ return $results;
+ }
+
+ protected function doFetch(array $ids): array
+ {
+ $results = [];
+ foreach ($ids as $id) {
+ try {
+ $resultCouchbase = $this->connection->get($id);
+ } catch (DocumentNotFoundException) {
+ continue;
+ }
+
+ $content = $resultCouchbase->value ?? $resultCouchbase->content();
+
+ $results[$id] = $this->marshaller->unmarshall($content);
+ }
+
+ return $results;
+ }
+
+ protected function doHave($id): bool
+ {
+ return $this->connection->exists($id)->exists();
+ }
+
+ protected function doClear($namespace): bool
+ {
+ return false;
+ }
+
+ protected function doDelete(array $ids): bool
+ {
+ $idsErrors = [];
+ foreach ($ids as $id) {
+ try {
+ $result = $this->connection->remove($id);
+
+ if (null === $result->mutationToken()) {
+ $idsErrors[] = $id;
+ }
+ } catch (DocumentNotFoundException) {
+ }
+ }
+
+ return 0 === \count($idsErrors);
+ }
+
+ protected function doSave(array $values, $lifetime): array|bool
+ {
+ if (!$values = $this->marshaller->marshall($values, $failed)) {
+ return $failed;
+ }
+
+ $upsertOptions = new UpsertOptions();
+ $upsertOptions->expiry($lifetime);
+
+ $ko = [];
+ foreach ($values as $key => $value) {
+ try {
+ $this->connection->upsert($key, $value, $upsertOptions);
+ } catch (\Exception) {
+ $ko[$key] = '';
+ }
+ }
+
+ return [] === $ko ? true : $ko;
+ }
+}
diff --git a/symfony/cache/Adapter/DoctrineDbalAdapter.php b/symfony/cache/Adapter/DoctrineDbalAdapter.php
new file mode 100644
index 0000000000000000000000000000000000000000..1866083b485a2afa2ca7275007f740ae0f91f966
--- /dev/null
+++ b/symfony/cache/Adapter/DoctrineDbalAdapter.php
@@ -0,0 +1,413 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Adapter;
+
+use Doctrine\DBAL\ArrayParameterType;
+use Doctrine\DBAL\Configuration;
+use Doctrine\DBAL\Connection;
+use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
+use Doctrine\DBAL\DriverManager;
+use Doctrine\DBAL\Exception as DBALException;
+use Doctrine\DBAL\Exception\TableNotFoundException;
+use Doctrine\DBAL\ParameterType;
+use Doctrine\DBAL\Schema\DefaultSchemaManagerFactory;
+use Doctrine\DBAL\Schema\Schema;
+use Doctrine\DBAL\ServerVersionProvider;
+use Doctrine\DBAL\Tools\DsnParser;
+use Symfony\Component\Cache\Exception\InvalidArgumentException;
+use Symfony\Component\Cache\Marshaller\DefaultMarshaller;
+use Symfony\Component\Cache\Marshaller\MarshallerInterface;
+use Symfony\Component\Cache\PruneableInterface;
+
+class DoctrineDbalAdapter extends AbstractAdapter implements PruneableInterface
+{
+ private const MAX_KEY_LENGTH = 255;
+
+ private MarshallerInterface $marshaller;
+ private Connection $conn;
+ private string $platformName;
+ private string $serverVersion;
+ private string $table = 'cache_items';
+ private string $idCol = 'item_id';
+ private string $dataCol = 'item_data';
+ private string $lifetimeCol = 'item_lifetime';
+ private string $timeCol = 'item_time';
+ private string $namespace;
+
+ /**
+ * You can either pass an existing database Doctrine DBAL Connection or
+ * a DSN string that will be used to connect to the database.
+ *
+ * The cache table is created automatically when possible.
+ * Otherwise, use the createTable() method.
+ *
+ * List of available options:
+ * * db_table: The name of the table [default: cache_items]
+ * * db_id_col: The column where to store the cache id [default: item_id]
+ * * db_data_col: The column where to store the cache data [default: item_data]
+ * * db_lifetime_col: The column where to store the lifetime [default: item_lifetime]
+ * * db_time_col: The column where to store the timestamp [default: item_time]
+ *
+ * @throws InvalidArgumentException When namespace contains invalid characters
+ */
+ public function __construct(Connection|string $connOrDsn, string $namespace = '', int $defaultLifetime = 0, array $options = [], ?MarshallerInterface $marshaller = null)
+ {
+ if (isset($namespace[0]) && preg_match('#[^-+.A-Za-z0-9]#', $namespace, $match)) {
+ throw new InvalidArgumentException(\sprintf('Namespace contains "%s" but only characters in [-+.A-Za-z0-9] are allowed.', $match[0]));
+ }
+
+ if ($connOrDsn instanceof Connection) {
+ $this->conn = $connOrDsn;
+ } else {
+ if (!class_exists(DriverManager::class)) {
+ throw new InvalidArgumentException('Failed to parse DSN. Try running "composer require doctrine/dbal".');
+ }
+ if (class_exists(DsnParser::class)) {
+ $params = (new DsnParser([
+ 'db2' => 'ibm_db2',
+ 'mssql' => 'pdo_sqlsrv',
+ 'mysql' => 'pdo_mysql',
+ 'mysql2' => 'pdo_mysql',
+ 'postgres' => 'pdo_pgsql',
+ 'postgresql' => 'pdo_pgsql',
+ 'pgsql' => 'pdo_pgsql',
+ 'sqlite' => 'pdo_sqlite',
+ 'sqlite3' => 'pdo_sqlite',
+ ]))->parse($connOrDsn);
+ } else {
+ $params = ['url' => $connOrDsn];
+ }
+
+ $config = new Configuration();
+ if (class_exists(DefaultSchemaManagerFactory::class)) {
+ $config->setSchemaManagerFactory(new DefaultSchemaManagerFactory());
+ }
+
+ $this->conn = DriverManager::getConnection($params, $config);
+ }
+
+ $this->maxIdLength = self::MAX_KEY_LENGTH;
+ $this->table = $options['db_table'] ?? $this->table;
+ $this->idCol = $options['db_id_col'] ?? $this->idCol;
+ $this->dataCol = $options['db_data_col'] ?? $this->dataCol;
+ $this->lifetimeCol = $options['db_lifetime_col'] ?? $this->lifetimeCol;
+ $this->timeCol = $options['db_time_col'] ?? $this->timeCol;
+ $this->namespace = $namespace;
+ $this->marshaller = $marshaller ?? new DefaultMarshaller();
+
+ parent::__construct($namespace, $defaultLifetime);
+ }
+
+ /**
+ * Creates the table to store cache items which can be called once for setup.
+ *
+ * Cache ID are saved in a column of maximum length 255. Cache data is
+ * saved in a BLOB.
+ *
+ * @throws DBALException When the table already exists
+ */
+ public function createTable(): void
+ {
+ $schema = new Schema();
+ $this->addTableToSchema($schema);
+
+ foreach ($schema->toSql($this->conn->getDatabasePlatform()) as $sql) {
+ $this->conn->executeStatement($sql);
+ }
+ }
+
+ /**
+ * @param \Closure $isSameDatabase
+ */
+ public function configureSchema(Schema $schema, Connection $forConnection/* , \Closure $isSameDatabase */): void
+ {
+ if ($schema->hasTable($this->table)) {
+ return;
+ }
+
+ $isSameDatabase = 2 < \func_num_args() ? func_get_arg(2) : static fn () => false;
+
+ if ($forConnection !== $this->conn && !$isSameDatabase($this->conn->executeStatement(...))) {
+ return;
+ }
+
+ $this->addTableToSchema($schema);
+ }
+
+ public function prune(): bool
+ {
+ $deleteSql = "DELETE FROM $this->table WHERE $this->lifetimeCol + $this->timeCol <= ?";
+ $params = [time()];
+ $paramTypes = [ParameterType::INTEGER];
+
+ if ('' !== $this->namespace) {
+ $deleteSql .= " AND $this->idCol LIKE ?";
+ $params[] = \sprintf('%s%%', $this->namespace);
+ $paramTypes[] = ParameterType::STRING;
+ }
+
+ try {
+ $this->conn->executeStatement($deleteSql, $params, $paramTypes);
+ } catch (TableNotFoundException) {
+ }
+
+ return true;
+ }
+
+ protected function doFetch(array $ids): iterable
+ {
+ $now = time();
+ $expired = [];
+
+ $sql = "SELECT $this->idCol, CASE WHEN $this->lifetimeCol IS NULL OR $this->lifetimeCol + $this->timeCol > ? THEN $this->dataCol ELSE NULL END FROM $this->table WHERE $this->idCol IN (?)";
+ $result = $this->conn->executeQuery($sql, [
+ $now,
+ $ids,
+ ], [
+ ParameterType::INTEGER,
+ class_exists(ArrayParameterType::class) ? ArrayParameterType::STRING : Connection::PARAM_STR_ARRAY,
+ ])->iterateNumeric();
+
+ foreach ($result as $row) {
+ if (null === $row[1]) {
+ $expired[] = $row[0];
+ } else {
+ yield $row[0] => $this->marshaller->unmarshall(\is_resource($row[1]) ? stream_get_contents($row[1]) : $row[1]);
+ }
+ }
+
+ if ($expired) {
+ $sql = "DELETE FROM $this->table WHERE $this->lifetimeCol + $this->timeCol <= ? AND $this->idCol IN (?)";
+ $this->conn->executeStatement($sql, [
+ $now,
+ $expired,
+ ], [
+ ParameterType::INTEGER,
+ class_exists(ArrayParameterType::class) ? ArrayParameterType::STRING : Connection::PARAM_STR_ARRAY,
+ ]);
+ }
+ }
+
+ protected function doHave(string $id): bool
+ {
+ $sql = "SELECT 1 FROM $this->table WHERE $this->idCol = ? AND ($this->lifetimeCol IS NULL OR $this->lifetimeCol + $this->timeCol > ?)";
+ $result = $this->conn->executeQuery($sql, [
+ $id,
+ time(),
+ ], [
+ ParameterType::STRING,
+ ParameterType::INTEGER,
+ ]);
+
+ return (bool) $result->fetchOne();
+ }
+
+ protected function doClear(string $namespace): bool
+ {
+ if ('' === $namespace) {
+ $sql = $this->conn->getDatabasePlatform()->getTruncateTableSQL($this->table);
+ } else {
+ $sql = "DELETE FROM $this->table WHERE $this->idCol LIKE '$namespace%'";
+ }
+
+ try {
+ $this->conn->executeStatement($sql);
+ } catch (TableNotFoundException) {
+ }
+
+ return true;
+ }
+
+ protected function doDelete(array $ids): bool
+ {
+ $sql = "DELETE FROM $this->table WHERE $this->idCol IN (?)";
+ try {
+ $this->conn->executeStatement($sql, [array_values($ids)], [class_exists(ArrayParameterType::class) ? ArrayParameterType::STRING : Connection::PARAM_STR_ARRAY]);
+ } catch (TableNotFoundException) {
+ }
+
+ return true;
+ }
+
+ protected function doSave(array $values, int $lifetime): array|bool
+ {
+ if (!$values = $this->marshaller->marshall($values, $failed)) {
+ return $failed;
+ }
+
+ $platformName = $this->getPlatformName();
+ $insertSql = "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (?, ?, ?, ?)";
+
+ switch (true) {
+ case 'mysql' === $platformName:
+ $sql = $insertSql." ON DUPLICATE KEY UPDATE $this->dataCol = VALUES($this->dataCol), $this->lifetimeCol = VALUES($this->lifetimeCol), $this->timeCol = VALUES($this->timeCol)";
+ break;
+ case 'oci' === $platformName:
+ // DUAL is Oracle specific dummy table
+ $sql = "MERGE INTO $this->table USING DUAL ON ($this->idCol = ?) ".
+ "WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (?, ?, ?, ?) ".
+ "WHEN MATCHED THEN UPDATE SET $this->dataCol = ?, $this->lifetimeCol = ?, $this->timeCol = ?";
+ break;
+ case 'sqlsrv' === $platformName && version_compare($this->getServerVersion(), '10', '>='):
+ // MERGE is only available since SQL Server 2008 and must be terminated by semicolon
+ // It also requires HOLDLOCK according to http://weblogs.sqlteam.com/dang/archive/2009/01/31/UPSERT-Race-Condition-With-MERGE.aspx
+ $sql = "MERGE INTO $this->table WITH (HOLDLOCK) USING (SELECT 1 AS dummy) AS src ON ($this->idCol = ?) ".
+ "WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (?, ?, ?, ?) ".
+ "WHEN MATCHED THEN UPDATE SET $this->dataCol = ?, $this->lifetimeCol = ?, $this->timeCol = ?;";
+ break;
+ case 'sqlite' === $platformName:
+ $sql = 'INSERT OR REPLACE'.substr($insertSql, 6);
+ break;
+ case 'pgsql' === $platformName && version_compare($this->getServerVersion(), '9.5', '>='):
+ $sql = $insertSql." ON CONFLICT ($this->idCol) DO UPDATE SET ($this->dataCol, $this->lifetimeCol, $this->timeCol) = (EXCLUDED.$this->dataCol, EXCLUDED.$this->lifetimeCol, EXCLUDED.$this->timeCol)";
+ break;
+ default:
+ $platformName = null;
+ $sql = "UPDATE $this->table SET $this->dataCol = ?, $this->lifetimeCol = ?, $this->timeCol = ? WHERE $this->idCol = ?";
+ break;
+ }
+
+ $now = time();
+ $lifetime = $lifetime ?: null;
+ try {
+ $stmt = $this->conn->prepare($sql);
+ } catch (TableNotFoundException) {
+ if (!$this->conn->isTransactionActive() || \in_array($platformName, ['pgsql', 'sqlite', 'sqlsrv'], true)) {
+ $this->createTable();
+ }
+ $stmt = $this->conn->prepare($sql);
+ }
+
+ if ('sqlsrv' === $platformName || 'oci' === $platformName) {
+ $bind = static function ($id, $data) use ($stmt) {
+ $stmt->bindValue(1, $id);
+ $stmt->bindValue(2, $id);
+ $stmt->bindValue(3, $data, ParameterType::LARGE_OBJECT);
+ $stmt->bindValue(6, $data, ParameterType::LARGE_OBJECT);
+ };
+ $stmt->bindValue(4, $lifetime, ParameterType::INTEGER);
+ $stmt->bindValue(5, $now, ParameterType::INTEGER);
+ $stmt->bindValue(7, $lifetime, ParameterType::INTEGER);
+ $stmt->bindValue(8, $now, ParameterType::INTEGER);
+ } elseif (null !== $platformName) {
+ $bind = static function ($id, $data) use ($stmt) {
+ $stmt->bindValue(1, $id);
+ $stmt->bindValue(2, $data, ParameterType::LARGE_OBJECT);
+ };
+ $stmt->bindValue(3, $lifetime, ParameterType::INTEGER);
+ $stmt->bindValue(4, $now, ParameterType::INTEGER);
+ } else {
+ $stmt->bindValue(2, $lifetime, ParameterType::INTEGER);
+ $stmt->bindValue(3, $now, ParameterType::INTEGER);
+
+ $insertStmt = $this->conn->prepare($insertSql);
+ $insertStmt->bindValue(3, $lifetime, ParameterType::INTEGER);
+ $insertStmt->bindValue(4, $now, ParameterType::INTEGER);
+
+ $bind = static function ($id, $data) use ($stmt, $insertStmt) {
+ $stmt->bindValue(1, $data, ParameterType::LARGE_OBJECT);
+ $stmt->bindValue(4, $id);
+ $insertStmt->bindValue(1, $id);
+ $insertStmt->bindValue(2, $data, ParameterType::LARGE_OBJECT);
+ };
+ }
+
+ foreach ($values as $id => $data) {
+ $bind($id, $data);
+ try {
+ $rowCount = $stmt->executeStatement();
+ } catch (TableNotFoundException) {
+ if (!$this->conn->isTransactionActive() || \in_array($platformName, ['pgsql', 'sqlite', 'sqlsrv'], true)) {
+ $this->createTable();
+ }
+ $rowCount = $stmt->executeStatement();
+ }
+ if (null === $platformName && 0 === $rowCount) {
+ try {
+ $insertStmt->executeStatement();
+ } catch (DBALException) {
+ // A concurrent write won, let it be
+ }
+ }
+ }
+
+ return $failed;
+ }
+
+ /**
+ * @internal
+ */
+ protected function getId(mixed $key): string
+ {
+ if ('pgsql' !== $this->platformName ??= $this->getPlatformName()) {
+ return parent::getId($key);
+ }
+
+ if (str_contains($key, "\0") || str_contains($key, '%') || !preg_match('//u', $key)) {
+ $key = rawurlencode($key);
+ }
+
+ return parent::getId($key);
+ }
+
+ private function getPlatformName(): string
+ {
+ if (isset($this->platformName)) {
+ return $this->platformName;
+ }
+
+ $platform = $this->conn->getDatabasePlatform();
+
+ return $this->platformName = match (true) {
+ $platform instanceof \Doctrine\DBAL\Platforms\MySQLPlatform,
+ $platform instanceof \Doctrine\DBAL\Platforms\MySQL57Platform => 'mysql',
+ $platform instanceof \Doctrine\DBAL\Platforms\SqlitePlatform => 'sqlite',
+ $platform instanceof \Doctrine\DBAL\Platforms\PostgreSQLPlatform,
+ $platform instanceof \Doctrine\DBAL\Platforms\PostgreSQL94Platform => 'pgsql',
+ $platform instanceof \Doctrine\DBAL\Platforms\OraclePlatform => 'oci',
+ $platform instanceof \Doctrine\DBAL\Platforms\SQLServerPlatform,
+ $platform instanceof \Doctrine\DBAL\Platforms\SQLServer2012Platform => 'sqlsrv',
+ default => $platform::class,
+ };
+ }
+
+ private function getServerVersion(): string
+ {
+ if (isset($this->serverVersion)) {
+ return $this->serverVersion;
+ }
+
+ if ($this->conn instanceof ServerVersionProvider || $this->conn instanceof ServerInfoAwareConnection) {
+ return $this->serverVersion = $this->conn->getServerVersion();
+ }
+
+ // The condition should be removed once support for DBAL <3.3 is dropped
+ $conn = method_exists($this->conn, 'getNativeConnection') ? $this->conn->getNativeConnection() : $this->conn->getWrappedConnection();
+
+ return $this->serverVersion = $conn->getAttribute(\PDO::ATTR_SERVER_VERSION);
+ }
+
+ private function addTableToSchema(Schema $schema): void
+ {
+ $types = [
+ 'mysql' => 'binary',
+ 'sqlite' => 'text',
+ ];
+
+ $table = $schema->createTable($this->table);
+ $table->addColumn($this->idCol, $types[$this->getPlatformName()] ?? 'string', ['length' => 255]);
+ $table->addColumn($this->dataCol, 'blob', ['length' => 16777215]);
+ $table->addColumn($this->lifetimeCol, 'integer', ['unsigned' => true, 'notnull' => false]);
+ $table->addColumn($this->timeCol, 'integer', ['unsigned' => true]);
+ $table->setPrimaryKey([$this->idCol]);
+ }
+}
diff --git a/symfony/cache/Adapter/FilesystemAdapter.php b/symfony/cache/Adapter/FilesystemAdapter.php
new file mode 100644
index 0000000000000000000000000000000000000000..13daa568c7cdd0225eb8993757ffbf57078d9253
--- /dev/null
+++ b/symfony/cache/Adapter/FilesystemAdapter.php
@@ -0,0 +1,29 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Adapter;
+
+use Symfony\Component\Cache\Marshaller\DefaultMarshaller;
+use Symfony\Component\Cache\Marshaller\MarshallerInterface;
+use Symfony\Component\Cache\PruneableInterface;
+use Symfony\Component\Cache\Traits\FilesystemTrait;
+
+class FilesystemAdapter extends AbstractAdapter implements PruneableInterface
+{
+ use FilesystemTrait;
+
+ public function __construct(string $namespace = '', int $defaultLifetime = 0, ?string $directory = null, ?MarshallerInterface $marshaller = null)
+ {
+ $this->marshaller = $marshaller ?? new DefaultMarshaller();
+ parent::__construct('', $defaultLifetime);
+ $this->init($namespace, $directory);
+ }
+}
diff --git a/symfony/cache/Adapter/FilesystemTagAwareAdapter.php b/symfony/cache/Adapter/FilesystemTagAwareAdapter.php
new file mode 100644
index 0000000000000000000000000000000000000000..80edee433dba0299e867ee99a4556e519e1edc26
--- /dev/null
+++ b/symfony/cache/Adapter/FilesystemTagAwareAdapter.php
@@ -0,0 +1,267 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Adapter;
+
+use Symfony\Component\Cache\Marshaller\MarshallerInterface;
+use Symfony\Component\Cache\Marshaller\TagAwareMarshaller;
+use Symfony\Component\Cache\PruneableInterface;
+use Symfony\Component\Cache\Traits\FilesystemTrait;
+
+/**
+ * Stores tag id <> cache id relationship as a symlink, and lookup on invalidation calls.
+ *
+ * @author Nicolas Grekas
+ * @author André Rømcke
+ */
+class FilesystemTagAwareAdapter extends AbstractTagAwareAdapter implements PruneableInterface
+{
+ use FilesystemTrait {
+ prune as private doPrune;
+ doClear as private doClearCache;
+ doSave as private doSaveCache;
+ }
+
+ /**
+ * Folder used for tag symlinks.
+ */
+ private const TAG_FOLDER = 'tags';
+
+ public function __construct(string $namespace = '', int $defaultLifetime = 0, ?string $directory = null, ?MarshallerInterface $marshaller = null)
+ {
+ $this->marshaller = new TagAwareMarshaller($marshaller);
+ parent::__construct('', $defaultLifetime);
+ $this->init($namespace, $directory);
+ }
+
+ public function prune(): bool
+ {
+ $ok = $this->doPrune();
+
+ set_error_handler(static function () {});
+ $chars = '+-ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
+
+ try {
+ foreach ($this->scanHashDir($this->directory.self::TAG_FOLDER.\DIRECTORY_SEPARATOR) as $dir) {
+ $dir .= \DIRECTORY_SEPARATOR;
+ $keepDir = false;
+ for ($i = 0; $i < 38; ++$i) {
+ if (!is_dir($dir.$chars[$i])) {
+ continue;
+ }
+ for ($j = 0; $j < 38; ++$j) {
+ if (!is_dir($d = $dir.$chars[$i].\DIRECTORY_SEPARATOR.$chars[$j])) {
+ continue;
+ }
+ foreach (scandir($d, \SCANDIR_SORT_NONE) ?: [] as $link) {
+ if ('.' === $link || '..' === $link) {
+ continue;
+ }
+ if ('_' !== $dir[-2] && realpath($d.\DIRECTORY_SEPARATOR.$link)) {
+ $keepDir = true;
+ } else {
+ unlink($d.\DIRECTORY_SEPARATOR.$link);
+ }
+ }
+ $keepDir ?: rmdir($d);
+ }
+ $keepDir ?: rmdir($dir.$chars[$i]);
+ }
+ $keepDir ?: rmdir($dir);
+ }
+ } finally {
+ restore_error_handler();
+ }
+
+ return $ok;
+ }
+
+ protected function doClear(string $namespace): bool
+ {
+ $ok = $this->doClearCache($namespace);
+
+ if ('' !== $namespace) {
+ return $ok;
+ }
+
+ set_error_handler(static function () {});
+ $chars = '+-ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
+
+ $this->tmpSuffix ??= str_replace('/', '-', base64_encode(random_bytes(6)));
+
+ try {
+ foreach ($this->scanHashDir($this->directory.self::TAG_FOLDER.\DIRECTORY_SEPARATOR) as $dir) {
+ if (rename($dir, $renamed = substr_replace($dir, $this->tmpSuffix.'_', -9))) {
+ $dir = $renamed.\DIRECTORY_SEPARATOR;
+ } else {
+ $dir .= \DIRECTORY_SEPARATOR;
+ $renamed = null;
+ }
+
+ for ($i = 0; $i < 38; ++$i) {
+ if (!is_dir($dir.$chars[$i])) {
+ continue;
+ }
+ for ($j = 0; $j < 38; ++$j) {
+ if (!is_dir($d = $dir.$chars[$i].\DIRECTORY_SEPARATOR.$chars[$j])) {
+ continue;
+ }
+ foreach (scandir($d, \SCANDIR_SORT_NONE) ?: [] as $link) {
+ if ('.' !== $link && '..' !== $link && (null !== $renamed || !realpath($d.\DIRECTORY_SEPARATOR.$link))) {
+ unlink($d.\DIRECTORY_SEPARATOR.$link);
+ }
+ }
+ null === $renamed ?: rmdir($d);
+ }
+ null === $renamed ?: rmdir($dir.$chars[$i]);
+ }
+ null === $renamed ?: rmdir($renamed);
+ }
+ } finally {
+ restore_error_handler();
+ }
+
+ return $ok;
+ }
+
+ protected function doSave(array $values, int $lifetime, array $addTagData = [], array $removeTagData = []): array
+ {
+ $failed = $this->doSaveCache($values, $lifetime);
+
+ // Add Tags as symlinks
+ foreach ($addTagData as $tagId => $ids) {
+ $tagFolder = $this->getTagFolder($tagId);
+ foreach ($ids as $id) {
+ if ($failed && \in_array($id, $failed, true)) {
+ continue;
+ }
+
+ $file = $this->getFile($id);
+
+ if (!@symlink($file, $tagLink = $this->getFile($id, true, $tagFolder)) && !is_link($tagLink)) {
+ @unlink($file);
+ $failed[] = $id;
+ }
+ }
+ }
+
+ // Unlink removed Tags
+ foreach ($removeTagData as $tagId => $ids) {
+ $tagFolder = $this->getTagFolder($tagId);
+ foreach ($ids as $id) {
+ if ($failed && \in_array($id, $failed, true)) {
+ continue;
+ }
+
+ @unlink($this->getFile($id, false, $tagFolder));
+ }
+ }
+
+ return $failed;
+ }
+
+ protected function doDeleteYieldTags(array $ids): iterable
+ {
+ foreach ($ids as $id) {
+ $file = $this->getFile($id);
+ if (!is_file($file) || !$h = @fopen($file, 'r')) {
+ continue;
+ }
+
+ if (!@unlink($file)) {
+ fclose($h);
+ continue;
+ }
+
+ $meta = explode("\n", fread($h, 4096), 3)[2] ?? '';
+
+ // detect the compact format used in marshall() using magic numbers in the form 9D-..-..-..-..-00-..-..-..-5F
+ if (13 < \strlen($meta) && "\x9D" === $meta[0] && "\0" === $meta[5] && "\x5F" === $meta[9]) {
+ $meta[9] = "\0";
+ $tagLen = unpack('Nlen', $meta, 9)['len'];
+ $meta = substr($meta, 13, $tagLen);
+
+ if (0 < $tagLen -= \strlen($meta)) {
+ $meta .= fread($h, $tagLen);
+ }
+
+ try {
+ yield $id => '' === $meta ? [] : $this->marshaller->unmarshall($meta);
+ } catch (\Exception) {
+ yield $id => [];
+ }
+ }
+
+ fclose($h);
+ }
+ }
+
+ protected function doDeleteTagRelations(array $tagData): bool
+ {
+ foreach ($tagData as $tagId => $idList) {
+ $tagFolder = $this->getTagFolder($tagId);
+ foreach ($idList as $id) {
+ @unlink($this->getFile($id, false, $tagFolder));
+ }
+ }
+
+ return true;
+ }
+
+ protected function doInvalidate(array $tagIds): bool
+ {
+ foreach ($tagIds as $tagId) {
+ if (!is_dir($tagFolder = $this->getTagFolder($tagId))) {
+ continue;
+ }
+
+ $this->tmpSuffix ??= str_replace('/', '-', base64_encode(random_bytes(6)));
+
+ set_error_handler(static function () {});
+
+ try {
+ if (rename($tagFolder, $renamed = substr_replace($tagFolder, $this->tmpSuffix.'_', -10))) {
+ $tagFolder = $renamed.\DIRECTORY_SEPARATOR;
+ } else {
+ $renamed = null;
+ }
+
+ foreach ($this->scanHashDir($tagFolder) as $itemLink) {
+ unlink(realpath($itemLink) ?: $itemLink);
+ unlink($itemLink);
+ }
+
+ if (null === $renamed) {
+ continue;
+ }
+
+ $chars = '+-ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
+
+ for ($i = 0; $i < 38; ++$i) {
+ for ($j = 0; $j < 38; ++$j) {
+ rmdir($tagFolder.$chars[$i].\DIRECTORY_SEPARATOR.$chars[$j]);
+ }
+ rmdir($tagFolder.$chars[$i]);
+ }
+ rmdir($renamed);
+ } finally {
+ restore_error_handler();
+ }
+ }
+
+ return true;
+ }
+
+ private function getTagFolder(string $tagId): string
+ {
+ return $this->getFile($tagId, false, $this->directory.self::TAG_FOLDER.\DIRECTORY_SEPARATOR).\DIRECTORY_SEPARATOR;
+ }
+}
diff --git a/symfony/cache/Adapter/MemcachedAdapter.php b/symfony/cache/Adapter/MemcachedAdapter.php
new file mode 100644
index 0000000000000000000000000000000000000000..9f983f0ad713527936c82ba8697cabda26e06c0b
--- /dev/null
+++ b/symfony/cache/Adapter/MemcachedAdapter.php
@@ -0,0 +1,332 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Adapter;
+
+use Symfony\Component\Cache\Exception\CacheException;
+use Symfony\Component\Cache\Exception\InvalidArgumentException;
+use Symfony\Component\Cache\Marshaller\DefaultMarshaller;
+use Symfony\Component\Cache\Marshaller\MarshallerInterface;
+
+/**
+ * @author Rob Frawley 2nd
+ * @author Nicolas Grekas
+ */
+class MemcachedAdapter extends AbstractAdapter
+{
+ /**
+ * We are replacing characters that are illegal in Memcached keys with reserved characters from
+ * {@see \Symfony\Contracts\Cache\ItemInterface::RESERVED_CHARACTERS} that are legal in Memcached.
+ * Note: don’t use {@see AbstractAdapter::NS_SEPARATOR}.
+ */
+ private const RESERVED_MEMCACHED = " \n\r\t\v\f\0";
+ private const RESERVED_PSR6 = '@()\{}/';
+ private const MAX_KEY_LENGTH = 250;
+
+ private MarshallerInterface $marshaller;
+ private \Memcached $client;
+ private \Memcached $lazyClient;
+
+ /**
+ * Using a MemcachedAdapter with a TagAwareAdapter for storing tags is discouraged.
+ * Using a RedisAdapter is recommended instead. If you cannot do otherwise, be aware that:
+ * - the Memcached::OPT_BINARY_PROTOCOL must be enabled
+ * (that's the default when using MemcachedAdapter::createConnection());
+ * - tags eviction by Memcached's LRU algorithm will break by-tags invalidation;
+ * your Memcached memory should be large enough to never trigger LRU.
+ *
+ * Using a MemcachedAdapter as a pure items store is fine.
+ */
+ public function __construct(\Memcached $client, string $namespace = '', int $defaultLifetime = 0, ?MarshallerInterface $marshaller = null)
+ {
+ if (!static::isSupported()) {
+ throw new CacheException('Memcached > 3.1.5 is required.');
+ }
+ $this->maxIdLength = self::MAX_KEY_LENGTH;
+
+ if ('Memcached' === $client::class) {
+ $opt = $client->getOption(\Memcached::OPT_SERIALIZER);
+ if (\Memcached::SERIALIZER_PHP !== $opt && \Memcached::SERIALIZER_IGBINARY !== $opt) {
+ throw new CacheException('MemcachedAdapter: "serializer" option must be "php" or "igbinary".');
+ }
+ $this->maxIdLength -= \strlen($client->getOption(\Memcached::OPT_PREFIX_KEY));
+ $this->client = $client;
+ } else {
+ $this->lazyClient = $client;
+ }
+
+ parent::__construct($namespace, $defaultLifetime);
+ $this->enableVersioning();
+ $this->marshaller = $marshaller ?? new DefaultMarshaller();
+ }
+
+ /**
+ * @return bool
+ */
+ public static function isSupported()
+ {
+ return \extension_loaded('memcached') && version_compare(phpversion('memcached'), '3.1.6', '>=');
+ }
+
+ /**
+ * Creates a Memcached instance.
+ *
+ * By default, the binary protocol, no block, and libketama compatible options are enabled.
+ *
+ * Examples for servers:
+ * - 'memcached://user:pass@localhost?weight=33'
+ * - [['localhost', 11211, 33]]
+ *
+ * @param array[]|string|string[] $servers An array of servers, a DSN, or an array of DSNs
+ *
+ * @throws \ErrorException When invalid options or servers are provided
+ */
+ public static function createConnection(#[\SensitiveParameter] array|string $servers, array $options = []): \Memcached
+ {
+ if (\is_string($servers)) {
+ $servers = [$servers];
+ }
+ if (!static::isSupported()) {
+ throw new CacheException('Memcached > 3.1.5 is required.');
+ }
+ set_error_handler(static fn ($type, $msg, $file, $line) => throw new \ErrorException($msg, 0, $type, $file, $line));
+ try {
+ $client = new \Memcached($options['persistent_id'] ?? null);
+ $username = $options['username'] ?? null;
+ $password = $options['password'] ?? null;
+
+ // parse any DSN in $servers
+ foreach ($servers as $i => $dsn) {
+ if (\is_array($dsn)) {
+ continue;
+ }
+ if (!str_starts_with($dsn, 'memcached:')) {
+ throw new InvalidArgumentException('Invalid Memcached DSN: it does not start with "memcached:".');
+ }
+ $params = preg_replace_callback('#^memcached:(//)?(?:([^@]*+)@)?#', function ($m) use (&$username, &$password) {
+ if (!empty($m[2])) {
+ [$username, $password] = explode(':', $m[2], 2) + [1 => null];
+ $username = rawurldecode($username);
+ $password = null !== $password ? rawurldecode($password) : null;
+ }
+
+ return 'file:'.($m[1] ?? '');
+ }, $dsn);
+ if (false === $params = parse_url($params)) {
+ throw new InvalidArgumentException('Invalid Memcached DSN.');
+ }
+ $query = $hosts = [];
+ if (isset($params['query'])) {
+ parse_str($params['query'], $query);
+
+ if (isset($query['host'])) {
+ if (!\is_array($hosts = $query['host'])) {
+ throw new InvalidArgumentException('Invalid Memcached DSN: query parameter "host" must be an array.');
+ }
+ foreach ($hosts as $host => $weight) {
+ if (false === $port = strrpos($host, ':')) {
+ $hosts[$host] = [$host, 11211, (int) $weight];
+ } else {
+ $hosts[$host] = [substr($host, 0, $port), (int) substr($host, 1 + $port), (int) $weight];
+ }
+ }
+ $hosts = array_values($hosts);
+ unset($query['host']);
+ }
+ if ($hosts && !isset($params['host']) && !isset($params['path'])) {
+ unset($servers[$i]);
+ $servers = array_merge($servers, $hosts);
+ continue;
+ }
+ }
+ if (!isset($params['host']) && !isset($params['path'])) {
+ throw new InvalidArgumentException('Invalid Memcached DSN: missing host or path.');
+ }
+ if (isset($params['path']) && preg_match('#/(\d+)$#', $params['path'], $m)) {
+ $params['weight'] = $m[1];
+ $params['path'] = substr($params['path'], 0, -\strlen($m[0]));
+ }
+ $params += [
+ 'host' => $params['host'] ?? $params['path'],
+ 'port' => isset($params['host']) ? 11211 : null,
+ 'weight' => 0,
+ ];
+ if ($query) {
+ $params += $query;
+ $options = $query + $options;
+ }
+
+ $servers[$i] = [$params['host'], $params['port'], $params['weight']];
+
+ if ($hosts) {
+ $servers = array_merge($servers, $hosts);
+ }
+ }
+
+ // set client's options
+ unset($options['persistent_id'], $options['username'], $options['password'], $options['weight'], $options['lazy']);
+ $options = array_change_key_case($options, \CASE_UPPER);
+ $client->setOption(\Memcached::OPT_BINARY_PROTOCOL, true);
+ $client->setOption(\Memcached::OPT_NO_BLOCK, true);
+ $client->setOption(\Memcached::OPT_TCP_NODELAY, true);
+ if (!\array_key_exists('LIBKETAMA_COMPATIBLE', $options) && !\array_key_exists(\Memcached::OPT_LIBKETAMA_COMPATIBLE, $options)) {
+ $client->setOption(\Memcached::OPT_LIBKETAMA_COMPATIBLE, true);
+ }
+ foreach ($options as $name => $value) {
+ if (\is_int($name)) {
+ continue;
+ }
+ if ('HASH' === $name || 'SERIALIZER' === $name || 'DISTRIBUTION' === $name) {
+ $value = \constant('Memcached::'.$name.'_'.strtoupper($value));
+ }
+ unset($options[$name]);
+
+ if (\defined('Memcached::OPT_'.$name)) {
+ $options[\constant('Memcached::OPT_'.$name)] = $value;
+ }
+ }
+ $client->setOptions($options + [\Memcached::OPT_SERIALIZER => \Memcached::SERIALIZER_PHP]);
+
+ // set client's servers, taking care of persistent connections
+ if (!$client->isPristine()) {
+ $oldServers = [];
+ foreach ($client->getServerList() as $server) {
+ $oldServers[] = [$server['host'], $server['port']];
+ }
+
+ $newServers = [];
+ foreach ($servers as $server) {
+ if (1 < \count($server)) {
+ $server = array_values($server);
+ unset($server[2]);
+ $server[1] = (int) $server[1];
+ }
+ $newServers[] = $server;
+ }
+
+ if ($oldServers !== $newServers) {
+ $client->resetServerList();
+ $client->addServers($servers);
+ }
+ } else {
+ $client->addServers($servers);
+ }
+
+ if (null !== $username || null !== $password) {
+ if (!method_exists($client, 'setSaslAuthData')) {
+ trigger_error('Missing SASL support: the memcached extension must be compiled with --enable-memcached-sasl.');
+ }
+ $client->setSaslAuthData($username, $password);
+ }
+
+ return $client;
+ } finally {
+ restore_error_handler();
+ }
+ }
+
+ protected function doSave(array $values, int $lifetime): array|bool
+ {
+ if (!$values = $this->marshaller->marshall($values, $failed)) {
+ return $failed;
+ }
+
+ if ($lifetime && $lifetime > 30 * 86400) {
+ $lifetime += time();
+ }
+
+ $encodedValues = [];
+ foreach ($values as $key => $value) {
+ $encodedValues[self::encodeKey($key)] = $value;
+ }
+
+ return $this->checkResultCode($this->getClient()->setMulti($encodedValues, $lifetime)) ? $failed : false;
+ }
+
+ protected function doFetch(array $ids): iterable
+ {
+ try {
+ $encodedIds = array_map([__CLASS__, 'encodeKey'], $ids);
+
+ $encodedResult = $this->checkResultCode($this->getClient()->getMulti($encodedIds));
+
+ $result = [];
+ foreach ($encodedResult as $key => $value) {
+ $result[self::decodeKey($key)] = $this->marshaller->unmarshall($value);
+ }
+
+ return $result;
+ } catch (\Error $e) {
+ throw new \ErrorException($e->getMessage(), $e->getCode(), \E_ERROR, $e->getFile(), $e->getLine());
+ }
+ }
+
+ protected function doHave(string $id): bool
+ {
+ return false !== $this->getClient()->get(self::encodeKey($id)) || $this->checkResultCode(\Memcached::RES_SUCCESS === $this->client->getResultCode());
+ }
+
+ protected function doDelete(array $ids): bool
+ {
+ $ok = true;
+ $encodedIds = array_map([__CLASS__, 'encodeKey'], $ids);
+ foreach ($this->checkResultCode($this->getClient()->deleteMulti($encodedIds)) as $result) {
+ if (\Memcached::RES_SUCCESS !== $result && \Memcached::RES_NOTFOUND !== $result) {
+ $ok = false;
+ }
+ }
+
+ return $ok;
+ }
+
+ protected function doClear(string $namespace): bool
+ {
+ return '' === $namespace && $this->getClient()->flush();
+ }
+
+ private function checkResultCode(mixed $result): mixed
+ {
+ $code = $this->client->getResultCode();
+
+ if (\Memcached::RES_SUCCESS === $code || \Memcached::RES_NOTFOUND === $code) {
+ return $result;
+ }
+
+ throw new CacheException('MemcachedAdapter client error: '.strtolower($this->client->getResultMessage()));
+ }
+
+ private function getClient(): \Memcached
+ {
+ if (isset($this->client)) {
+ return $this->client;
+ }
+
+ $opt = $this->lazyClient->getOption(\Memcached::OPT_SERIALIZER);
+ if (\Memcached::SERIALIZER_PHP !== $opt && \Memcached::SERIALIZER_IGBINARY !== $opt) {
+ throw new CacheException('MemcachedAdapter: "serializer" option must be "php" or "igbinary".');
+ }
+ if ('' !== $prefix = (string) $this->lazyClient->getOption(\Memcached::OPT_PREFIX_KEY)) {
+ throw new CacheException(\sprintf('MemcachedAdapter: "prefix_key" option must be empty when using proxified connections, "%s" given.', $prefix));
+ }
+
+ return $this->client = $this->lazyClient;
+ }
+
+ private static function encodeKey(string $key): string
+ {
+ return strtr($key, self::RESERVED_MEMCACHED, self::RESERVED_PSR6);
+ }
+
+ private static function decodeKey(string $key): string
+ {
+ return strtr($key, self::RESERVED_PSR6, self::RESERVED_MEMCACHED);
+ }
+}
diff --git a/symfony/cache/Adapter/NullAdapter.php b/symfony/cache/Adapter/NullAdapter.php
new file mode 100644
index 0000000000000000000000000000000000000000..d5d2ef6b40d03b03dc0b05950c532554e67ca8a2
--- /dev/null
+++ b/symfony/cache/Adapter/NullAdapter.php
@@ -0,0 +1,105 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Adapter;
+
+use Psr\Cache\CacheItemInterface;
+use Symfony\Component\Cache\CacheItem;
+use Symfony\Contracts\Cache\CacheInterface;
+
+/**
+ * @author Titouan Galopin
+ */
+class NullAdapter implements AdapterInterface, CacheInterface
+{
+ private static \Closure $createCacheItem;
+
+ public function __construct()
+ {
+ self::$createCacheItem ??= \Closure::bind(
+ static function ($key) {
+ $item = new CacheItem();
+ $item->key = $key;
+ $item->isHit = false;
+
+ return $item;
+ },
+ null,
+ CacheItem::class
+ );
+ }
+
+ public function get(string $key, callable $callback, ?float $beta = null, ?array &$metadata = null): mixed
+ {
+ $save = true;
+
+ return $callback((self::$createCacheItem)($key), $save);
+ }
+
+ public function getItem(mixed $key): CacheItem
+ {
+ return (self::$createCacheItem)($key);
+ }
+
+ public function getItems(array $keys = []): iterable
+ {
+ return $this->generateItems($keys);
+ }
+
+ public function hasItem(mixed $key): bool
+ {
+ return false;
+ }
+
+ public function clear(string $prefix = ''): bool
+ {
+ return true;
+ }
+
+ public function deleteItem(mixed $key): bool
+ {
+ return true;
+ }
+
+ public function deleteItems(array $keys): bool
+ {
+ return true;
+ }
+
+ public function save(CacheItemInterface $item): bool
+ {
+ return true;
+ }
+
+ public function saveDeferred(CacheItemInterface $item): bool
+ {
+ return true;
+ }
+
+ public function commit(): bool
+ {
+ return true;
+ }
+
+ public function delete(string $key): bool
+ {
+ return $this->deleteItem($key);
+ }
+
+ private function generateItems(array $keys): \Generator
+ {
+ $f = self::$createCacheItem;
+
+ foreach ($keys as $key) {
+ yield $key => $f($key);
+ }
+ }
+}
diff --git a/symfony/cache/Adapter/ParameterNormalizer.php b/symfony/cache/Adapter/ParameterNormalizer.php
new file mode 100644
index 0000000000000000000000000000000000000000..483df1c0bc2fc409ab9e9ce0e47af8b10891cb34
--- /dev/null
+++ b/symfony/cache/Adapter/ParameterNormalizer.php
@@ -0,0 +1,35 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Adapter;
+
+/**
+ * @author Lars Strojny
+ */
+final class ParameterNormalizer
+{
+ public static function normalizeDuration(string $duration): int
+ {
+ if (is_numeric($duration)) {
+ return $duration;
+ }
+
+ if (false !== $time = strtotime($duration, 0)) {
+ return $time;
+ }
+
+ try {
+ return \DateTimeImmutable::createFromFormat('U', 0)->add(new \DateInterval($duration))->getTimestamp();
+ } catch (\Exception $e) {
+ throw new \InvalidArgumentException(\sprintf('Cannot parse date interval "%s".', $duration), 0, $e);
+ }
+ }
+}
diff --git a/symfony/cache/Adapter/PdoAdapter.php b/symfony/cache/Adapter/PdoAdapter.php
new file mode 100644
index 0000000000000000000000000000000000000000..f5865993d2312eb6cda075c3b567d309312f158b
--- /dev/null
+++ b/symfony/cache/Adapter/PdoAdapter.php
@@ -0,0 +1,398 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Adapter;
+
+use Symfony\Component\Cache\Exception\InvalidArgumentException;
+use Symfony\Component\Cache\Marshaller\DefaultMarshaller;
+use Symfony\Component\Cache\Marshaller\MarshallerInterface;
+use Symfony\Component\Cache\PruneableInterface;
+
+class PdoAdapter extends AbstractAdapter implements PruneableInterface
+{
+ private const MAX_KEY_LENGTH = 255;
+
+ private MarshallerInterface $marshaller;
+ private \PDO $conn;
+ private string $dsn;
+ private string $driver;
+ private string $serverVersion;
+ private string $table = 'cache_items';
+ private string $idCol = 'item_id';
+ private string $dataCol = 'item_data';
+ private string $lifetimeCol = 'item_lifetime';
+ private string $timeCol = 'item_time';
+ private ?string $username = null;
+ private ?string $password = null;
+ private array $connectionOptions = [];
+ private string $namespace;
+
+ /**
+ * You can either pass an existing database connection as PDO instance or
+ * a DSN string that will be used to lazy-connect to the database when the
+ * cache is actually used.
+ *
+ * List of available options:
+ * * db_table: The name of the table [default: cache_items]
+ * * db_id_col: The column where to store the cache id [default: item_id]
+ * * db_data_col: The column where to store the cache data [default: item_data]
+ * * db_lifetime_col: The column where to store the lifetime [default: item_lifetime]
+ * * db_time_col: The column where to store the timestamp [default: item_time]
+ * * db_username: The username when lazy-connect [default: '']
+ * * db_password: The password when lazy-connect [default: '']
+ * * db_connection_options: An array of driver-specific connection options [default: []]
+ *
+ * @throws InvalidArgumentException When first argument is not PDO nor Connection nor string
+ * @throws InvalidArgumentException When PDO error mode is not PDO::ERRMODE_EXCEPTION
+ * @throws InvalidArgumentException When namespace contains invalid characters
+ */
+ public function __construct(#[\SensitiveParameter] \PDO|string $connOrDsn, string $namespace = '', int $defaultLifetime = 0, array $options = [], ?MarshallerInterface $marshaller = null)
+ {
+ if (\is_string($connOrDsn) && str_contains($connOrDsn, '://')) {
+ throw new InvalidArgumentException(\sprintf('Usage of Doctrine DBAL URL with "%s" is not supported. Use a PDO DSN or "%s" instead.', __CLASS__, DoctrineDbalAdapter::class));
+ }
+
+ if (isset($namespace[0]) && preg_match('#[^-+.A-Za-z0-9]#', $namespace, $match)) {
+ throw new InvalidArgumentException(\sprintf('Namespace contains "%s" but only characters in [-+.A-Za-z0-9] are allowed.', $match[0]));
+ }
+
+ if ($connOrDsn instanceof \PDO) {
+ if (\PDO::ERRMODE_EXCEPTION !== $connOrDsn->getAttribute(\PDO::ATTR_ERRMODE)) {
+ throw new InvalidArgumentException(\sprintf('"%s" requires PDO error mode attribute be set to throw Exceptions (i.e. $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION)).', __CLASS__));
+ }
+
+ $this->conn = $connOrDsn;
+ } else {
+ $this->dsn = $connOrDsn;
+ }
+
+ $this->maxIdLength = self::MAX_KEY_LENGTH;
+ $this->table = $options['db_table'] ?? $this->table;
+ $this->idCol = $options['db_id_col'] ?? $this->idCol;
+ $this->dataCol = $options['db_data_col'] ?? $this->dataCol;
+ $this->lifetimeCol = $options['db_lifetime_col'] ?? $this->lifetimeCol;
+ $this->timeCol = $options['db_time_col'] ?? $this->timeCol;
+ $this->username = $options['db_username'] ?? $this->username;
+ $this->password = $options['db_password'] ?? $this->password;
+ $this->connectionOptions = $options['db_connection_options'] ?? $this->connectionOptions;
+ $this->namespace = $namespace;
+ $this->marshaller = $marshaller ?? new DefaultMarshaller();
+
+ parent::__construct($namespace, $defaultLifetime);
+ }
+
+ /**
+ * Creates the table to store cache items which can be called once for setup.
+ *
+ * Cache ID are saved in a column of maximum length 255. Cache data is
+ * saved in a BLOB.
+ *
+ * @return void
+ *
+ * @throws \PDOException When the table already exists
+ * @throws \DomainException When an unsupported PDO driver is used
+ */
+ public function createTable()
+ {
+ $sql = match ($driver = $this->getDriver()) {
+ // We use varbinary for the ID column because it prevents unwanted conversions:
+ // - character set conversions between server and client
+ // - trailing space removal
+ // - case-insensitivity
+ // - language processing like é == e
+ 'mysql' => "CREATE TABLE $this->table ($this->idCol VARBINARY(255) NOT NULL PRIMARY KEY, $this->dataCol MEDIUMBLOB NOT NULL, $this->lifetimeCol INTEGER UNSIGNED, $this->timeCol INTEGER UNSIGNED NOT NULL), ENGINE = InnoDB",
+ 'sqlite' => "CREATE TABLE $this->table ($this->idCol TEXT NOT NULL PRIMARY KEY, $this->dataCol BLOB NOT NULL, $this->lifetimeCol INTEGER, $this->timeCol INTEGER NOT NULL)",
+ 'pgsql' => "CREATE TABLE $this->table ($this->idCol VARCHAR(255) NOT NULL PRIMARY KEY, $this->dataCol BYTEA NOT NULL, $this->lifetimeCol INTEGER, $this->timeCol INTEGER NOT NULL)",
+ 'oci' => "CREATE TABLE $this->table ($this->idCol VARCHAR2(255) NOT NULL PRIMARY KEY, $this->dataCol BLOB NOT NULL, $this->lifetimeCol INTEGER, $this->timeCol INTEGER NOT NULL)",
+ 'sqlsrv' => "CREATE TABLE $this->table ($this->idCol VARCHAR(255) NOT NULL PRIMARY KEY, $this->dataCol VARBINARY(MAX) NOT NULL, $this->lifetimeCol INTEGER, $this->timeCol INTEGER NOT NULL)",
+ default => throw new \DomainException(\sprintf('Creating the cache table is currently not implemented for PDO driver "%s".', $driver)),
+ };
+
+ $this->getConnection()->exec($sql);
+ }
+
+ public function prune(): bool
+ {
+ $deleteSql = "DELETE FROM $this->table WHERE $this->lifetimeCol + $this->timeCol <= :time";
+
+ if ('' !== $this->namespace) {
+ $deleteSql .= " AND $this->idCol LIKE :namespace";
+ }
+
+ $connection = $this->getConnection();
+
+ try {
+ $delete = $connection->prepare($deleteSql);
+ } catch (\PDOException) {
+ return true;
+ }
+ $delete->bindValue(':time', time(), \PDO::PARAM_INT);
+
+ if ('' !== $this->namespace) {
+ $delete->bindValue(':namespace', \sprintf('%s%%', $this->namespace), \PDO::PARAM_STR);
+ }
+ try {
+ return $delete->execute();
+ } catch (\PDOException) {
+ return true;
+ }
+ }
+
+ protected function doFetch(array $ids): iterable
+ {
+ $connection = $this->getConnection();
+
+ $now = time();
+ $expired = [];
+
+ $sql = str_pad('', (\count($ids) << 1) - 1, '?,');
+ $sql = "SELECT $this->idCol, CASE WHEN $this->lifetimeCol IS NULL OR $this->lifetimeCol + $this->timeCol > ? THEN $this->dataCol ELSE NULL END FROM $this->table WHERE $this->idCol IN ($sql)";
+ $stmt = $connection->prepare($sql);
+ $stmt->bindValue($i = 1, $now, \PDO::PARAM_INT);
+ foreach ($ids as $id) {
+ $stmt->bindValue(++$i, $id);
+ }
+ $result = $stmt->execute();
+
+ if (\is_object($result)) {
+ $result = $result->iterateNumeric();
+ } else {
+ $stmt->setFetchMode(\PDO::FETCH_NUM);
+ $result = $stmt;
+ }
+
+ foreach ($result as $row) {
+ if (null === $row[1]) {
+ $expired[] = $row[0];
+ } else {
+ yield $row[0] => $this->marshaller->unmarshall(\is_resource($row[1]) ? stream_get_contents($row[1]) : $row[1]);
+ }
+ }
+
+ if ($expired) {
+ $sql = str_pad('', (\count($expired) << 1) - 1, '?,');
+ $sql = "DELETE FROM $this->table WHERE $this->lifetimeCol + $this->timeCol <= ? AND $this->idCol IN ($sql)";
+ $stmt = $connection->prepare($sql);
+ $stmt->bindValue($i = 1, $now, \PDO::PARAM_INT);
+ foreach ($expired as $id) {
+ $stmt->bindValue(++$i, $id);
+ }
+ $stmt->execute();
+ }
+ }
+
+ protected function doHave(string $id): bool
+ {
+ $connection = $this->getConnection();
+
+ $sql = "SELECT 1 FROM $this->table WHERE $this->idCol = :id AND ($this->lifetimeCol IS NULL OR $this->lifetimeCol + $this->timeCol > :time)";
+ $stmt = $connection->prepare($sql);
+
+ $stmt->bindValue(':id', $id);
+ $stmt->bindValue(':time', time(), \PDO::PARAM_INT);
+ $stmt->execute();
+
+ return (bool) $stmt->fetchColumn();
+ }
+
+ protected function doClear(string $namespace): bool
+ {
+ $conn = $this->getConnection();
+
+ if ('' === $namespace) {
+ if ('sqlite' === $this->getDriver()) {
+ $sql = "DELETE FROM $this->table";
+ } else {
+ $sql = "TRUNCATE TABLE $this->table";
+ }
+ } else {
+ $sql = "DELETE FROM $this->table WHERE $this->idCol LIKE '$namespace%'";
+ }
+
+ try {
+ $conn->exec($sql);
+ } catch (\PDOException) {
+ }
+
+ return true;
+ }
+
+ protected function doDelete(array $ids): bool
+ {
+ $sql = str_pad('', (\count($ids) << 1) - 1, '?,');
+ $sql = "DELETE FROM $this->table WHERE $this->idCol IN ($sql)";
+ try {
+ $stmt = $this->getConnection()->prepare($sql);
+ $stmt->execute(array_values($ids));
+ } catch (\PDOException) {
+ }
+
+ return true;
+ }
+
+ protected function doSave(array $values, int $lifetime): array|bool
+ {
+ if (!$values = $this->marshaller->marshall($values, $failed)) {
+ return $failed;
+ }
+
+ $conn = $this->getConnection();
+
+ $driver = $this->getDriver();
+ $insertSql = "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (:id, :data, :lifetime, :time)";
+
+ switch (true) {
+ case 'mysql' === $driver:
+ $sql = $insertSql." ON DUPLICATE KEY UPDATE $this->dataCol = VALUES($this->dataCol), $this->lifetimeCol = VALUES($this->lifetimeCol), $this->timeCol = VALUES($this->timeCol)";
+ break;
+ case 'oci' === $driver:
+ // DUAL is Oracle specific dummy table
+ $sql = "MERGE INTO $this->table USING DUAL ON ($this->idCol = ?) ".
+ "WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (?, ?, ?, ?) ".
+ "WHEN MATCHED THEN UPDATE SET $this->dataCol = ?, $this->lifetimeCol = ?, $this->timeCol = ?";
+ break;
+ case 'sqlsrv' === $driver && version_compare($this->getServerVersion(), '10', '>='):
+ // MERGE is only available since SQL Server 2008 and must be terminated by semicolon
+ // It also requires HOLDLOCK according to http://weblogs.sqlteam.com/dang/archive/2009/01/31/UPSERT-Race-Condition-With-MERGE.aspx
+ $sql = "MERGE INTO $this->table WITH (HOLDLOCK) USING (SELECT 1 AS dummy) AS src ON ($this->idCol = ?) ".
+ "WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (?, ?, ?, ?) ".
+ "WHEN MATCHED THEN UPDATE SET $this->dataCol = ?, $this->lifetimeCol = ?, $this->timeCol = ?;";
+ break;
+ case 'sqlite' === $driver:
+ $sql = 'INSERT OR REPLACE'.substr($insertSql, 6);
+ break;
+ case 'pgsql' === $driver && version_compare($this->getServerVersion(), '9.5', '>='):
+ $sql = $insertSql." ON CONFLICT ($this->idCol) DO UPDATE SET ($this->dataCol, $this->lifetimeCol, $this->timeCol) = (EXCLUDED.$this->dataCol, EXCLUDED.$this->lifetimeCol, EXCLUDED.$this->timeCol)";
+ break;
+ default:
+ $driver = null;
+ $sql = "UPDATE $this->table SET $this->dataCol = :data, $this->lifetimeCol = :lifetime, $this->timeCol = :time WHERE $this->idCol = :id";
+ break;
+ }
+
+ $now = time();
+ $lifetime = $lifetime ?: null;
+ try {
+ $stmt = $conn->prepare($sql);
+ } catch (\PDOException $e) {
+ if ($this->isTableMissing($e) && (!$conn->inTransaction() || \in_array($driver, ['pgsql', 'sqlite', 'sqlsrv'], true))) {
+ $this->createTable();
+ }
+ $stmt = $conn->prepare($sql);
+ }
+
+ // $id and $data are defined later in the loop. Binding is done by reference, values are read on execution.
+ if ('sqlsrv' === $driver || 'oci' === $driver) {
+ $stmt->bindParam(1, $id);
+ $stmt->bindParam(2, $id);
+ $stmt->bindParam(3, $data, \PDO::PARAM_LOB);
+ $stmt->bindValue(4, $lifetime, \PDO::PARAM_INT);
+ $stmt->bindValue(5, $now, \PDO::PARAM_INT);
+ $stmt->bindParam(6, $data, \PDO::PARAM_LOB);
+ $stmt->bindValue(7, $lifetime, \PDO::PARAM_INT);
+ $stmt->bindValue(8, $now, \PDO::PARAM_INT);
+ } else {
+ $stmt->bindParam(':id', $id);
+ $stmt->bindParam(':data', $data, \PDO::PARAM_LOB);
+ $stmt->bindValue(':lifetime', $lifetime, \PDO::PARAM_INT);
+ $stmt->bindValue(':time', $now, \PDO::PARAM_INT);
+ }
+ if (null === $driver) {
+ $insertStmt = $conn->prepare($insertSql);
+
+ $insertStmt->bindParam(':id', $id);
+ $insertStmt->bindParam(':data', $data, \PDO::PARAM_LOB);
+ $insertStmt->bindValue(':lifetime', $lifetime, \PDO::PARAM_INT);
+ $insertStmt->bindValue(':time', $now, \PDO::PARAM_INT);
+ }
+
+ if ('sqlsrv' === $driver) {
+ $dataStream = fopen('php://memory', 'r+');
+ }
+ foreach ($values as $id => $data) {
+ if ('sqlsrv' === $driver) {
+ rewind($dataStream);
+ fwrite($dataStream, $data);
+ ftruncate($dataStream, \strlen($data));
+ rewind($dataStream);
+ $data = $dataStream;
+ }
+ try {
+ $stmt->execute();
+ } catch (\PDOException $e) {
+ if ($this->isTableMissing($e) && (!$conn->inTransaction() || \in_array($driver, ['pgsql', 'sqlite', 'sqlsrv'], true))) {
+ $this->createTable();
+ }
+ $stmt->execute();
+ }
+ if (null === $driver && !$stmt->rowCount()) {
+ try {
+ $insertStmt->execute();
+ } catch (\PDOException) {
+ // A concurrent write won, let it be
+ }
+ }
+ }
+
+ return $failed;
+ }
+
+ /**
+ * @internal
+ */
+ protected function getId(mixed $key): string
+ {
+ if ('pgsql' !== $this->getDriver()) {
+ return parent::getId($key);
+ }
+
+ if (str_contains($key, "\0") || str_contains($key, '%') || !preg_match('//u', $key)) {
+ $key = rawurlencode($key);
+ }
+
+ return parent::getId($key);
+ }
+
+ private function getConnection(): \PDO
+ {
+ if (!isset($this->conn)) {
+ $this->conn = new \PDO($this->dsn, $this->username, $this->password, $this->connectionOptions);
+ $this->conn->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
+ }
+
+ return $this->conn;
+ }
+
+ private function getDriver(): string
+ {
+ return $this->driver ??= $this->getConnection()->getAttribute(\PDO::ATTR_DRIVER_NAME);
+ }
+
+ private function getServerVersion(): string
+ {
+ return $this->serverVersion ??= $this->getConnection()->getAttribute(\PDO::ATTR_SERVER_VERSION);
+ }
+
+ private function isTableMissing(\PDOException $exception): bool
+ {
+ $driver = $this->getDriver();
+ [$sqlState, $code] = $exception->errorInfo ?? [null, $exception->getCode()];
+
+ return match ($driver) {
+ 'pgsql' => '42P01' === $sqlState,
+ 'sqlite' => str_contains($exception->getMessage(), 'no such table:'),
+ 'oci' => 942 === $code,
+ 'sqlsrv' => 208 === $code,
+ 'mysql' => 1146 === $code,
+ default => false,
+ };
+ }
+}
diff --git a/symfony/cache/Adapter/PhpArrayAdapter.php b/symfony/cache/Adapter/PhpArrayAdapter.php
new file mode 100644
index 0000000000000000000000000000000000000000..6c3d70724582f38fcd490b442150e946280ce55c
--- /dev/null
+++ b/symfony/cache/Adapter/PhpArrayAdapter.php
@@ -0,0 +1,388 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Adapter;
+
+use Psr\Cache\CacheItemInterface;
+use Psr\Cache\CacheItemPoolInterface;
+use Symfony\Component\Cache\CacheItem;
+use Symfony\Component\Cache\Exception\InvalidArgumentException;
+use Symfony\Component\Cache\PruneableInterface;
+use Symfony\Component\Cache\ResettableInterface;
+use Symfony\Component\Cache\Traits\CachedValueInterface;
+use Symfony\Component\Cache\Traits\ContractsTrait;
+use Symfony\Component\Cache\Traits\ProxyTrait;
+use Symfony\Component\VarExporter\VarExporter;
+use Symfony\Contracts\Cache\CacheInterface;
+
+/**
+ * Caches items at warm up time using a PHP array that is stored in shared memory by OPCache since PHP 7.0.
+ * Warmed up items are read-only and run-time discovered items are cached using a fallback adapter.
+ *
+ * @author Titouan Galopin
+ * @author Nicolas Grekas
+ */
+class PhpArrayAdapter implements AdapterInterface, CacheInterface, PruneableInterface, ResettableInterface
+{
+ use ContractsTrait;
+ use ProxyTrait;
+
+ private string $file;
+ private array $keys;
+ private array $values;
+
+ private static \Closure $createCacheItem;
+ private static array $valuesCache = [];
+
+ /**
+ * @param string $file The PHP file were values are cached
+ * @param AdapterInterface $fallbackPool A pool to fallback on when an item is not hit
+ */
+ public function __construct(string $file, AdapterInterface $fallbackPool)
+ {
+ $this->file = $file;
+ $this->pool = $fallbackPool;
+ self::$createCacheItem ??= \Closure::bind(
+ static function ($key, $value, $isHit) {
+ $item = new CacheItem();
+ $item->key = $key;
+ $item->value = $value;
+ $item->isHit = $isHit;
+
+ return $item;
+ },
+ null,
+ CacheItem::class
+ );
+ }
+
+ /**
+ * This adapter takes advantage of how PHP stores arrays in its latest versions.
+ *
+ * @param string $file The PHP file were values are cached
+ * @param CacheItemPoolInterface $fallbackPool A pool to fallback on when an item is not hit
+ */
+ public static function create(string $file, CacheItemPoolInterface $fallbackPool): CacheItemPoolInterface
+ {
+ if (!$fallbackPool instanceof AdapterInterface) {
+ $fallbackPool = new ProxyAdapter($fallbackPool);
+ }
+
+ return new static($file, $fallbackPool);
+ }
+
+ public function get(string $key, callable $callback, ?float $beta = null, ?array &$metadata = null): mixed
+ {
+ if (!isset($this->values)) {
+ $this->initialize();
+ }
+ if (!isset($this->keys[$key])) {
+ get_from_pool:
+ if ($this->pool instanceof CacheInterface) {
+ return $this->pool->get($key, $callback, $beta, $metadata);
+ }
+
+ return $this->doGet($this->pool, $key, $callback, $beta, $metadata);
+ }
+ $value = $this->values[$this->keys[$key]];
+
+ if ('N;' === $value) {
+ return null;
+ }
+ if (!$value instanceof CachedValueInterface) {
+ return $value;
+ }
+ try {
+ return $value->getValue();
+ } catch (\Throwable) {
+ unset($this->keys[$key]);
+ goto get_from_pool;
+ }
+ }
+
+ public function getItem(mixed $key): CacheItem
+ {
+ if (!\is_string($key)) {
+ throw new InvalidArgumentException(\sprintf('Cache key must be string, "%s" given.', get_debug_type($key)));
+ }
+ if (!isset($this->values)) {
+ $this->initialize();
+ }
+ if (!isset($this->keys[$key])) {
+ return $this->pool->getItem($key);
+ }
+
+ $value = $this->values[$this->keys[$key]];
+ $isHit = true;
+
+ if ('N;' === $value) {
+ $value = null;
+ } elseif ($value instanceof CachedValueInterface) {
+ try {
+ $value = $value->getValue();
+ } catch (\Throwable) {
+ $value = null;
+ $isHit = false;
+ }
+ }
+
+ return (self::$createCacheItem)($key, $value, $isHit);
+ }
+
+ public function getItems(array $keys = []): iterable
+ {
+ foreach ($keys as $key) {
+ if (!\is_string($key)) {
+ throw new InvalidArgumentException(\sprintf('Cache key must be string, "%s" given.', get_debug_type($key)));
+ }
+ }
+ if (!isset($this->values)) {
+ $this->initialize();
+ }
+
+ return $this->generateItems($keys);
+ }
+
+ public function hasItem(mixed $key): bool
+ {
+ if (!\is_string($key)) {
+ throw new InvalidArgumentException(\sprintf('Cache key must be string, "%s" given.', get_debug_type($key)));
+ }
+ if (!isset($this->values)) {
+ $this->initialize();
+ }
+
+ return isset($this->keys[$key]) || $this->pool->hasItem($key);
+ }
+
+ public function deleteItem(mixed $key): bool
+ {
+ if (!\is_string($key)) {
+ throw new InvalidArgumentException(\sprintf('Cache key must be string, "%s" given.', get_debug_type($key)));
+ }
+ if (!isset($this->values)) {
+ $this->initialize();
+ }
+
+ return !isset($this->keys[$key]) && $this->pool->deleteItem($key);
+ }
+
+ public function deleteItems(array $keys): bool
+ {
+ $deleted = true;
+ $fallbackKeys = [];
+
+ foreach ($keys as $key) {
+ if (!\is_string($key)) {
+ throw new InvalidArgumentException(\sprintf('Cache key must be string, "%s" given.', get_debug_type($key)));
+ }
+
+ if (isset($this->keys[$key])) {
+ $deleted = false;
+ } else {
+ $fallbackKeys[] = $key;
+ }
+ }
+ if (!isset($this->values)) {
+ $this->initialize();
+ }
+
+ if ($fallbackKeys) {
+ $deleted = $this->pool->deleteItems($fallbackKeys) && $deleted;
+ }
+
+ return $deleted;
+ }
+
+ public function save(CacheItemInterface $item): bool
+ {
+ if (!isset($this->values)) {
+ $this->initialize();
+ }
+
+ return !isset($this->keys[$item->getKey()]) && $this->pool->save($item);
+ }
+
+ public function saveDeferred(CacheItemInterface $item): bool
+ {
+ if (!isset($this->values)) {
+ $this->initialize();
+ }
+
+ return !isset($this->keys[$item->getKey()]) && $this->pool->saveDeferred($item);
+ }
+
+ public function commit(): bool
+ {
+ return $this->pool->commit();
+ }
+
+ public function clear(string $prefix = ''): bool
+ {
+ $this->keys = $this->values = [];
+
+ $cleared = @unlink($this->file) || !file_exists($this->file);
+ unset(self::$valuesCache[$this->file]);
+
+ if ($this->pool instanceof AdapterInterface) {
+ return $this->pool->clear($prefix) && $cleared;
+ }
+
+ return $this->pool->clear() && $cleared;
+ }
+
+ /**
+ * Store an array of cached values.
+ *
+ * @param array $values The cached values
+ *
+ * @return string[] A list of classes to preload on PHP 7.4+
+ */
+ public function warmUp(array $values): array
+ {
+ if (file_exists($this->file)) {
+ if (!is_file($this->file)) {
+ throw new InvalidArgumentException(\sprintf('Cache path exists and is not a file: "%s".', $this->file));
+ }
+
+ if (!is_writable($this->file)) {
+ throw new InvalidArgumentException(\sprintf('Cache file is not writable: "%s".', $this->file));
+ }
+ } else {
+ $directory = \dirname($this->file);
+
+ if (!is_dir($directory) && !@mkdir($directory, 0777, true)) {
+ throw new InvalidArgumentException(\sprintf('Cache directory does not exist and cannot be created: "%s".', $directory));
+ }
+
+ if (!is_writable($directory)) {
+ throw new InvalidArgumentException(\sprintf('Cache directory is not writable: "%s".', $directory));
+ }
+ }
+
+ $preload = [];
+ $dumpedValues = '';
+ $dumpedMap = [];
+ $dump = <<<'EOF'
+ $value) {
+ CacheItem::validateKey(\is_int($key) ? (string) $key : $key);
+ $isStaticValue = true;
+
+ if (null === $value) {
+ $value = "'N;'";
+ } elseif (\is_object($value) || \is_array($value)) {
+ try {
+ $value = VarExporter::export($value, $isStaticValue, $preload);
+ } catch (\Exception $e) {
+ throw new InvalidArgumentException(\sprintf('Cache key "%s" has non-serializable "%s" value.', $key, get_debug_type($value)), 0, $e);
+ }
+ } elseif (\is_string($value)) {
+ // Wrap "N;" in a closure to not confuse it with an encoded `null`
+ if ('N;' === $value) {
+ $isStaticValue = false;
+ }
+ $value = var_export($value, true);
+ } elseif (!\is_scalar($value)) {
+ throw new InvalidArgumentException(\sprintf('Cache key "%s" has non-serializable "%s" value.', $key, get_debug_type($value)));
+ } else {
+ $value = var_export($value, true);
+ }
+
+ if (!$isStaticValue) {
+ $value = 'new class() implements \\'.CachedValueInterface::class." { public function getValue(): mixed { return {$value}; } }";
+ }
+ $hash = hash('xxh128', $value);
+
+ if (null === $id = $dumpedMap[$hash] ?? null) {
+ $id = $dumpedMap[$hash] = \count($dumpedMap);
+ $dumpedValues .= "{$id} => {$value},\n";
+ }
+
+ $dump .= var_export($key, true)." => {$id},\n";
+ }
+
+ $dump .= "\n], [\n\n{$dumpedValues}\n]];\n";
+
+ $tmpFile = uniqid($this->file, true);
+
+ file_put_contents($tmpFile, $dump);
+ @chmod($tmpFile, 0666 & ~umask());
+ unset($serialized, $value, $dump);
+
+ @rename($tmpFile, $this->file);
+ unset(self::$valuesCache[$this->file]);
+
+ $this->initialize();
+
+ return $preload;
+ }
+
+ /**
+ * Load the cache file.
+ */
+ private function initialize(): void
+ {
+ if (isset(self::$valuesCache[$this->file])) {
+ $values = self::$valuesCache[$this->file];
+ } elseif (!is_file($this->file)) {
+ $this->keys = $this->values = [];
+
+ return;
+ } else {
+ $values = self::$valuesCache[$this->file] = (include $this->file) ?: [[], []];
+ }
+
+ if (2 !== \count($values) || !isset($values[0], $values[1])) {
+ $this->keys = $this->values = [];
+ } else {
+ [$this->keys, $this->values] = $values;
+ }
+ }
+
+ private function generateItems(array $keys): \Generator
+ {
+ $f = self::$createCacheItem;
+ $fallbackKeys = [];
+
+ foreach ($keys as $key) {
+ if (isset($this->keys[$key])) {
+ $value = $this->values[$this->keys[$key]];
+
+ if ('N;' === $value) {
+ yield $key => $f($key, null, true);
+ } elseif ($value instanceof CachedValueInterface) {
+ try {
+ yield $key => $f($key, $value->getValue(), true);
+ } catch (\Throwable) {
+ yield $key => $f($key, null, false);
+ }
+ } else {
+ yield $key => $f($key, $value, true);
+ }
+ } else {
+ $fallbackKeys[] = $key;
+ }
+ }
+
+ if ($fallbackKeys) {
+ yield from $this->pool->getItems($fallbackKeys);
+ }
+ }
+}
diff --git a/symfony/cache/Adapter/PhpFilesAdapter.php b/symfony/cache/Adapter/PhpFilesAdapter.php
new file mode 100644
index 0000000000000000000000000000000000000000..70d08944513afecf6713ab5cbab8cde8b9939402
--- /dev/null
+++ b/symfony/cache/Adapter/PhpFilesAdapter.php
@@ -0,0 +1,321 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Adapter;
+
+use Symfony\Component\Cache\Exception\CacheException;
+use Symfony\Component\Cache\Exception\InvalidArgumentException;
+use Symfony\Component\Cache\PruneableInterface;
+use Symfony\Component\Cache\Traits\CachedValueInterface;
+use Symfony\Component\Cache\Traits\FilesystemCommonTrait;
+use Symfony\Component\VarExporter\VarExporter;
+
+/**
+ * @author Piotr Stankowski
+ * @author Nicolas Grekas
+ * @author Rob Frawley 2nd
+ */
+class PhpFilesAdapter extends AbstractAdapter implements PruneableInterface
+{
+ use FilesystemCommonTrait {
+ doClear as private doCommonClear;
+ doDelete as private doCommonDelete;
+ }
+
+ private \Closure $includeHandler;
+ private bool $appendOnly;
+ private array $values = [];
+ private array $files = [];
+
+ private static int $startTime;
+ private static array $valuesCache = [];
+
+ /**
+ * @param $appendOnly Set to `true` to gain extra performance when the items stored in this pool never expire.
+ * Doing so is encouraged because it fits perfectly OPcache's memory model.
+ *
+ * @throws CacheException if OPcache is not enabled
+ */
+ public function __construct(string $namespace = '', int $defaultLifetime = 0, ?string $directory = null, bool $appendOnly = false)
+ {
+ $this->appendOnly = $appendOnly;
+ self::$startTime ??= $_SERVER['REQUEST_TIME'] ?? time();
+ parent::__construct('', $defaultLifetime);
+ $this->init($namespace, $directory);
+ $this->includeHandler = static function ($type, $msg, $file, $line) {
+ throw new \ErrorException($msg, 0, $type, $file, $line);
+ };
+ }
+
+ /**
+ * @return bool
+ */
+ public static function isSupported()
+ {
+ self::$startTime ??= $_SERVER['REQUEST_TIME'] ?? time();
+
+ return \function_exists('opcache_invalidate') && filter_var(\ini_get('opcache.enable'), \FILTER_VALIDATE_BOOL) && (!\in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true) || filter_var(\ini_get('opcache.enable_cli'), \FILTER_VALIDATE_BOOL));
+ }
+
+ public function prune(): bool
+ {
+ $time = time();
+ $pruned = true;
+ $getExpiry = true;
+
+ set_error_handler($this->includeHandler);
+ try {
+ foreach ($this->scanHashDir($this->directory) as $file) {
+ try {
+ if (\is_array($expiresAt = include $file)) {
+ $expiresAt = $expiresAt[0];
+ }
+ } catch (\ErrorException $e) {
+ $expiresAt = $time;
+ }
+
+ if ($time >= $expiresAt) {
+ $pruned = ($this->doUnlink($file) || !file_exists($file)) && $pruned;
+ }
+ }
+ } finally {
+ restore_error_handler();
+ }
+
+ return $pruned;
+ }
+
+ protected function doFetch(array $ids): iterable
+ {
+ if ($this->appendOnly) {
+ $now = 0;
+ $missingIds = [];
+ } else {
+ $now = time();
+ $missingIds = $ids;
+ $ids = [];
+ }
+ $values = [];
+
+ begin:
+ $getExpiry = false;
+
+ foreach ($ids as $id) {
+ if (null === $value = $this->values[$id] ?? null) {
+ $missingIds[] = $id;
+ } elseif ('N;' === $value) {
+ $values[$id] = null;
+ } elseif (!\is_object($value)) {
+ $values[$id] = $value;
+ } elseif ($value instanceof CachedValueInterface) {
+ $values[$id] = $value->getValue();
+ } elseif (!$value instanceof LazyValue) {
+ $values[$id] = $value;
+ } elseif (false === $values[$id] = include $value->file) {
+ unset($values[$id], $this->values[$id]);
+ $missingIds[] = $id;
+ }
+ if (!$this->appendOnly) {
+ unset($this->values[$id]);
+ }
+ }
+
+ if (!$missingIds) {
+ return $values;
+ }
+
+ set_error_handler($this->includeHandler);
+ try {
+ $getExpiry = true;
+
+ foreach ($missingIds as $k => $id) {
+ try {
+ $file = $this->files[$id] ??= $this->getFile($id);
+
+ if (isset(self::$valuesCache[$file])) {
+ [$expiresAt, $this->values[$id]] = self::$valuesCache[$file];
+ } elseif (\is_array($expiresAt = include $file)) {
+ if ($this->appendOnly) {
+ self::$valuesCache[$file] = $expiresAt;
+ }
+
+ [$expiresAt, $this->values[$id]] = $expiresAt;
+ } elseif ($now < $expiresAt) {
+ $this->values[$id] = new LazyValue($file);
+ }
+
+ if ($now >= $expiresAt) {
+ unset($this->values[$id], $missingIds[$k], self::$valuesCache[$file]);
+ }
+ } catch (\ErrorException) {
+ unset($missingIds[$k]);
+ }
+ }
+ } finally {
+ restore_error_handler();
+ }
+
+ $ids = $missingIds;
+ $missingIds = [];
+ goto begin;
+ }
+
+ protected function doHave(string $id): bool
+ {
+ if ($this->appendOnly && isset($this->values[$id])) {
+ return true;
+ }
+
+ set_error_handler($this->includeHandler);
+ try {
+ $file = $this->files[$id] ??= $this->getFile($id);
+ $getExpiry = true;
+
+ if (isset(self::$valuesCache[$file])) {
+ [$expiresAt, $value] = self::$valuesCache[$file];
+ } elseif (\is_array($expiresAt = include $file)) {
+ if ($this->appendOnly) {
+ self::$valuesCache[$file] = $expiresAt;
+ }
+
+ [$expiresAt, $value] = $expiresAt;
+ } elseif ($this->appendOnly) {
+ $value = new LazyValue($file);
+ }
+ } catch (\ErrorException) {
+ return false;
+ } finally {
+ restore_error_handler();
+ }
+ if ($this->appendOnly) {
+ $now = 0;
+ $this->values[$id] = $value;
+ } else {
+ $now = time();
+ }
+
+ return $now < $expiresAt;
+ }
+
+ protected function doSave(array $values, int $lifetime): array|bool
+ {
+ $ok = true;
+ $expiry = $lifetime ? time() + $lifetime : 'PHP_INT_MAX';
+ $allowCompile = self::isSupported();
+
+ foreach ($values as $key => $value) {
+ unset($this->values[$key]);
+ $isStaticValue = true;
+ if (null === $value) {
+ $value = "'N;'";
+ } elseif (\is_object($value) || \is_array($value)) {
+ try {
+ $value = VarExporter::export($value, $isStaticValue);
+ } catch (\Exception $e) {
+ throw new InvalidArgumentException(\sprintf('Cache key "%s" has non-serializable "%s" value.', $key, get_debug_type($value)), 0, $e);
+ }
+ } elseif (\is_string($value)) {
+ // Wrap "N;" in a closure to not confuse it with an encoded `null`
+ if ('N;' === $value) {
+ $isStaticValue = false;
+ }
+ $value = var_export($value, true);
+ } elseif (!\is_scalar($value)) {
+ throw new InvalidArgumentException(\sprintf('Cache key "%s" has non-serializable "%s" value.', $key, get_debug_type($value)));
+ } else {
+ $value = var_export($value, true);
+ }
+
+ $encodedKey = rawurlencode($key);
+
+ if ($isStaticValue) {
+ $value = "return [{$expiry}, {$value}];";
+ } elseif ($this->appendOnly) {
+ $value = "return [{$expiry}, new class() implements \\".CachedValueInterface::class." { public function getValue(): mixed { return {$value}; } }];";
+ } else {
+ // We cannot use a closure here because of https://bugs.php.net/76982
+ $value = str_replace('\Symfony\Component\VarExporter\Internal\\', '', $value);
+ $value = "namespace Symfony\Component\VarExporter\Internal;\n\nreturn \$getExpiry ? {$expiry} : {$value};";
+ }
+
+ $file = $this->files[$key] = $this->getFile($key, true);
+ // Since OPcache only compiles files older than the script execution start, set the file's mtime in the past
+ $ok = $this->write($file, "directory)) {
+ throw new CacheException(\sprintf('Cache directory is not writable (%s).', $this->directory));
+ }
+
+ return $ok;
+ }
+
+ protected function doClear(string $namespace): bool
+ {
+ $this->values = [];
+
+ return $this->doCommonClear($namespace);
+ }
+
+ protected function doDelete(array $ids): bool
+ {
+ foreach ($ids as $id) {
+ unset($this->values[$id]);
+ }
+
+ return $this->doCommonDelete($ids);
+ }
+
+ /**
+ * @return bool
+ */
+ protected function doUnlink(string $file)
+ {
+ unset(self::$valuesCache[$file]);
+
+ if (self::isSupported()) {
+ @opcache_invalidate($file, true);
+ }
+
+ return @unlink($file);
+ }
+
+ private function getFileKey(string $file): string
+ {
+ if (!$h = @fopen($file, 'r')) {
+ return '';
+ }
+
+ $encodedKey = substr(fgets($h), 8);
+ fclose($h);
+
+ return rawurldecode(rtrim($encodedKey));
+ }
+}
+
+/**
+ * @internal
+ */
+class LazyValue
+{
+ public string $file;
+
+ public function __construct(string $file)
+ {
+ $this->file = $file;
+ }
+}
diff --git a/symfony/cache/Adapter/ProxyAdapter.php b/symfony/cache/Adapter/ProxyAdapter.php
new file mode 100644
index 0000000000000000000000000000000000000000..5621226069bb1f95810d50e62b29ffa6009db142
--- /dev/null
+++ b/symfony/cache/Adapter/ProxyAdapter.php
@@ -0,0 +1,206 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Adapter;
+
+use Psr\Cache\CacheItemInterface;
+use Psr\Cache\CacheItemPoolInterface;
+use Symfony\Component\Cache\CacheItem;
+use Symfony\Component\Cache\PruneableInterface;
+use Symfony\Component\Cache\ResettableInterface;
+use Symfony\Component\Cache\Traits\ContractsTrait;
+use Symfony\Component\Cache\Traits\ProxyTrait;
+use Symfony\Contracts\Cache\CacheInterface;
+
+/**
+ * @author Nicolas Grekas
+ */
+class ProxyAdapter implements AdapterInterface, CacheInterface, PruneableInterface, ResettableInterface
+{
+ use ContractsTrait;
+ use ProxyTrait;
+
+ private string $namespace = '';
+ private int $namespaceLen;
+ private string $poolHash;
+ private int $defaultLifetime;
+
+ private static \Closure $createCacheItem;
+ private static \Closure $setInnerItem;
+
+ public function __construct(CacheItemPoolInterface $pool, string $namespace = '', int $defaultLifetime = 0)
+ {
+ $this->pool = $pool;
+ $this->poolHash = spl_object_hash($pool);
+ if ('' !== $namespace) {
+ \assert('' !== CacheItem::validateKey($namespace));
+ $this->namespace = $namespace;
+ }
+ $this->namespaceLen = \strlen($namespace);
+ $this->defaultLifetime = $defaultLifetime;
+ self::$createCacheItem ??= \Closure::bind(
+ static function ($key, $innerItem, $poolHash) {
+ $item = new CacheItem();
+ $item->key = $key;
+
+ if (null === $innerItem) {
+ return $item;
+ }
+
+ $item->value = $innerItem->get();
+ $item->isHit = $innerItem->isHit();
+ $item->innerItem = $innerItem;
+ $item->poolHash = $poolHash;
+
+ if (!$item->unpack() && $innerItem instanceof CacheItem) {
+ $item->metadata = $innerItem->metadata;
+ }
+ $innerItem->set(null);
+
+ return $item;
+ },
+ null,
+ CacheItem::class
+ );
+ self::$setInnerItem ??= \Closure::bind(
+ static function (CacheItemInterface $innerItem, CacheItem $item, $expiry = null) {
+ $innerItem->set($item->pack());
+ $innerItem->expiresAt(($expiry ?? $item->expiry) ? \DateTimeImmutable::createFromFormat('U.u', \sprintf('%.6F', $expiry ?? $item->expiry)) : null);
+ },
+ null,
+ CacheItem::class
+ );
+ }
+
+ public function get(string $key, callable $callback, ?float $beta = null, ?array &$metadata = null): mixed
+ {
+ if (!$this->pool instanceof CacheInterface) {
+ return $this->doGet($this, $key, $callback, $beta, $metadata);
+ }
+
+ return $this->pool->get($this->getId($key), function ($innerItem, bool &$save) use ($key, $callback) {
+ $item = (self::$createCacheItem)($key, $innerItem, $this->poolHash);
+ $item->set($value = $callback($item, $save));
+ (self::$setInnerItem)($innerItem, $item);
+
+ return $value;
+ }, $beta, $metadata);
+ }
+
+ public function getItem(mixed $key): CacheItem
+ {
+ $item = $this->pool->getItem($this->getId($key));
+
+ return (self::$createCacheItem)($key, $item, $this->poolHash);
+ }
+
+ public function getItems(array $keys = []): iterable
+ {
+ if ($this->namespaceLen) {
+ foreach ($keys as $i => $key) {
+ $keys[$i] = $this->getId($key);
+ }
+ }
+
+ return $this->generateItems($this->pool->getItems($keys));
+ }
+
+ public function hasItem(mixed $key): bool
+ {
+ return $this->pool->hasItem($this->getId($key));
+ }
+
+ public function clear(string $prefix = ''): bool
+ {
+ if ($this->pool instanceof AdapterInterface) {
+ return $this->pool->clear($this->namespace.$prefix);
+ }
+
+ return $this->pool->clear();
+ }
+
+ public function deleteItem(mixed $key): bool
+ {
+ return $this->pool->deleteItem($this->getId($key));
+ }
+
+ public function deleteItems(array $keys): bool
+ {
+ if ($this->namespaceLen) {
+ foreach ($keys as $i => $key) {
+ $keys[$i] = $this->getId($key);
+ }
+ }
+
+ return $this->pool->deleteItems($keys);
+ }
+
+ public function save(CacheItemInterface $item): bool
+ {
+ return $this->doSave($item, __FUNCTION__);
+ }
+
+ public function saveDeferred(CacheItemInterface $item): bool
+ {
+ return $this->doSave($item, __FUNCTION__);
+ }
+
+ public function commit(): bool
+ {
+ return $this->pool->commit();
+ }
+
+ private function doSave(CacheItemInterface $item, string $method): bool
+ {
+ if (!$item instanceof CacheItem) {
+ return false;
+ }
+ $castItem = (array) $item;
+
+ if (null === $castItem["\0*\0expiry"] && 0 < $this->defaultLifetime) {
+ $castItem["\0*\0expiry"] = microtime(true) + $this->defaultLifetime;
+ }
+
+ if ($castItem["\0*\0poolHash"] === $this->poolHash && $castItem["\0*\0innerItem"]) {
+ $innerItem = $castItem["\0*\0innerItem"];
+ } elseif ($this->pool instanceof AdapterInterface) {
+ // this is an optimization specific for AdapterInterface implementations
+ // so we can save a round-trip to the backend by just creating a new item
+ $innerItem = (self::$createCacheItem)($this->namespace.$castItem["\0*\0key"], null, $this->poolHash);
+ } else {
+ $innerItem = $this->pool->getItem($this->namespace.$castItem["\0*\0key"]);
+ }
+
+ (self::$setInnerItem)($innerItem, $item, $castItem["\0*\0expiry"]);
+
+ return $this->pool->$method($innerItem);
+ }
+
+ private function generateItems(iterable $items): \Generator
+ {
+ $f = self::$createCacheItem;
+
+ foreach ($items as $key => $item) {
+ if ($this->namespaceLen) {
+ $key = substr($key, $this->namespaceLen);
+ }
+
+ yield $key => $f($key, $item, $this->poolHash);
+ }
+ }
+
+ private function getId(mixed $key): string
+ {
+ \assert('' !== CacheItem::validateKey($key));
+
+ return $this->namespace.$key;
+ }
+}
diff --git a/symfony/cache/Adapter/Psr16Adapter.php b/symfony/cache/Adapter/Psr16Adapter.php
new file mode 100644
index 0000000000000000000000000000000000000000..a72b037b03d380ba495a26c6f411a3ee44a7d536
--- /dev/null
+++ b/symfony/cache/Adapter/Psr16Adapter.php
@@ -0,0 +1,71 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Adapter;
+
+use Psr\SimpleCache\CacheInterface;
+use Symfony\Component\Cache\PruneableInterface;
+use Symfony\Component\Cache\ResettableInterface;
+use Symfony\Component\Cache\Traits\ProxyTrait;
+
+/**
+ * Turns a PSR-16 cache into a PSR-6 one.
+ *
+ * @author Nicolas Grekas
+ */
+class Psr16Adapter extends AbstractAdapter implements PruneableInterface, ResettableInterface
+{
+ use ProxyTrait;
+
+ /**
+ * @internal
+ */
+ protected const NS_SEPARATOR = '_';
+
+ private object $miss;
+
+ public function __construct(CacheInterface $pool, string $namespace = '', int $defaultLifetime = 0)
+ {
+ parent::__construct($namespace, $defaultLifetime);
+
+ $this->pool = $pool;
+ $this->miss = new \stdClass();
+ }
+
+ protected function doFetch(array $ids): iterable
+ {
+ foreach ($this->pool->getMultiple($ids, $this->miss) as $key => $value) {
+ if ($this->miss !== $value) {
+ yield $key => $value;
+ }
+ }
+ }
+
+ protected function doHave(string $id): bool
+ {
+ return $this->pool->has($id);
+ }
+
+ protected function doClear(string $namespace): bool
+ {
+ return $this->pool->clear();
+ }
+
+ protected function doDelete(array $ids): bool
+ {
+ return $this->pool->deleteMultiple($ids);
+ }
+
+ protected function doSave(array $values, int $lifetime): array|bool
+ {
+ return $this->pool->setMultiple($values, 0 === $lifetime ? null : $lifetime);
+ }
+}
diff --git a/symfony/cache/Adapter/RedisAdapter.php b/symfony/cache/Adapter/RedisAdapter.php
new file mode 100644
index 0000000000000000000000000000000000000000..e33f2f65fc92746fbbfa3cf167ca0ff3f26b264a
--- /dev/null
+++ b/symfony/cache/Adapter/RedisAdapter.php
@@ -0,0 +1,25 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Adapter;
+
+use Symfony\Component\Cache\Marshaller\MarshallerInterface;
+use Symfony\Component\Cache\Traits\RedisTrait;
+
+class RedisAdapter extends AbstractAdapter
+{
+ use RedisTrait;
+
+ public function __construct(\Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface|\Relay\Relay $redis, string $namespace = '', int $defaultLifetime = 0, ?MarshallerInterface $marshaller = null)
+ {
+ $this->init($redis, $namespace, $defaultLifetime, $marshaller);
+ }
+}
diff --git a/symfony/cache/Adapter/RedisTagAwareAdapter.php b/symfony/cache/Adapter/RedisTagAwareAdapter.php
new file mode 100644
index 0000000000000000000000000000000000000000..9aa959add24b53fd67696e316db25a2ff55c68f7
--- /dev/null
+++ b/symfony/cache/Adapter/RedisTagAwareAdapter.php
@@ -0,0 +1,316 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Adapter;
+
+use Predis\Connection\Aggregate\ClusterInterface;
+use Predis\Connection\Aggregate\PredisCluster;
+use Predis\Connection\Aggregate\ReplicationInterface;
+use Predis\Connection\Replication\ReplicationInterface as Predis2ReplicationInterface;
+use Predis\Response\ErrorInterface;
+use Predis\Response\Status;
+use Relay\Relay;
+use Symfony\Component\Cache\CacheItem;
+use Symfony\Component\Cache\Exception\InvalidArgumentException;
+use Symfony\Component\Cache\Exception\LogicException;
+use Symfony\Component\Cache\Marshaller\DeflateMarshaller;
+use Symfony\Component\Cache\Marshaller\MarshallerInterface;
+use Symfony\Component\Cache\Marshaller\TagAwareMarshaller;
+use Symfony\Component\Cache\Traits\RedisTrait;
+
+/**
+ * Stores tag id <> cache id relationship as a Redis Set.
+ *
+ * Set (tag relation info) is stored without expiry (non-volatile), while cache always gets an expiry (volatile) even
+ * if not set by caller. Thus if you configure redis with the right eviction policy you can be safe this tag <> cache
+ * relationship survives eviction (cache cleanup when Redis runs out of memory).
+ *
+ * Redis server 2.8+ with any `volatile-*` eviction policy, OR `noeviction` if you're sure memory will NEVER fill up
+ *
+ * Design limitations:
+ * - Max 4 billion cache keys per cache tag as limited by Redis Set datatype.
+ * E.g. If you use a "all" items tag for expiry instead of clear(), that limits you to 4 billion cache items also.
+ *
+ * @see https://redis.io/topics/lru-cache#eviction-policies Documentation for Redis eviction policies.
+ * @see https://redis.io/topics/data-types#sets Documentation for Redis Set datatype.
+ *
+ * @author Nicolas Grekas
+ * @author André Rømcke
+ */
+class RedisTagAwareAdapter extends AbstractTagAwareAdapter
+{
+ use RedisTrait;
+
+ /**
+ * On cache items without a lifetime set, we set it to 100 days. This is to make sure cache items are
+ * preferred to be evicted over tag Sets, if eviction policy is configured according to requirements.
+ */
+ private const DEFAULT_CACHE_TTL = 8640000;
+
+ /**
+ * detected eviction policy used on Redis server.
+ */
+ private string $redisEvictionPolicy;
+ private string $namespace;
+
+ public function __construct(\Redis|Relay|\RedisArray|\RedisCluster|\Predis\ClientInterface $redis, string $namespace = '', int $defaultLifetime = 0, ?MarshallerInterface $marshaller = null)
+ {
+ if ($redis instanceof \Predis\ClientInterface && $redis->getConnection() instanceof ClusterInterface && !$redis->getConnection() instanceof PredisCluster) {
+ throw new InvalidArgumentException(\sprintf('Unsupported Predis cluster connection: only "%s" is, "%s" given.', PredisCluster::class, get_debug_type($redis->getConnection())));
+ }
+
+ $isRelay = $redis instanceof Relay;
+ if ($isRelay || \defined('Redis::OPT_COMPRESSION') && \in_array($redis::class, [\Redis::class, \RedisArray::class, \RedisCluster::class], true)) {
+ $compression = $redis->getOption($isRelay ? Relay::OPT_COMPRESSION : \Redis::OPT_COMPRESSION);
+
+ foreach (\is_array($compression) ? $compression : [$compression] as $c) {
+ if ($isRelay ? Relay::COMPRESSION_NONE : \Redis::COMPRESSION_NONE !== $c) {
+ throw new InvalidArgumentException(\sprintf('redis compression must be disabled when using "%s", use "%s" instead.', static::class, DeflateMarshaller::class));
+ }
+ }
+ }
+
+ $this->init($redis, $namespace, $defaultLifetime, new TagAwareMarshaller($marshaller));
+ $this->namespace = $namespace;
+ }
+
+ protected function doSave(array $values, int $lifetime, array $addTagData = [], array $delTagData = []): array
+ {
+ $eviction = $this->getRedisEvictionPolicy();
+ if ('noeviction' !== $eviction && !str_starts_with($eviction, 'volatile-')) {
+ throw new LogicException(\sprintf('Redis maxmemory-policy setting "%s" is *not* supported by RedisTagAwareAdapter, use "noeviction" or "volatile-*" eviction policies.', $eviction));
+ }
+
+ // serialize values
+ if (!$serialized = $this->marshaller->marshall($values, $failed)) {
+ return $failed;
+ }
+
+ // While pipeline isn't supported on RedisCluster, other setups will at least benefit from doing this in one op
+ $results = $this->pipeline(static function () use ($serialized, $lifetime, $addTagData, $delTagData, $failed) {
+ // Store cache items, force a ttl if none is set, as there is no MSETEX we need to set each one
+ foreach ($serialized as $id => $value) {
+ yield 'setEx' => [
+ $id,
+ 0 >= $lifetime ? self::DEFAULT_CACHE_TTL : $lifetime,
+ $value,
+ ];
+ }
+
+ // Add and Remove Tags
+ foreach ($addTagData as $tagId => $ids) {
+ if (!$failed || $ids = array_diff($ids, $failed)) {
+ yield 'sAdd' => array_merge([$tagId], $ids);
+ }
+ }
+
+ foreach ($delTagData as $tagId => $ids) {
+ if (!$failed || $ids = array_diff($ids, $failed)) {
+ yield 'sRem' => array_merge([$tagId], $ids);
+ }
+ }
+ });
+
+ foreach ($results as $id => $result) {
+ // Skip results of SADD/SREM operations, they'll be 1 or 0 depending on if set value already existed or not
+ if (is_numeric($result)) {
+ continue;
+ }
+ // setEx results
+ if (true !== $result && (!$result instanceof Status || Status::get('OK') !== $result)) {
+ $failed[] = $id;
+ }
+ }
+
+ return $failed;
+ }
+
+ protected function doDeleteYieldTags(array $ids): iterable
+ {
+ $lua = <<<'EOLUA'
+ local v = redis.call('GET', KEYS[1])
+ local e = redis.pcall('UNLINK', KEYS[1])
+
+ if type(e) ~= 'number' then
+ redis.call('DEL', KEYS[1])
+ end
+
+ if not v or v:len() <= 13 or v:byte(1) ~= 0x9D or v:byte(6) ~= 0 or v:byte(10) ~= 0x5F then
+ return ''
+ end
+
+ return v:sub(14, 13 + v:byte(13) + v:byte(12) * 256 + v:byte(11) * 65536)
+EOLUA;
+
+ $results = $this->pipeline(function () use ($ids, $lua) {
+ foreach ($ids as $id) {
+ yield 'eval' => $this->redis instanceof \Predis\ClientInterface ? [$lua, 1, $id] : [$lua, [$id], 1];
+ }
+ });
+
+ foreach ($results as $id => $result) {
+ if ($result instanceof \RedisException || $result instanceof \Relay\Exception || $result instanceof ErrorInterface) {
+ CacheItem::log($this->logger, 'Failed to delete key "{key}": '.$result->getMessage(), ['key' => substr($id, \strlen($this->namespace)), 'exception' => $result]);
+
+ continue;
+ }
+
+ try {
+ yield $id => !\is_string($result) || '' === $result ? [] : $this->marshaller->unmarshall($result);
+ } catch (\Exception) {
+ yield $id => [];
+ }
+ }
+ }
+
+ protected function doDeleteTagRelations(array $tagData): bool
+ {
+ $results = $this->pipeline(static function () use ($tagData) {
+ foreach ($tagData as $tagId => $idList) {
+ array_unshift($idList, $tagId);
+ yield 'sRem' => $idList;
+ }
+ });
+ foreach ($results as $result) {
+ // no-op
+ }
+
+ return true;
+ }
+
+ protected function doInvalidate(array $tagIds): bool
+ {
+ // This script scans the set of items linked to tag: it empties the set
+ // and removes the linked items. When the set is still not empty after
+ // the scan, it means we're in cluster mode and that the linked items
+ // are on other nodes: we move the links to a temporary set and we
+ // garbage collect that set from the client side.
+
+ $lua = <<<'EOLUA'
+ redis.replicate_commands()
+
+ local cursor = '0'
+ local id = KEYS[1]
+ repeat
+ local result = redis.call('SSCAN', id, cursor, 'COUNT', 5000);
+ cursor = result[1];
+ local rems = {}
+
+ for _, v in ipairs(result[2]) do
+ local ok, _ = pcall(redis.call, 'DEL', ARGV[1]..v)
+ if ok then
+ table.insert(rems, v)
+ end
+ end
+ if 0 < #rems then
+ redis.call('SREM', id, unpack(rems))
+ end
+ until '0' == cursor;
+
+ redis.call('SUNIONSTORE', '{'..id..'}'..id, id)
+ redis.call('DEL', id)
+
+ return redis.call('SSCAN', '{'..id..'}'..id, '0', 'COUNT', 5000)
+EOLUA;
+
+ $results = $this->pipeline(function () use ($tagIds, $lua) {
+ if ($this->redis instanceof \Predis\ClientInterface) {
+ $prefix = $this->redis->getOptions()->prefix ? $this->redis->getOptions()->prefix->getPrefix() : '';
+ } elseif (\is_array($prefix = $this->redis->getOption($this->redis instanceof Relay ? Relay::OPT_PREFIX : \Redis::OPT_PREFIX) ?? '')) {
+ $prefix = current($prefix);
+ }
+
+ foreach ($tagIds as $id) {
+ yield 'eval' => $this->redis instanceof \Predis\ClientInterface ? [$lua, 1, $id, $prefix] : [$lua, [$id, $prefix], 1];
+ }
+ });
+
+ $lua = <<<'EOLUA'
+ redis.replicate_commands()
+
+ local id = KEYS[1]
+ local cursor = table.remove(ARGV)
+ redis.call('SREM', '{'..id..'}'..id, unpack(ARGV))
+
+ return redis.call('SSCAN', '{'..id..'}'..id, cursor, 'COUNT', 5000)
+EOLUA;
+
+ $success = true;
+ foreach ($results as $id => $values) {
+ if ($values instanceof \RedisException || $values instanceof \Relay\Exception || $values instanceof ErrorInterface) {
+ CacheItem::log($this->logger, 'Failed to invalidate key "{key}": '.$values->getMessage(), ['key' => substr($id, \strlen($this->namespace)), 'exception' => $values]);
+ $success = false;
+
+ continue;
+ }
+
+ [$cursor, $ids] = $values;
+
+ while ($ids || '0' !== $cursor) {
+ $this->doDelete($ids);
+
+ $evalArgs = [$id, $cursor];
+ array_splice($evalArgs, 1, 0, $ids);
+
+ if ($this->redis instanceof \Predis\ClientInterface) {
+ array_unshift($evalArgs, $lua, 1);
+ } else {
+ $evalArgs = [$lua, $evalArgs, 1];
+ }
+
+ $results = $this->pipeline(function () use ($evalArgs) {
+ yield 'eval' => $evalArgs;
+ });
+
+ foreach ($results as [$cursor, $ids]) {
+ // no-op
+ }
+ }
+ }
+
+ return $success;
+ }
+
+ private function getRedisEvictionPolicy(): string
+ {
+ if (isset($this->redisEvictionPolicy)) {
+ return $this->redisEvictionPolicy;
+ }
+
+ $hosts = $this->getHosts();
+ $host = reset($hosts);
+ if ($host instanceof \Predis\Client) {
+ $connection = $host->getConnection();
+
+ // Predis supports info command only on the master in replication environments
+ if ($connection instanceof ReplicationInterface) {
+ $hosts = [$host->getClientFor('master')];
+ } elseif ($connection instanceof Predis2ReplicationInterface) {
+ $connection->switchToMaster();
+ $hosts = [$host];
+ }
+ }
+
+ foreach ($hosts as $host) {
+ $info = $host->info('Memory');
+
+ if (false === $info || null === $info || $info instanceof ErrorInterface) {
+ continue;
+ }
+
+ $info = $info['Memory'] ?? $info;
+
+ return $this->redisEvictionPolicy = $info['maxmemory_policy'] ?? '';
+ }
+
+ return $this->redisEvictionPolicy = '';
+ }
+}
diff --git a/symfony/cache/Adapter/TagAwareAdapter.php b/symfony/cache/Adapter/TagAwareAdapter.php
new file mode 100644
index 0000000000000000000000000000000000000000..a12e908ad7d14bb527da6decfd6cba7983d517ba
--- /dev/null
+++ b/symfony/cache/Adapter/TagAwareAdapter.php
@@ -0,0 +1,372 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Adapter;
+
+use Psr\Cache\CacheItemInterface;
+use Psr\Cache\InvalidArgumentException;
+use Psr\Log\LoggerAwareInterface;
+use Psr\Log\LoggerAwareTrait;
+use Symfony\Component\Cache\CacheItem;
+use Symfony\Component\Cache\PruneableInterface;
+use Symfony\Component\Cache\ResettableInterface;
+use Symfony\Component\Cache\Traits\ContractsTrait;
+use Symfony\Contracts\Cache\TagAwareCacheInterface;
+
+/**
+ * Implements simple and robust tag-based invalidation suitable for use with volatile caches.
+ *
+ * This adapter works by storing a version for each tags. When saving an item, it is stored together with its tags and
+ * their corresponding versions. When retrieving an item, those tag versions are compared to the current version of
+ * each tags. Invalidation is achieved by deleting tags, thereby ensuring that their versions change even when the
+ * storage is out of space. When versions of non-existing tags are requested for item commits, this adapter assigns a
+ * new random version to them.
+ *
+ * @author Nicolas Grekas
+ * @author Sergey Belyshkin
+ */
+class TagAwareAdapter implements TagAwareAdapterInterface, TagAwareCacheInterface, PruneableInterface, ResettableInterface, LoggerAwareInterface
+{
+ use ContractsTrait;
+ use LoggerAwareTrait;
+
+ public const TAGS_PREFIX = "\1tags\1";
+
+ private array $deferred = [];
+ private AdapterInterface $pool;
+ private AdapterInterface $tags;
+ private array $knownTagVersions = [];
+ private float $knownTagVersionsTtl;
+
+ private static \Closure $setCacheItemTags;
+ private static \Closure $setTagVersions;
+ private static \Closure $getTagsByKey;
+ private static \Closure $saveTags;
+
+ public function __construct(AdapterInterface $itemsPool, ?AdapterInterface $tagsPool = null, float $knownTagVersionsTtl = 0.15)
+ {
+ $this->pool = $itemsPool;
+ $this->tags = $tagsPool ?? $itemsPool;
+ $this->knownTagVersionsTtl = $knownTagVersionsTtl;
+ self::$setCacheItemTags ??= \Closure::bind(
+ static function (array $items, array $itemTags) {
+ foreach ($items as $key => $item) {
+ $item->isTaggable = true;
+
+ if (isset($itemTags[$key])) {
+ $tags = array_keys($itemTags[$key]);
+ $item->metadata[CacheItem::METADATA_TAGS] = array_combine($tags, $tags);
+ } else {
+ $item->value = null;
+ $item->isHit = false;
+ $item->metadata = [];
+ }
+ }
+
+ return $items;
+ },
+ null,
+ CacheItem::class
+ );
+ self::$setTagVersions ??= \Closure::bind(
+ static function (array $items, array $tagVersions) {
+ foreach ($items as $item) {
+ $item->newMetadata[CacheItem::METADATA_TAGS] = array_intersect_key($tagVersions, $item->newMetadata[CacheItem::METADATA_TAGS] ?? []);
+ }
+ },
+ null,
+ CacheItem::class
+ );
+ self::$getTagsByKey ??= \Closure::bind(
+ static function ($deferred) {
+ $tagsByKey = [];
+ foreach ($deferred as $key => $item) {
+ $tagsByKey[$key] = $item->newMetadata[CacheItem::METADATA_TAGS] ?? [];
+ $item->metadata = $item->newMetadata;
+ }
+
+ return $tagsByKey;
+ },
+ null,
+ CacheItem::class
+ );
+ self::$saveTags ??= \Closure::bind(
+ static function (AdapterInterface $tagsAdapter, array $tags) {
+ ksort($tags);
+
+ foreach ($tags as $v) {
+ $v->expiry = 0;
+ $tagsAdapter->saveDeferred($v);
+ }
+
+ return $tagsAdapter->commit();
+ },
+ null,
+ CacheItem::class
+ );
+ }
+
+ public function invalidateTags(array $tags): bool
+ {
+ $ids = [];
+ foreach ($tags as $tag) {
+ \assert('' !== CacheItem::validateKey($tag));
+ unset($this->knownTagVersions[$tag]);
+ $ids[] = $tag.static::TAGS_PREFIX;
+ }
+
+ return !$tags || $this->tags->deleteItems($ids);
+ }
+
+ public function hasItem(mixed $key): bool
+ {
+ return $this->getItem($key)->isHit();
+ }
+
+ public function getItem(mixed $key): CacheItem
+ {
+ foreach ($this->getItems([$key]) as $item) {
+ return $item;
+ }
+ }
+
+ public function getItems(array $keys = []): iterable
+ {
+ $tagKeys = [];
+ $commit = false;
+
+ foreach ($keys as $key) {
+ if ('' !== $key && \is_string($key)) {
+ $commit = $commit || isset($this->deferred[$key]);
+ }
+ }
+
+ if ($commit) {
+ $this->commit();
+ }
+
+ try {
+ $items = $this->pool->getItems($keys);
+ } catch (InvalidArgumentException $e) {
+ $this->pool->getItems($keys); // Should throw an exception
+
+ throw $e;
+ }
+
+ $bufferedItems = $itemTags = [];
+
+ foreach ($items as $key => $item) {
+ if (null !== $tags = $item->getMetadata()[CacheItem::METADATA_TAGS] ?? null) {
+ $itemTags[$key] = $tags;
+ }
+
+ $bufferedItems[$key] = $item;
+
+ if (null === $tags) {
+ $key = "\0tags\0".$key;
+ $tagKeys[$key] = $key; // BC with pools populated before v6.1
+ }
+ }
+
+ if ($tagKeys) {
+ foreach ($this->pool->getItems($tagKeys) as $key => $item) {
+ if ($item->isHit()) {
+ $itemTags[substr($key, \strlen("\0tags\0"))] = $item->get() ?: [];
+ }
+ }
+ }
+
+ $tagVersions = $this->getTagVersions($itemTags, false);
+ foreach ($itemTags as $key => $tags) {
+ foreach ($tags as $tag => $version) {
+ if ($tagVersions[$tag] !== $version) {
+ unset($itemTags[$key]);
+ continue 2;
+ }
+ }
+ }
+ $tagVersions = null;
+
+ return (self::$setCacheItemTags)($bufferedItems, $itemTags);
+ }
+
+ public function clear(string $prefix = ''): bool
+ {
+ if ('' !== $prefix) {
+ foreach ($this->deferred as $key => $item) {
+ if (str_starts_with($key, $prefix)) {
+ unset($this->deferred[$key]);
+ }
+ }
+ } else {
+ $this->deferred = [];
+ }
+
+ if ($this->pool instanceof AdapterInterface) {
+ return $this->pool->clear($prefix);
+ }
+
+ return $this->pool->clear();
+ }
+
+ public function deleteItem(mixed $key): bool
+ {
+ return $this->deleteItems([$key]);
+ }
+
+ public function deleteItems(array $keys): bool
+ {
+ foreach ($keys as $key) {
+ if ('' !== $key && \is_string($key)) {
+ $keys[] = "\0tags\0".$key; // BC with pools populated before v6.1
+ }
+ }
+
+ return $this->pool->deleteItems($keys);
+ }
+
+ public function save(CacheItemInterface $item): bool
+ {
+ if (!$item instanceof CacheItem) {
+ return false;
+ }
+ $this->deferred[$item->getKey()] = $item;
+
+ return $this->commit();
+ }
+
+ public function saveDeferred(CacheItemInterface $item): bool
+ {
+ if (!$item instanceof CacheItem) {
+ return false;
+ }
+ $this->deferred[$item->getKey()] = $item;
+
+ return true;
+ }
+
+ public function commit(): bool
+ {
+ if (!$items = $this->deferred) {
+ return true;
+ }
+
+ $tagVersions = $this->getTagVersions((self::$getTagsByKey)($items), true);
+ (self::$setTagVersions)($items, $tagVersions);
+
+ $ok = true;
+ foreach ($items as $key => $item) {
+ if ($this->pool->saveDeferred($item)) {
+ unset($this->deferred[$key]);
+ } else {
+ $ok = false;
+ }
+ }
+ $ok = $this->pool->commit() && $ok;
+
+ $tagVersions = array_keys($tagVersions);
+ (self::$setTagVersions)($items, array_combine($tagVersions, $tagVersions));
+
+ return $ok;
+ }
+
+ public function prune(): bool
+ {
+ return $this->pool instanceof PruneableInterface && $this->pool->prune();
+ }
+
+ /**
+ * @return void
+ */
+ public function reset()
+ {
+ $this->commit();
+ $this->knownTagVersions = [];
+ $this->pool instanceof ResettableInterface && $this->pool->reset();
+ $this->tags instanceof ResettableInterface && $this->tags->reset();
+ }
+
+ public function __serialize(): array
+ {
+ throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
+ }
+
+ public function __unserialize(array $data): void
+ {
+ throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
+ }
+
+ public function __destruct()
+ {
+ $this->commit();
+ }
+
+ private function getTagVersions(array $tagsByKey, bool $persistTags): array
+ {
+ $tagVersions = [];
+ $fetchTagVersions = $persistTags;
+
+ foreach ($tagsByKey as $tags) {
+ $tagVersions += $tags;
+ if ($fetchTagVersions) {
+ continue;
+ }
+ foreach ($tags as $tag => $version) {
+ if ($tagVersions[$tag] !== $version) {
+ $fetchTagVersions = true;
+ }
+ }
+ }
+
+ if (!$tagVersions) {
+ return [];
+ }
+
+ $now = microtime(true);
+ $tags = [];
+ foreach ($tagVersions as $tag => $version) {
+ $tags[$tag.static::TAGS_PREFIX] = $tag;
+ $knownTagVersion = $this->knownTagVersions[$tag] ?? [0, null];
+ if ($fetchTagVersions || $now > $knownTagVersion[0] || $knownTagVersion[1] !== $version) {
+ // reuse previously fetched tag versions until the expiration
+ $fetchTagVersions = true;
+ }
+ }
+
+ if (!$fetchTagVersions) {
+ return $tagVersions;
+ }
+
+ $newTags = [];
+ $newVersion = null;
+ $expiration = $now + $this->knownTagVersionsTtl;
+ foreach ($this->tags->getItems(array_keys($tags)) as $tag => $version) {
+ unset($this->knownTagVersions[$tag = $tags[$tag]]); // update FIFO
+ if (null !== $tagVersions[$tag] = $version->get()) {
+ $this->knownTagVersions[$tag] = [$expiration, $tagVersions[$tag]];
+ } elseif ($persistTags) {
+ $newTags[$tag] = $version->set($newVersion ??= random_bytes(6));
+ $tagVersions[$tag] = $newVersion;
+ $this->knownTagVersions[$tag] = [$expiration, $newVersion];
+ }
+ }
+
+ if ($newTags) {
+ (self::$saveTags)($this->tags, $newTags);
+ }
+
+ while ($now > ($this->knownTagVersions[$tag = array_key_first($this->knownTagVersions) ?? ''][0] ?? \INF)) {
+ unset($this->knownTagVersions[$tag]);
+ }
+
+ return $tagVersions;
+ }
+}
diff --git a/symfony/cache/Adapter/TagAwareAdapterInterface.php b/symfony/cache/Adapter/TagAwareAdapterInterface.php
new file mode 100644
index 0000000000000000000000000000000000000000..9242779c1aae85319e0ffce65be51b582b969ba4
--- /dev/null
+++ b/symfony/cache/Adapter/TagAwareAdapterInterface.php
@@ -0,0 +1,31 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Adapter;
+
+use Psr\Cache\InvalidArgumentException;
+
+/**
+ * Interface for invalidating cached items using tags.
+ *
+ * @author Nicolas Grekas
+ */
+interface TagAwareAdapterInterface extends AdapterInterface
+{
+ /**
+ * Invalidates cached items using tags.
+ *
+ * @param string[] $tags An array of tags to invalidate
+ *
+ * @throws InvalidArgumentException When $tags is not valid
+ */
+ public function invalidateTags(array $tags): bool;
+}
diff --git a/symfony/cache/Adapter/TraceableAdapter.php b/symfony/cache/Adapter/TraceableAdapter.php
new file mode 100644
index 0000000000000000000000000000000000000000..1e9929541990bbf8e5e2aa3c37fd5ddc57ef1266
--- /dev/null
+++ b/symfony/cache/Adapter/TraceableAdapter.php
@@ -0,0 +1,262 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Adapter;
+
+use Psr\Cache\CacheItemInterface;
+use Symfony\Component\Cache\CacheItem;
+use Symfony\Component\Cache\PruneableInterface;
+use Symfony\Component\Cache\ResettableInterface;
+use Symfony\Contracts\Cache\CacheInterface;
+use Symfony\Contracts\Service\ResetInterface;
+
+/**
+ * An adapter that collects data about all cache calls.
+ *
+ * @author Aaron Scherer
+ * @author Tobias Nyholm
+ * @author Nicolas Grekas
+ */
+class TraceableAdapter implements AdapterInterface, CacheInterface, PruneableInterface, ResettableInterface
+{
+ protected $pool;
+ private array $calls = [];
+
+ public function __construct(AdapterInterface $pool)
+ {
+ $this->pool = $pool;
+ }
+
+ public function get(string $key, callable $callback, ?float $beta = null, ?array &$metadata = null): mixed
+ {
+ if (!$this->pool instanceof CacheInterface) {
+ throw new \BadMethodCallException(\sprintf('Cannot call "%s::get()": this class doesn\'t implement "%s".', get_debug_type($this->pool), CacheInterface::class));
+ }
+
+ $isHit = true;
+ $callback = function (CacheItem $item, bool &$save) use ($callback, &$isHit) {
+ $isHit = $item->isHit();
+
+ return $callback($item, $save);
+ };
+
+ $event = $this->start(__FUNCTION__);
+ try {
+ $value = $this->pool->get($key, $callback, $beta, $metadata);
+ $event->result[$key] = get_debug_type($value);
+ } finally {
+ $event->end = microtime(true);
+ }
+ if ($isHit) {
+ ++$event->hits;
+ } else {
+ ++$event->misses;
+ }
+
+ return $value;
+ }
+
+ public function getItem(mixed $key): CacheItem
+ {
+ $event = $this->start(__FUNCTION__);
+ try {
+ $item = $this->pool->getItem($key);
+ } finally {
+ $event->end = microtime(true);
+ }
+ if ($event->result[$key] = $item->isHit()) {
+ ++$event->hits;
+ } else {
+ ++$event->misses;
+ }
+
+ return $item;
+ }
+
+ public function hasItem(mixed $key): bool
+ {
+ $event = $this->start(__FUNCTION__);
+ try {
+ return $event->result[$key] = $this->pool->hasItem($key);
+ } finally {
+ $event->end = microtime(true);
+ }
+ }
+
+ public function deleteItem(mixed $key): bool
+ {
+ $event = $this->start(__FUNCTION__);
+ try {
+ return $event->result[$key] = $this->pool->deleteItem($key);
+ } finally {
+ $event->end = microtime(true);
+ }
+ }
+
+ public function save(CacheItemInterface $item): bool
+ {
+ $event = $this->start(__FUNCTION__);
+ try {
+ return $event->result[$item->getKey()] = $this->pool->save($item);
+ } finally {
+ $event->end = microtime(true);
+ }
+ }
+
+ public function saveDeferred(CacheItemInterface $item): bool
+ {
+ $event = $this->start(__FUNCTION__);
+ try {
+ return $event->result[$item->getKey()] = $this->pool->saveDeferred($item);
+ } finally {
+ $event->end = microtime(true);
+ }
+ }
+
+ public function getItems(array $keys = []): iterable
+ {
+ $event = $this->start(__FUNCTION__);
+ try {
+ $result = $this->pool->getItems($keys);
+ } finally {
+ $event->end = microtime(true);
+ }
+ $f = function () use ($result, $event) {
+ $event->result = [];
+ foreach ($result as $key => $item) {
+ if ($event->result[$key] = $item->isHit()) {
+ ++$event->hits;
+ } else {
+ ++$event->misses;
+ }
+ yield $key => $item;
+ }
+ };
+
+ return $f();
+ }
+
+ public function clear(string $prefix = ''): bool
+ {
+ $event = $this->start(__FUNCTION__);
+ try {
+ if ($this->pool instanceof AdapterInterface) {
+ return $event->result = $this->pool->clear($prefix);
+ }
+
+ return $event->result = $this->pool->clear();
+ } finally {
+ $event->end = microtime(true);
+ }
+ }
+
+ public function deleteItems(array $keys): bool
+ {
+ $event = $this->start(__FUNCTION__);
+ $event->result['keys'] = $keys;
+ try {
+ return $event->result['result'] = $this->pool->deleteItems($keys);
+ } finally {
+ $event->end = microtime(true);
+ }
+ }
+
+ public function commit(): bool
+ {
+ $event = $this->start(__FUNCTION__);
+ try {
+ return $event->result = $this->pool->commit();
+ } finally {
+ $event->end = microtime(true);
+ }
+ }
+
+ public function prune(): bool
+ {
+ if (!$this->pool instanceof PruneableInterface) {
+ return false;
+ }
+ $event = $this->start(__FUNCTION__);
+ try {
+ return $event->result = $this->pool->prune();
+ } finally {
+ $event->end = microtime(true);
+ }
+ }
+
+ /**
+ * @return void
+ */
+ public function reset()
+ {
+ if ($this->pool instanceof ResetInterface) {
+ $this->pool->reset();
+ }
+
+ $this->clearCalls();
+ }
+
+ public function delete(string $key): bool
+ {
+ $event = $this->start(__FUNCTION__);
+ try {
+ return $event->result[$key] = $this->pool->deleteItem($key);
+ } finally {
+ $event->end = microtime(true);
+ }
+ }
+
+ /**
+ * @return array
+ */
+ public function getCalls()
+ {
+ return $this->calls;
+ }
+
+ /**
+ * @return void
+ */
+ public function clearCalls()
+ {
+ $this->calls = [];
+ }
+
+ public function getPool(): AdapterInterface
+ {
+ return $this->pool;
+ }
+
+ /**
+ * @return TraceableAdapterEvent
+ */
+ protected function start(string $name)
+ {
+ $this->calls[] = $event = new TraceableAdapterEvent();
+ $event->name = $name;
+ $event->start = microtime(true);
+
+ return $event;
+ }
+}
+
+/**
+ * @internal
+ */
+class TraceableAdapterEvent
+{
+ public string $name;
+ public float $start;
+ public float $end;
+ public array|bool $result;
+ public int $hits = 0;
+ public int $misses = 0;
+}
diff --git a/symfony/cache/Adapter/TraceableTagAwareAdapter.php b/symfony/cache/Adapter/TraceableTagAwareAdapter.php
new file mode 100644
index 0000000000000000000000000000000000000000..c85d199e49cb6f352a21fc24bb484e2a1f5c4975
--- /dev/null
+++ b/symfony/cache/Adapter/TraceableTagAwareAdapter.php
@@ -0,0 +1,35 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Adapter;
+
+use Symfony\Contracts\Cache\TagAwareCacheInterface;
+
+/**
+ * @author Robin Chalas
+ */
+class TraceableTagAwareAdapter extends TraceableAdapter implements TagAwareAdapterInterface, TagAwareCacheInterface
+{
+ public function __construct(TagAwareAdapterInterface $pool)
+ {
+ parent::__construct($pool);
+ }
+
+ public function invalidateTags(array $tags): bool
+ {
+ $event = $this->start(__FUNCTION__);
+ try {
+ return $event->result = $this->pool->invalidateTags($tags);
+ } finally {
+ $event->end = microtime(true);
+ }
+ }
+}
diff --git a/symfony/cache/CHANGELOG.md b/symfony/cache/CHANGELOG.md
new file mode 100644
index 0000000000000000000000000000000000000000..4c1c9d4205762a72833408a9309781a6bb67254e
--- /dev/null
+++ b/symfony/cache/CHANGELOG.md
@@ -0,0 +1,132 @@
+CHANGELOG
+=========
+
+6.4
+---
+
+ * `EarlyExpirationHandler` no longer implements `MessageHandlerInterface`, rely on `AsMessageHandler` instead
+
+6.3
+---
+
+ * Add support for Relay PHP extension for Redis
+ * Updates to allow Redis cluster connections using predis/predis:^2.0
+ * Add optional parameter `$isSameDatabase` to `DoctrineDbalAdapter::configureSchema()`
+
+6.1
+---
+
+ * Add support for ACL auth in RedisAdapter
+ * Improve reliability and performance of `TagAwareAdapter` by making tag versions an integral part of item value
+
+6.0
+---
+
+ * Remove `DoctrineProvider` and `DoctrineAdapter`
+ * Remove support of Doctrine DBAL in `PdoAdapter`
+
+5.4
+---
+
+ * Deprecate `DoctrineProvider` and `DoctrineAdapter` because these classes have been added to the `doctrine/cache` package
+ * Add `DoctrineDbalAdapter` identical to `PdoAdapter` for `Doctrine\DBAL\Connection` or DBAL URL
+ * Deprecate usage of `PdoAdapter` with `Doctrine\DBAL\Connection` or DBAL URL
+
+5.3
+---
+
+ * added support for connecting to Redis Sentinel clusters when using the Redis PHP extension
+ * add support for a custom serializer to the `ApcuAdapter` class
+
+5.2.0
+-----
+
+ * added integration with Messenger to allow computing cached values in a worker
+ * allow ISO 8601 time intervals to specify default lifetime
+
+5.1.0
+-----
+
+ * added max-items + LRU + max-lifetime capabilities to `ArrayCache`
+ * added `CouchbaseBucketAdapter`
+ * added context `cache-adapter` to log messages
+
+5.0.0
+-----
+
+ * removed all PSR-16 implementations in the `Simple` namespace
+ * removed `SimpleCacheAdapter`
+ * removed `AbstractAdapter::unserialize()`
+ * removed `CacheItem::getPreviousTags()`
+
+4.4.0
+-----
+
+ * added support for connecting to Redis Sentinel clusters
+ * added argument `$prefix` to `AdapterInterface::clear()`
+ * improved `RedisTagAwareAdapter` to support Redis server >= 2.8 and up to 4B items per tag
+ * added `TagAwareMarshaller` for optimized data storage when using `AbstractTagAwareAdapter`
+ * added `DeflateMarshaller` to compress serialized values
+ * removed support for phpredis 4 `compression`
+ * [BC BREAK] `RedisTagAwareAdapter` is not compatible with `RedisCluster` from `Predis` anymore, use `phpredis` instead
+ * Marked the `CacheDataCollector` class as `@final`.
+ * added `SodiumMarshaller` to encrypt/decrypt values using libsodium
+
+4.3.0
+-----
+
+ * removed `psr/simple-cache` dependency, run `composer require psr/simple-cache` if you need it
+ * deprecated all PSR-16 adapters, use `Psr16Cache` or `Symfony\Contracts\Cache\CacheInterface` implementations instead
+ * deprecated `SimpleCacheAdapter`, use `Psr16Adapter` instead
+
+4.2.0
+-----
+
+ * added support for connecting to Redis clusters via DSN
+ * added support for configuring multiple Memcached servers via DSN
+ * added `MarshallerInterface` and `DefaultMarshaller` to allow changing the serializer and provide one that automatically uses igbinary when available
+ * implemented `CacheInterface`, which provides stampede protection via probabilistic early expiration and should become the preferred way to use a cache
+ * added sub-second expiry accuracy for backends that support it
+ * added support for phpredis 4 `compression` and `tcp_keepalive` options
+ * added automatic table creation when using Doctrine DBAL with PDO-based backends
+ * throw `LogicException` when `CacheItem::tag()` is called on an item coming from a non tag-aware pool
+ * deprecated `CacheItem::getPreviousTags()`, use `CacheItem::getMetadata()` instead
+ * deprecated the `AbstractAdapter::unserialize()` and `AbstractCache::unserialize()` methods
+ * added `CacheCollectorPass` (originally in `FrameworkBundle`)
+ * added `CachePoolClearerPass` (originally in `FrameworkBundle`)
+ * added `CachePoolPass` (originally in `FrameworkBundle`)
+ * added `CachePoolPrunerPass` (originally in `FrameworkBundle`)
+
+3.4.0
+-----
+
+ * added using options from Memcached DSN
+ * added PruneableInterface so PSR-6 or PSR-16 cache implementations can declare support for manual stale cache pruning
+ * added prune logic to FilesystemTrait, PhpFilesTrait, PdoTrait, TagAwareAdapter and ChainTrait
+ * now FilesystemAdapter, PhpFilesAdapter, FilesystemCache, PhpFilesCache, PdoAdapter, PdoCache, ChainAdapter, and
+ ChainCache implement PruneableInterface and support manual stale cache pruning
+
+3.3.0
+-----
+
+ * added CacheItem::getPreviousTags() to get bound tags coming from the pool storage if any
+ * added PSR-16 "Simple Cache" implementations for all existing PSR-6 adapters
+ * added Psr6Cache and SimpleCacheAdapter for bidirectional interoperability between PSR-6 and PSR-16
+ * added MemcachedAdapter (PSR-6) and MemcachedCache (PSR-16)
+ * added TraceableAdapter (PSR-6) and TraceableCache (PSR-16)
+
+3.2.0
+-----
+
+ * added TagAwareAdapter for tags-based invalidation
+ * added PdoAdapter with PDO and Doctrine DBAL support
+ * added PhpArrayAdapter and PhpFilesAdapter for OPcache-backed shared memory storage (PHP 7+ only)
+ * added NullAdapter
+
+3.1.0
+-----
+
+ * added the component with strict PSR-6 implementations
+ * added ApcuAdapter, ArrayAdapter, FilesystemAdapter and RedisAdapter
+ * added AbstractAdapter, ChainAdapter and ProxyAdapter
+ * added DoctrineAdapter and DoctrineProvider for bidirectional interoperability with Doctrine Cache
diff --git a/symfony/cache/CacheItem.php b/symfony/cache/CacheItem.php
new file mode 100644
index 0000000000000000000000000000000000000000..1aa5bcdced6f04ae7a712b04abdfa544b67d02d8
--- /dev/null
+++ b/symfony/cache/CacheItem.php
@@ -0,0 +1,201 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache;
+
+use Psr\Cache\CacheItemInterface;
+use Psr\Log\LoggerInterface;
+use Symfony\Component\Cache\Exception\InvalidArgumentException;
+use Symfony\Component\Cache\Exception\LogicException;
+use Symfony\Contracts\Cache\ItemInterface;
+
+/**
+ * @author Nicolas Grekas
+ */
+final class CacheItem implements ItemInterface
+{
+ private const METADATA_EXPIRY_OFFSET = 1527506807;
+ private const VALUE_WRAPPER = "\xA9";
+
+ protected string $key;
+ protected mixed $value = null;
+ protected bool $isHit = false;
+ protected float|int|null $expiry = null;
+ protected array $metadata = [];
+ protected array $newMetadata = [];
+ protected ?CacheItemInterface $innerItem = null;
+ protected ?string $poolHash = null;
+ protected bool $isTaggable = false;
+
+ public function getKey(): string
+ {
+ return $this->key;
+ }
+
+ public function get(): mixed
+ {
+ return $this->value;
+ }
+
+ public function isHit(): bool
+ {
+ return $this->isHit;
+ }
+
+ /**
+ * @return $this
+ */
+ public function set($value): static
+ {
+ $this->value = $value;
+
+ return $this;
+ }
+
+ /**
+ * @return $this
+ */
+ public function expiresAt(?\DateTimeInterface $expiration): static
+ {
+ $this->expiry = null !== $expiration ? (float) $expiration->format('U.u') : null;
+
+ return $this;
+ }
+
+ /**
+ * @return $this
+ */
+ public function expiresAfter(mixed $time): static
+ {
+ if (null === $time) {
+ $this->expiry = null;
+ } elseif ($time instanceof \DateInterval) {
+ $this->expiry = microtime(true) + \DateTimeImmutable::createFromFormat('U', 0)->add($time)->format('U.u');
+ } elseif (\is_int($time)) {
+ $this->expiry = $time + microtime(true);
+ } else {
+ throw new InvalidArgumentException(\sprintf('Expiration date must be an integer, a DateInterval or null, "%s" given.', get_debug_type($time)));
+ }
+
+ return $this;
+ }
+
+ public function tag(mixed $tags): static
+ {
+ if (!$this->isTaggable) {
+ throw new LogicException(\sprintf('Cache item "%s" comes from a non tag-aware pool: you cannot tag it.', $this->key));
+ }
+ if (!\is_array($tags) && !$tags instanceof \Traversable) { // don't use is_iterable(), it's slow
+ $tags = [$tags];
+ }
+ foreach ($tags as $tag) {
+ if (!\is_string($tag) && !$tag instanceof \Stringable) {
+ throw new InvalidArgumentException(\sprintf('Cache tag must be string or object that implements __toString(), "%s" given.', get_debug_type($tag)));
+ }
+ $tag = (string) $tag;
+ if (isset($this->newMetadata[self::METADATA_TAGS][$tag])) {
+ continue;
+ }
+ if ('' === $tag) {
+ throw new InvalidArgumentException('Cache tag length must be greater than zero.');
+ }
+ if (false !== strpbrk($tag, self::RESERVED_CHARACTERS)) {
+ throw new InvalidArgumentException(\sprintf('Cache tag "%s" contains reserved characters "%s".', $tag, self::RESERVED_CHARACTERS));
+ }
+ $this->newMetadata[self::METADATA_TAGS][$tag] = $tag;
+ }
+
+ return $this;
+ }
+
+ public function getMetadata(): array
+ {
+ return $this->metadata;
+ }
+
+ /**
+ * Validates a cache key according to PSR-6.
+ *
+ * @param mixed $key The key to validate
+ *
+ * @throws InvalidArgumentException When $key is not valid
+ */
+ public static function validateKey($key): string
+ {
+ if (!\is_string($key)) {
+ throw new InvalidArgumentException(\sprintf('Cache key must be string, "%s" given.', get_debug_type($key)));
+ }
+ if ('' === $key) {
+ throw new InvalidArgumentException('Cache key length must be greater than zero.');
+ }
+ if (false !== strpbrk($key, self::RESERVED_CHARACTERS)) {
+ throw new InvalidArgumentException(\sprintf('Cache key "%s" contains reserved characters "%s".', $key, self::RESERVED_CHARACTERS));
+ }
+
+ return $key;
+ }
+
+ /**
+ * Internal logging helper.
+ *
+ * @internal
+ */
+ public static function log(?LoggerInterface $logger, string $message, array $context = []): void
+ {
+ if ($logger) {
+ $logger->warning($message, $context);
+ } else {
+ $replace = [];
+ foreach ($context as $k => $v) {
+ if (\is_scalar($v)) {
+ $replace['{'.$k.'}'] = $v;
+ }
+ }
+ @trigger_error(strtr($message, $replace), \E_USER_WARNING);
+ }
+ }
+
+ private function pack(): mixed
+ {
+ if (!$m = $this->newMetadata) {
+ return $this->value;
+ }
+ $valueWrapper = self::VALUE_WRAPPER;
+
+ return new $valueWrapper($this->value, $m + ['expiry' => $this->expiry]);
+ }
+
+ private function unpack(): bool
+ {
+ $v = $this->value;
+ $valueWrapper = self::VALUE_WRAPPER;
+
+ if ($v instanceof $valueWrapper) {
+ $this->value = $v->value;
+ $this->metadata = $v->metadata;
+
+ return true;
+ }
+
+ if (!\is_array($v) || 1 !== \count($v) || 10 !== \strlen($k = (string) array_key_first($v)) || "\x9D" !== $k[0] || "\0" !== $k[5] || "\x5F" !== $k[9]) {
+ return false;
+ }
+
+ // BC with pools populated before v6.1
+ $this->value = $v[$k];
+ $this->metadata = unpack('Vexpiry/Nctime', substr($k, 1, -1));
+ $this->metadata['expiry'] += self::METADATA_EXPIRY_OFFSET;
+
+ return true;
+ }
+}
+
+// @php-cs-fixer-ignore protected_to_private Friend-level scope access relies on protected properties
diff --git a/symfony/cache/DataCollector/CacheDataCollector.php b/symfony/cache/DataCollector/CacheDataCollector.php
new file mode 100644
index 0000000000000000000000000000000000000000..73886cb4d712c688354e12fe2f0cf7cdc5cc2a14
--- /dev/null
+++ b/symfony/cache/DataCollector/CacheDataCollector.php
@@ -0,0 +1,187 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\DataCollector;
+
+use Symfony\Component\Cache\Adapter\TraceableAdapter;
+use Symfony\Component\Cache\Adapter\TraceableAdapterEvent;
+use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpFoundation\Response;
+use Symfony\Component\HttpKernel\DataCollector\DataCollector;
+use Symfony\Component\HttpKernel\DataCollector\LateDataCollectorInterface;
+
+/**
+ * @author Aaron Scherer
+ * @author Tobias Nyholm
+ *
+ * @final
+ */
+class CacheDataCollector extends DataCollector implements LateDataCollectorInterface
+{
+ /**
+ * @var TraceableAdapter[]
+ */
+ private array $instances = [];
+
+ public function addInstance(string $name, TraceableAdapter $instance): void
+ {
+ $this->instances[$name] = $instance;
+ }
+
+ public function collect(Request $request, Response $response, ?\Throwable $exception = null): void
+ {
+ $this->lateCollect();
+ }
+
+ public function reset(): void
+ {
+ $this->data = [];
+ foreach ($this->instances as $instance) {
+ $instance->clearCalls();
+ }
+ }
+
+ public function lateCollect(): void
+ {
+ $empty = ['calls' => [], 'adapters' => [], 'config' => [], 'options' => [], 'statistics' => []];
+ $this->data = ['instances' => $empty, 'total' => $empty];
+ foreach ($this->instances as $name => $instance) {
+ $this->data['instances']['calls'][$name] = $instance->getCalls();
+ $this->data['instances']['adapters'][$name] = get_debug_type($instance->getPool());
+ }
+
+ $this->data['instances']['statistics'] = $this->calculateStatistics();
+ $this->data['total']['statistics'] = $this->calculateTotalStatistics();
+ $this->data['instances']['calls'] = $this->cloneVar($this->data['instances']['calls']);
+ }
+
+ public function getName(): string
+ {
+ return 'cache';
+ }
+
+ /**
+ * Method returns amount of logged Cache reads: "get" calls.
+ */
+ public function getStatistics(): array
+ {
+ return $this->data['instances']['statistics'];
+ }
+
+ /**
+ * Method returns the statistic totals.
+ */
+ public function getTotals(): array
+ {
+ return $this->data['total']['statistics'];
+ }
+
+ /**
+ * Method returns all logged Cache call objects.
+ */
+ public function getCalls(): mixed
+ {
+ return $this->data['instances']['calls'];
+ }
+
+ /**
+ * Method returns all logged Cache adapter classes.
+ */
+ public function getAdapters(): array
+ {
+ return $this->data['instances']['adapters'];
+ }
+
+ private function calculateStatistics(): array
+ {
+ $statistics = [];
+ foreach ($this->data['instances']['calls'] as $name => $calls) {
+ $statistics[$name] = [
+ 'calls' => 0,
+ 'time' => 0,
+ 'reads' => 0,
+ 'writes' => 0,
+ 'deletes' => 0,
+ 'hits' => 0,
+ 'misses' => 0,
+ ];
+ /** @var TraceableAdapterEvent $call */
+ foreach ($calls as $call) {
+ ++$statistics[$name]['calls'];
+ $statistics[$name]['time'] += ($call->end ?? microtime(true)) - $call->start;
+ if ('get' === $call->name) {
+ ++$statistics[$name]['reads'];
+ if ($call->hits) {
+ ++$statistics[$name]['hits'];
+ } else {
+ ++$statistics[$name]['misses'];
+ ++$statistics[$name]['writes'];
+ }
+ } elseif ('getItem' === $call->name) {
+ ++$statistics[$name]['reads'];
+ if ($call->hits) {
+ ++$statistics[$name]['hits'];
+ } else {
+ ++$statistics[$name]['misses'];
+ }
+ } elseif ('getItems' === $call->name) {
+ $statistics[$name]['reads'] += $call->hits + $call->misses;
+ $statistics[$name]['hits'] += $call->hits;
+ $statistics[$name]['misses'] += $call->misses;
+ } elseif ('hasItem' === $call->name) {
+ ++$statistics[$name]['reads'];
+ foreach ($call->result ?? [] as $result) {
+ ++$statistics[$name][$result ? 'hits' : 'misses'];
+ }
+ } elseif ('save' === $call->name) {
+ ++$statistics[$name]['writes'];
+ } elseif ('saveDeferred' === $call->name) {
+ ++$statistics[$name]['writes'];
+ } elseif ('deleteItem' === $call->name) {
+ ++$statistics[$name]['deletes'];
+ }
+ }
+ if ($statistics[$name]['reads']) {
+ $statistics[$name]['hit_read_ratio'] = round(100 * $statistics[$name]['hits'] / $statistics[$name]['reads'], 2);
+ } else {
+ $statistics[$name]['hit_read_ratio'] = null;
+ }
+ }
+
+ return $statistics;
+ }
+
+ private function calculateTotalStatistics(): array
+ {
+ $statistics = $this->getStatistics();
+ $totals = [
+ 'calls' => 0,
+ 'time' => 0,
+ 'reads' => 0,
+ 'writes' => 0,
+ 'deletes' => 0,
+ 'hits' => 0,
+ 'misses' => 0,
+ ];
+ foreach ($statistics as $name => $values) {
+ foreach ($totals as $key => $value) {
+ $totals[$key] += $statistics[$name][$key];
+ }
+ }
+ if ($totals['reads']) {
+ $totals['hit_read_ratio'] = round(100 * $totals['hits'] / $totals['reads'], 2);
+ } else {
+ $totals['hit_read_ratio'] = null;
+ }
+
+ return $totals;
+ }
+}
diff --git a/symfony/cache/DependencyInjection/CacheCollectorPass.php b/symfony/cache/DependencyInjection/CacheCollectorPass.php
new file mode 100644
index 0000000000000000000000000000000000000000..17507f1fb04103cbca62faa0ced0c66f087c96dd
--- /dev/null
+++ b/symfony/cache/DependencyInjection/CacheCollectorPass.php
@@ -0,0 +1,78 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\DependencyInjection;
+
+use Symfony\Component\Cache\Adapter\TagAwareAdapterInterface;
+use Symfony\Component\Cache\Adapter\TraceableAdapter;
+use Symfony\Component\Cache\Adapter\TraceableTagAwareAdapter;
+use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\DependencyInjection\Definition;
+use Symfony\Component\DependencyInjection\Reference;
+
+/**
+ * Inject a data collector to all the cache services to be able to get detailed statistics.
+ *
+ * @author Tobias Nyholm
+ */
+class CacheCollectorPass implements CompilerPassInterface
+{
+ /**
+ * @return void
+ */
+ public function process(ContainerBuilder $container)
+ {
+ if (!$container->hasDefinition('data_collector.cache')) {
+ return;
+ }
+
+ foreach ($container->findTaggedServiceIds('cache.pool') as $id => $attributes) {
+ $poolName = $attributes[0]['name'] ?? $id;
+
+ $this->addToCollector($id, $poolName, $container);
+ }
+ }
+
+ private function addToCollector(string $id, string $name, ContainerBuilder $container): void
+ {
+ $definition = $container->getDefinition($id);
+ if ($definition->isAbstract()) {
+ return;
+ }
+
+ $collectorDefinition = $container->getDefinition('data_collector.cache');
+ $recorder = new Definition(is_subclass_of($definition->getClass(), TagAwareAdapterInterface::class) ? TraceableTagAwareAdapter::class : TraceableAdapter::class);
+ $recorder->setTags($definition->getTags());
+ if (!$definition->isPublic() || !$definition->isPrivate()) {
+ $recorder->setPublic($definition->isPublic());
+ }
+ $recorder->setArguments([new Reference($innerId = $id.'.recorder_inner')]);
+
+ foreach ($definition->getMethodCalls() as [$method, $args]) {
+ if ('setCallbackWrapper' !== $method || !$args[0] instanceof Definition || !($args[0]->getArguments()[2] ?? null) instanceof Definition) {
+ continue;
+ }
+ if ([new Reference($id), 'setCallbackWrapper'] == $args[0]->getArguments()[2]->getFactory()) {
+ $args[0]->getArguments()[2]->setFactory([new Reference($innerId), 'setCallbackWrapper']);
+ }
+ }
+
+ $definition->setTags([]);
+ $definition->setPublic(false);
+
+ $container->setDefinition($innerId, $definition);
+ $container->setDefinition($id, $recorder);
+
+ // Tell the collector to add the new instance
+ $collectorDefinition->addMethodCall('addInstance', [$name, new Reference($id)]);
+ }
+}
diff --git a/symfony/cache/DependencyInjection/CachePoolClearerPass.php b/symfony/cache/DependencyInjection/CachePoolClearerPass.php
new file mode 100644
index 0000000000000000000000000000000000000000..6793bea94c2e8fa3b6c5771f93722401db9b4c13
--- /dev/null
+++ b/symfony/cache/DependencyInjection/CachePoolClearerPass.php
@@ -0,0 +1,41 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\DependencyInjection;
+
+use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\DependencyInjection\Reference;
+
+/**
+ * @author Nicolas Grekas
+ */
+class CachePoolClearerPass implements CompilerPassInterface
+{
+ /**
+ * @return void
+ */
+ public function process(ContainerBuilder $container)
+ {
+ $container->getParameterBag()->remove('cache.prefix.seed');
+
+ foreach ($container->findTaggedServiceIds('cache.pool.clearer') as $id => $attr) {
+ $clearer = $container->getDefinition($id);
+ $pools = [];
+ foreach ($clearer->getArgument(0) as $name => $ref) {
+ if ($container->hasDefinition($ref)) {
+ $pools[$name] = new Reference($ref);
+ }
+ }
+ $clearer->replaceArgument(0, $pools);
+ }
+ }
+}
diff --git a/symfony/cache/DependencyInjection/CachePoolPass.php b/symfony/cache/DependencyInjection/CachePoolPass.php
new file mode 100644
index 0000000000000000000000000000000000000000..9d2273d905a9bd11d1ec3d593c95bd15778b2ca4
--- /dev/null
+++ b/symfony/cache/DependencyInjection/CachePoolPass.php
@@ -0,0 +1,255 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\DependencyInjection;
+
+use Symfony\Component\Cache\Adapter\AbstractAdapter;
+use Symfony\Component\Cache\Adapter\ArrayAdapter;
+use Symfony\Component\Cache\Adapter\ChainAdapter;
+use Symfony\Component\Cache\Adapter\NullAdapter;
+use Symfony\Component\Cache\Adapter\ParameterNormalizer;
+use Symfony\Component\Cache\Adapter\TagAwareAdapter;
+use Symfony\Component\Cache\Messenger\EarlyExpirationDispatcher;
+use Symfony\Component\Cache\PruneableInterface;
+use Symfony\Component\DependencyInjection\ChildDefinition;
+use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\DependencyInjection\Definition;
+use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
+use Symfony\Component\DependencyInjection\Reference;
+
+/**
+ * @author Nicolas Grekas
+ */
+class CachePoolPass implements CompilerPassInterface
+{
+ /**
+ * @return void
+ */
+ public function process(ContainerBuilder $container)
+ {
+ if ($container->hasParameter('cache.prefix.seed')) {
+ $seed = $container->getParameterBag()->resolveValue($container->getParameter('cache.prefix.seed'));
+ } else {
+ $seed = '_'.$container->getParameter('kernel.project_dir');
+ $seed .= '.'.$container->getParameter('kernel.container_class');
+ }
+
+ $needsMessageHandler = false;
+ $allPools = [];
+ $clearers = [];
+ $attributes = [
+ 'provider',
+ 'name',
+ 'namespace',
+ 'default_lifetime',
+ 'early_expiration_message_bus',
+ 'reset',
+ 'pruneable',
+ ];
+ foreach ($container->findTaggedServiceIds('cache.pool') as $id => $tags) {
+ $adapter = $pool = $container->getDefinition($id);
+ if ($pool->isAbstract()) {
+ continue;
+ }
+ $class = $adapter->getClass();
+ $providers = $adapter->getArguments();
+ while ($adapter instanceof ChildDefinition) {
+ $adapter = $container->findDefinition($adapter->getParent());
+ $class = $class ?: $adapter->getClass();
+ $providers += $adapter->getArguments();
+ if ($t = $adapter->getTag('cache.pool')) {
+ $tags[0] += $t[0];
+ }
+ }
+ $name = $tags[0]['name'] ?? $id;
+ if (!isset($tags[0]['namespace'])) {
+ $namespaceSeed = $seed;
+ if (null !== $class) {
+ $namespaceSeed .= '.'.$class;
+ }
+
+ $tags[0]['namespace'] = $this->getNamespace($namespaceSeed, $name);
+ }
+ if (isset($tags[0]['clearer'])) {
+ $clearer = $tags[0]['clearer'];
+ while ($container->hasAlias($clearer)) {
+ $clearer = (string) $container->getAlias($clearer);
+ }
+ } else {
+ $clearer = null;
+ }
+ unset($tags[0]['clearer'], $tags[0]['name']);
+
+ if (isset($tags[0]['provider'])) {
+ $tags[0]['provider'] = new Reference(static::getServiceProvider($container, $tags[0]['provider']));
+ }
+
+ $pruneable = $tags[0]['pruneable'] ?? $container->getReflectionClass($class, false)?->implementsInterface(PruneableInterface::class) ?? false;
+
+ if (ChainAdapter::class === $class) {
+ $adapters = [];
+ foreach ($providers['index_0'] ?? $providers[0] as $provider => $adapter) {
+ if ($adapter instanceof ChildDefinition) {
+ $chainedPool = clone $adapter;
+ } else {
+ $chainedPool = $adapter = new ChildDefinition($adapter);
+ }
+
+ $chainedTags = [\is_int($provider) ? [] : ['provider' => $provider]];
+ $chainedClass = '';
+
+ while ($adapter instanceof ChildDefinition) {
+ $adapter = $container->findDefinition($adapter->getParent());
+ $chainedClass = $chainedClass ?: $adapter->getClass();
+ if ($t = $adapter->getTag('cache.pool')) {
+ $chainedTags[0] += $t[0];
+ }
+ }
+
+ if (ChainAdapter::class === $chainedClass) {
+ throw new InvalidArgumentException(\sprintf('Invalid service "%s": chain of adapters cannot reference another chain, found "%s".', $id, $chainedPool->getParent()));
+ }
+
+ $i = 0;
+
+ if (isset($chainedTags[0]['provider'])) {
+ $chainedPool->replaceArgument($i++, new Reference(static::getServiceProvider($container, $chainedTags[0]['provider'])));
+ }
+
+ if (isset($tags[0]['namespace']) && !\in_array($adapter->getClass(), [ArrayAdapter::class, NullAdapter::class], true)) {
+ $chainedPool->replaceArgument($i++, $tags[0]['namespace']);
+ }
+
+ if (isset($tags[0]['default_lifetime'])) {
+ $chainedPool->replaceArgument($i++, $tags[0]['default_lifetime']);
+ }
+
+ $adapters[] = $chainedPool;
+ }
+
+ $pool->replaceArgument(0, $adapters);
+ unset($tags[0]['provider'], $tags[0]['namespace']);
+ $i = 1;
+ } else {
+ $i = 0;
+ }
+
+ foreach ($attributes as $attr) {
+ if (!isset($tags[0][$attr])) {
+ // no-op
+ } elseif ('reset' === $attr) {
+ if ($tags[0][$attr]) {
+ $pool->addTag('kernel.reset', ['method' => $tags[0][$attr]]);
+ }
+ } elseif ('early_expiration_message_bus' === $attr) {
+ $needsMessageHandler = true;
+ $pool->addMethodCall('setCallbackWrapper', [(new Definition(EarlyExpirationDispatcher::class))
+ ->addArgument(new Reference($tags[0]['early_expiration_message_bus']))
+ ->addArgument(new Reference('reverse_container'))
+ ->addArgument((new Definition('callable'))
+ ->setFactory([new Reference($id), 'setCallbackWrapper'])
+ ->addArgument(null)
+ ),
+ ]);
+ $pool->addTag('container.reversible');
+ } elseif ('pruneable' === $attr) {
+ // no-op
+ } elseif ('namespace' !== $attr || !\in_array($class, [ArrayAdapter::class, NullAdapter::class, TagAwareAdapter::class], true)) {
+ $argument = $tags[0][$attr];
+
+ if ('default_lifetime' === $attr && !is_numeric($argument)) {
+ $argument = (new Definition('int', [$argument]))
+ ->setFactory([ParameterNormalizer::class, 'normalizeDuration']);
+ }
+
+ $pool->replaceArgument($i++, $argument);
+ }
+ unset($tags[0][$attr]);
+ }
+ if (!empty($tags[0])) {
+ throw new InvalidArgumentException(\sprintf('Invalid "cache.pool" tag for service "%s": accepted attributes are "clearer", "provider", "name", "namespace", "default_lifetime", "early_expiration_message_bus", "reset" and "pruneable", found "%s".', $id, implode('", "', array_keys($tags[0]))));
+ }
+
+ if (null !== $clearer) {
+ $clearers[$clearer][$name] = new Reference($id, $container::IGNORE_ON_UNINITIALIZED_REFERENCE);
+ }
+
+ $poolTags = $pool->getTags();
+ $poolTags['cache.pool'][0]['pruneable'] ??= $pruneable;
+ $pool->setTags($poolTags);
+
+ $allPools[$name] = new Reference($id, $container::IGNORE_ON_UNINITIALIZED_REFERENCE);
+ }
+
+ if (!$needsMessageHandler) {
+ $container->removeDefinition('cache.early_expiration_handler');
+ }
+
+ $notAliasedCacheClearerId = 'cache.global_clearer';
+ while ($container->hasAlias($notAliasedCacheClearerId)) {
+ $notAliasedCacheClearerId = (string) $container->getAlias($notAliasedCacheClearerId);
+ }
+ if ($container->hasDefinition($notAliasedCacheClearerId)) {
+ $clearers[$notAliasedCacheClearerId] = $allPools;
+ }
+
+ foreach ($clearers as $id => $pools) {
+ $clearer = $container->getDefinition($id);
+ if ($clearer instanceof ChildDefinition) {
+ $clearer->replaceArgument(0, $pools);
+ } else {
+ $clearer->setArgument(0, $pools);
+ }
+ $clearer->addTag('cache.pool.clearer');
+ }
+
+ $allPoolsKeys = array_keys($allPools);
+
+ if ($container->hasDefinition('console.command.cache_pool_list')) {
+ $container->getDefinition('console.command.cache_pool_list')->replaceArgument(0, $allPoolsKeys);
+ }
+
+ if ($container->hasDefinition('console.command.cache_pool_clear')) {
+ $container->getDefinition('console.command.cache_pool_clear')->addArgument($allPoolsKeys);
+ }
+
+ if ($container->hasDefinition('console.command.cache_pool_delete')) {
+ $container->getDefinition('console.command.cache_pool_delete')->addArgument($allPoolsKeys);
+ }
+ }
+
+ private function getNamespace(string $seed, string $id): string
+ {
+ return substr(str_replace('/', '-', base64_encode(hash('sha256', $id.$seed, true))), 0, 10);
+ }
+
+ /**
+ * @internal
+ */
+ public static function getServiceProvider(ContainerBuilder $container, string $name): string
+ {
+ $container->resolveEnvPlaceholders($name, null, $usedEnvs);
+
+ if ($usedEnvs || preg_match('#^[a-z]++:#', $name)) {
+ $dsn = $name;
+
+ if (!$container->hasDefinition($name = '.cache_connection.'.ContainerBuilder::hash($dsn))) {
+ $definition = new Definition(AbstractAdapter::class);
+ $definition->setFactory([AbstractAdapter::class, 'createConnection']);
+ $definition->setArguments([$dsn, ['lazy' => true]]);
+ $container->setDefinition($name, $definition);
+ }
+ }
+
+ return $name;
+ }
+}
diff --git a/symfony/cache/DependencyInjection/CachePoolPrunerPass.php b/symfony/cache/DependencyInjection/CachePoolPrunerPass.php
new file mode 100644
index 0000000000000000000000000000000000000000..8700231414dbb5e3c5b7d7b75b934e59d42a2929
--- /dev/null
+++ b/symfony/cache/DependencyInjection/CachePoolPrunerPass.php
@@ -0,0 +1,44 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\DependencyInjection;
+
+use Symfony\Component\Cache\PruneableInterface;
+use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
+use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\DependencyInjection\Reference;
+
+/**
+ * @author Rob Frawley 2nd
+ */
+class CachePoolPrunerPass implements CompilerPassInterface
+{
+ /**
+ * @return void
+ */
+ public function process(ContainerBuilder $container)
+ {
+ if (!$container->hasDefinition('console.command.cache_pool_prune')) {
+ return;
+ }
+
+ $services = [];
+
+ foreach ($container->findTaggedServiceIds('cache.pool') as $id => $tags) {
+ if ($tags[0]['pruneable'] ?? $container->getReflectionClass($container->getDefinition($id)->getClass(), false)?->implementsInterface(PruneableInterface::class) ?? false) {
+ $services[$tags[0]['name'] ?? $id] = new Reference($id);
+ }
+ }
+
+ $container->getDefinition('console.command.cache_pool_prune')->replaceArgument(0, new IteratorArgument($services));
+ }
+}
diff --git a/symfony/cache/Exception/CacheException.php b/symfony/cache/Exception/CacheException.php
new file mode 100644
index 0000000000000000000000000000000000000000..d2e975b2bc6066d29699372407541865c5e2cd74
--- /dev/null
+++ b/symfony/cache/Exception/CacheException.php
@@ -0,0 +1,25 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Exception;
+
+use Psr\Cache\CacheException as Psr6CacheInterface;
+use Psr\SimpleCache\CacheException as SimpleCacheInterface;
+
+if (interface_exists(SimpleCacheInterface::class)) {
+ class CacheException extends \Exception implements Psr6CacheInterface, SimpleCacheInterface
+ {
+ }
+} else {
+ class CacheException extends \Exception implements Psr6CacheInterface
+ {
+ }
+}
diff --git a/symfony/cache/Exception/InvalidArgumentException.php b/symfony/cache/Exception/InvalidArgumentException.php
new file mode 100644
index 0000000000000000000000000000000000000000..7f9584a2643281302c539c764ef7db071bb54d9c
--- /dev/null
+++ b/symfony/cache/Exception/InvalidArgumentException.php
@@ -0,0 +1,25 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Exception;
+
+use Psr\Cache\InvalidArgumentException as Psr6CacheInterface;
+use Psr\SimpleCache\InvalidArgumentException as SimpleCacheInterface;
+
+if (interface_exists(SimpleCacheInterface::class)) {
+ class InvalidArgumentException extends \InvalidArgumentException implements Psr6CacheInterface, SimpleCacheInterface
+ {
+ }
+} else {
+ class InvalidArgumentException extends \InvalidArgumentException implements Psr6CacheInterface
+ {
+ }
+}
diff --git a/symfony/cache/Exception/LogicException.php b/symfony/cache/Exception/LogicException.php
new file mode 100644
index 0000000000000000000000000000000000000000..9ffa7ed69566b61fd310ca03616e75cf4b18d506
--- /dev/null
+++ b/symfony/cache/Exception/LogicException.php
@@ -0,0 +1,25 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Exception;
+
+use Psr\Cache\CacheException as Psr6CacheInterface;
+use Psr\SimpleCache\CacheException as SimpleCacheInterface;
+
+if (interface_exists(SimpleCacheInterface::class)) {
+ class LogicException extends \LogicException implements Psr6CacheInterface, SimpleCacheInterface
+ {
+ }
+} else {
+ class LogicException extends \LogicException implements Psr6CacheInterface
+ {
+ }
+}
diff --git a/symfony/cache/LICENSE b/symfony/cache/LICENSE
new file mode 100644
index 0000000000000000000000000000000000000000..0223acd4a01f47e52df4bb6ccd83a9a0a1b843c3
--- /dev/null
+++ b/symfony/cache/LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2016-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.
diff --git a/symfony/cache/LockRegistry.php b/symfony/cache/LockRegistry.php
new file mode 100644
index 0000000000000000000000000000000000000000..31ec51ced988ca0917edffdbbd8bcd1de81f4f76
--- /dev/null
+++ b/symfony/cache/LockRegistry.php
@@ -0,0 +1,171 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache;
+
+use Psr\Log\LoggerInterface;
+use Symfony\Contracts\Cache\CacheInterface;
+use Symfony\Contracts\Cache\ItemInterface;
+
+/**
+ * LockRegistry is used internally by existing adapters to protect against cache stampede.
+ *
+ * It does so by wrapping the computation of items in a pool of locks.
+ * Foreach each apps, there can be at most 20 concurrent processes that
+ * compute items at the same time and only one per cache-key.
+ *
+ * @author Nicolas Grekas
+ */
+final class LockRegistry
+{
+ private static array $openedFiles = [];
+ private static ?array $lockedFiles = null;
+ private static \Exception $signalingException;
+ private static \Closure $signalingCallback;
+
+ /**
+ * The number of items in this list controls the max number of concurrent processes.
+ */
+ private static array $files = [
+ __DIR__.\DIRECTORY_SEPARATOR.'Adapter'.\DIRECTORY_SEPARATOR.'AbstractAdapter.php',
+ __DIR__.\DIRECTORY_SEPARATOR.'Adapter'.\DIRECTORY_SEPARATOR.'AbstractTagAwareAdapter.php',
+ __DIR__.\DIRECTORY_SEPARATOR.'Adapter'.\DIRECTORY_SEPARATOR.'AdapterInterface.php',
+ __DIR__.\DIRECTORY_SEPARATOR.'Adapter'.\DIRECTORY_SEPARATOR.'ApcuAdapter.php',
+ __DIR__.\DIRECTORY_SEPARATOR.'Adapter'.\DIRECTORY_SEPARATOR.'ArrayAdapter.php',
+ __DIR__.\DIRECTORY_SEPARATOR.'Adapter'.\DIRECTORY_SEPARATOR.'ChainAdapter.php',
+ __DIR__.\DIRECTORY_SEPARATOR.'Adapter'.\DIRECTORY_SEPARATOR.'CouchbaseBucketAdapter.php',
+ __DIR__.\DIRECTORY_SEPARATOR.'Adapter'.\DIRECTORY_SEPARATOR.'CouchbaseCollectionAdapter.php',
+ __DIR__.\DIRECTORY_SEPARATOR.'Adapter'.\DIRECTORY_SEPARATOR.'DoctrineDbalAdapter.php',
+ __DIR__.\DIRECTORY_SEPARATOR.'Adapter'.\DIRECTORY_SEPARATOR.'FilesystemAdapter.php',
+ __DIR__.\DIRECTORY_SEPARATOR.'Adapter'.\DIRECTORY_SEPARATOR.'FilesystemTagAwareAdapter.php',
+ __DIR__.\DIRECTORY_SEPARATOR.'Adapter'.\DIRECTORY_SEPARATOR.'MemcachedAdapter.php',
+ __DIR__.\DIRECTORY_SEPARATOR.'Adapter'.\DIRECTORY_SEPARATOR.'NullAdapter.php',
+ __DIR__.\DIRECTORY_SEPARATOR.'Adapter'.\DIRECTORY_SEPARATOR.'ParameterNormalizer.php',
+ __DIR__.\DIRECTORY_SEPARATOR.'Adapter'.\DIRECTORY_SEPARATOR.'PdoAdapter.php',
+ __DIR__.\DIRECTORY_SEPARATOR.'Adapter'.\DIRECTORY_SEPARATOR.'PhpArrayAdapter.php',
+ __DIR__.\DIRECTORY_SEPARATOR.'Adapter'.\DIRECTORY_SEPARATOR.'PhpFilesAdapter.php',
+ __DIR__.\DIRECTORY_SEPARATOR.'Adapter'.\DIRECTORY_SEPARATOR.'ProxyAdapter.php',
+ __DIR__.\DIRECTORY_SEPARATOR.'Adapter'.\DIRECTORY_SEPARATOR.'Psr16Adapter.php',
+ __DIR__.\DIRECTORY_SEPARATOR.'Adapter'.\DIRECTORY_SEPARATOR.'RedisAdapter.php',
+ __DIR__.\DIRECTORY_SEPARATOR.'Adapter'.\DIRECTORY_SEPARATOR.'RedisTagAwareAdapter.php',
+ __DIR__.\DIRECTORY_SEPARATOR.'Adapter'.\DIRECTORY_SEPARATOR.'TagAwareAdapter.php',
+ __DIR__.\DIRECTORY_SEPARATOR.'Adapter'.\DIRECTORY_SEPARATOR.'TagAwareAdapterInterface.php',
+ __DIR__.\DIRECTORY_SEPARATOR.'Adapter'.\DIRECTORY_SEPARATOR.'TraceableAdapter.php',
+ __DIR__.\DIRECTORY_SEPARATOR.'Adapter'.\DIRECTORY_SEPARATOR.'TraceableTagAwareAdapter.php',
+ ];
+
+ /**
+ * Defines a set of existing files that will be used as keys to acquire locks.
+ *
+ * @return array The previously defined set of files
+ */
+ public static function setFiles(array $files): array
+ {
+ $previousFiles = self::$files;
+ self::$files = $files;
+
+ foreach (self::$openedFiles as $file) {
+ if ($file) {
+ flock($file, \LOCK_UN);
+ fclose($file);
+ }
+ }
+ self::$openedFiles = self::$lockedFiles = [];
+
+ return $previousFiles;
+ }
+
+ public static function compute(callable $callback, ItemInterface $item, bool &$save, CacheInterface $pool, ?\Closure $setMetadata = null, ?LoggerInterface $logger = null, ?float $beta = null): mixed
+ {
+ if ('\\' === \DIRECTORY_SEPARATOR && null === self::$lockedFiles) {
+ // disable locking on Windows by default
+ self::$files = self::$lockedFiles = [];
+ }
+
+ $key = self::$files ? abs(crc32($item->getKey())) % \count(self::$files) : -1;
+
+ if ($key < 0 || self::$lockedFiles || !$lock = self::open($key)) {
+ return $callback($item, $save);
+ }
+
+ self::$signalingException ??= unserialize("O:9:\"Exception\":1:{s:16:\"\0Exception\0trace\";a:0:{}}");
+ self::$signalingCallback ??= fn () => throw self::$signalingException;
+
+ while (true) {
+ try {
+ // race to get the lock in non-blocking mode
+ $locked = flock($lock, \LOCK_EX | \LOCK_NB, $wouldBlock);
+
+ if ($locked || !$wouldBlock) {
+ $logger?->info(\sprintf('Lock %s, now computing item "{key}"', $locked ? 'acquired' : 'not supported'), ['key' => $item->getKey()]);
+ self::$lockedFiles[$key] = true;
+
+ $value = $callback($item, $save);
+
+ if ($save) {
+ if ($setMetadata) {
+ $setMetadata($item);
+ }
+
+ $pool->save($item->set($value));
+ $save = false;
+ }
+
+ return $value;
+ }
+ // if we failed the race, retry locking in blocking mode to wait for the winner
+ $logger?->info('Item "{key}" is locked, waiting for it to be released', ['key' => $item->getKey()]);
+ flock($lock, \LOCK_SH);
+
+ if (\INF === $beta) {
+ $logger?->info('Force-recomputing item "{key}"', ['key' => $item->getKey()]);
+ continue;
+ }
+ } finally {
+ flock($lock, \LOCK_UN);
+ unset(self::$lockedFiles[$key]);
+ }
+
+ try {
+ $value = $pool->get($item->getKey(), self::$signalingCallback, 0);
+ $logger?->info('Item "{key}" retrieved after lock was released', ['key' => $item->getKey()]);
+ $save = false;
+
+ return $value;
+ } catch (\Exception $e) {
+ if (self::$signalingException !== $e) {
+ throw $e;
+ }
+ $logger?->info('Item "{key}" not found while lock was released, now retrying', ['key' => $item->getKey()]);
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * @return resource|false
+ */
+ private static function open(int $key)
+ {
+ if (null !== $h = self::$openedFiles[$key] ?? null) {
+ return $h;
+ }
+ set_error_handler(static fn () => null);
+ try {
+ $h = fopen(self::$files[$key], 'r+');
+ } finally {
+ restore_error_handler();
+ }
+
+ return self::$openedFiles[$key] = $h ?: @fopen(self::$files[$key], 'r');
+ }
+}
diff --git a/symfony/cache/Marshaller/DefaultMarshaller.php b/symfony/cache/Marshaller/DefaultMarshaller.php
new file mode 100644
index 0000000000000000000000000000000000000000..34bbeb8930078a645604b64e3e1a77a11b6d4e76
--- /dev/null
+++ b/symfony/cache/Marshaller/DefaultMarshaller.php
@@ -0,0 +1,98 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Marshaller;
+
+use Symfony\Component\Cache\Exception\CacheException;
+
+/**
+ * Serializes/unserializes values using igbinary_serialize() if available, serialize() otherwise.
+ *
+ * @author Nicolas Grekas
+ */
+class DefaultMarshaller implements MarshallerInterface
+{
+ private bool $useIgbinarySerialize = true;
+ private bool $throwOnSerializationFailure = false;
+
+ public function __construct(?bool $useIgbinarySerialize = null, bool $throwOnSerializationFailure = false)
+ {
+ if (null === $useIgbinarySerialize) {
+ $useIgbinarySerialize = \extension_loaded('igbinary') && version_compare('3.1.6', phpversion('igbinary'), '<=');
+ } elseif ($useIgbinarySerialize && (!\extension_loaded('igbinary') || version_compare('3.1.6', phpversion('igbinary'), '>'))) {
+ throw new CacheException(\extension_loaded('igbinary') ? 'Please upgrade the "igbinary" PHP extension to v3.1.6 or higher.' : 'The "igbinary" PHP extension is not loaded.');
+ }
+ $this->useIgbinarySerialize = $useIgbinarySerialize;
+ $this->throwOnSerializationFailure = $throwOnSerializationFailure;
+ }
+
+ public function marshall(array $values, ?array &$failed): array
+ {
+ $serialized = $failed = [];
+
+ foreach ($values as $id => $value) {
+ try {
+ if ($this->useIgbinarySerialize) {
+ $serialized[$id] = igbinary_serialize($value);
+ } else {
+ $serialized[$id] = serialize($value);
+ }
+ } catch (\Exception $e) {
+ if ($this->throwOnSerializationFailure) {
+ throw new \ValueError($e->getMessage(), 0, $e);
+ }
+ $failed[] = $id;
+ }
+ }
+
+ return $serialized;
+ }
+
+ public function unmarshall(string $value): mixed
+ {
+ if ('b:0;' === $value) {
+ return false;
+ }
+ if ('N;' === $value) {
+ return null;
+ }
+ static $igbinaryNull;
+ if ($value === $igbinaryNull ??= \extension_loaded('igbinary') ? igbinary_serialize(null) : false) {
+ return null;
+ }
+ $unserializeCallbackHandler = ini_set('unserialize_callback_func', __CLASS__.'::handleUnserializeCallback');
+ try {
+ if (':' === ($value[1] ?? ':')) {
+ if (false !== $value = unserialize($value)) {
+ return $value;
+ }
+ } elseif (false === $igbinaryNull) {
+ throw new \RuntimeException('Failed to unserialize values, did you forget to install the "igbinary" extension?');
+ } elseif (null !== $value = igbinary_unserialize($value)) {
+ return $value;
+ }
+
+ throw new \DomainException(error_get_last() ? error_get_last()['message'] : 'Failed to unserialize values.');
+ } catch (\Error $e) {
+ throw new \ErrorException($e->getMessage(), $e->getCode(), \E_ERROR, $e->getFile(), $e->getLine());
+ } finally {
+ ini_set('unserialize_callback_func', $unserializeCallbackHandler);
+ }
+ }
+
+ /**
+ * @internal
+ */
+ public static function handleUnserializeCallback(string $class): never
+ {
+ throw new \DomainException('Class not found: '.$class);
+ }
+}
diff --git a/symfony/cache/Marshaller/DeflateMarshaller.php b/symfony/cache/Marshaller/DeflateMarshaller.php
new file mode 100644
index 0000000000000000000000000000000000000000..35237de6884158bfe1c8b1adefa9af6f9bea9f5d
--- /dev/null
+++ b/symfony/cache/Marshaller/DeflateMarshaller.php
@@ -0,0 +1,47 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Marshaller;
+
+use Symfony\Component\Cache\Exception\CacheException;
+
+/**
+ * Compresses values using gzdeflate().
+ *
+ * @author Nicolas Grekas
+ */
+class DeflateMarshaller implements MarshallerInterface
+{
+ private MarshallerInterface $marshaller;
+
+ public function __construct(MarshallerInterface $marshaller)
+ {
+ if (!\function_exists('gzdeflate')) {
+ throw new CacheException('The "zlib" PHP extension is not loaded.');
+ }
+
+ $this->marshaller = $marshaller;
+ }
+
+ public function marshall(array $values, ?array &$failed): array
+ {
+ return array_map('gzdeflate', $this->marshaller->marshall($values, $failed));
+ }
+
+ public function unmarshall(string $value): mixed
+ {
+ if (false !== $inflatedValue = @gzinflate($value)) {
+ $value = $inflatedValue;
+ }
+
+ return $this->marshaller->unmarshall($value);
+ }
+}
diff --git a/symfony/cache/Marshaller/MarshallerInterface.php b/symfony/cache/Marshaller/MarshallerInterface.php
new file mode 100644
index 0000000000000000000000000000000000000000..5b81aad2d8582a8f251e15e549bc266ef4af0b72
--- /dev/null
+++ b/symfony/cache/Marshaller/MarshallerInterface.php
@@ -0,0 +1,38 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Marshaller;
+
+/**
+ * Serializes/unserializes PHP values.
+ *
+ * Implementations of this interface MUST deal with errors carefully. They MUST
+ * also deal with forward and backward compatibility at the storage format level.
+ *
+ * @author Nicolas Grekas
+ */
+interface MarshallerInterface
+{
+ /**
+ * Serializes a list of values.
+ *
+ * When serialization fails for a specific value, no exception should be
+ * thrown. Instead, its key should be listed in $failed.
+ */
+ public function marshall(array $values, ?array &$failed): array;
+
+ /**
+ * Unserializes a single value and throws an exception if anything goes wrong.
+ *
+ * @throws \Exception Whenever unserialization fails
+ */
+ public function unmarshall(string $value): mixed;
+}
diff --git a/symfony/cache/Marshaller/SodiumMarshaller.php b/symfony/cache/Marshaller/SodiumMarshaller.php
new file mode 100644
index 0000000000000000000000000000000000000000..49eb716a651f90ec369cfb3c0bad6de23e09620f
--- /dev/null
+++ b/symfony/cache/Marshaller/SodiumMarshaller.php
@@ -0,0 +1,74 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Marshaller;
+
+use Symfony\Component\Cache\Exception\CacheException;
+use Symfony\Component\Cache\Exception\InvalidArgumentException;
+
+/**
+ * Encrypt/decrypt values using Libsodium.
+ *
+ * @author Ahmed TAILOULOUTE
+ */
+class SodiumMarshaller implements MarshallerInterface
+{
+ private MarshallerInterface $marshaller;
+ private array $decryptionKeys;
+
+ /**
+ * @param string[] $decryptionKeys The key at index "0" is required and is used to decrypt and encrypt values;
+ * more rotating keys can be provided to decrypt values;
+ * each key must be generated using sodium_crypto_box_keypair()
+ */
+ public function __construct(array $decryptionKeys, ?MarshallerInterface $marshaller = null)
+ {
+ if (!self::isSupported()) {
+ throw new CacheException('The "sodium" PHP extension is not loaded.');
+ }
+
+ if (!isset($decryptionKeys[0])) {
+ throw new InvalidArgumentException('At least one decryption key must be provided at index "0".');
+ }
+
+ $this->marshaller = $marshaller ?? new DefaultMarshaller();
+ $this->decryptionKeys = $decryptionKeys;
+ }
+
+ public static function isSupported(): bool
+ {
+ return \function_exists('sodium_crypto_box_seal');
+ }
+
+ public function marshall(array $values, ?array &$failed): array
+ {
+ $encryptionKey = sodium_crypto_box_publickey($this->decryptionKeys[0]);
+
+ $encryptedValues = [];
+ foreach ($this->marshaller->marshall($values, $failed) as $k => $v) {
+ $encryptedValues[$k] = sodium_crypto_box_seal($v, $encryptionKey);
+ }
+
+ return $encryptedValues;
+ }
+
+ public function unmarshall(string $value): mixed
+ {
+ foreach ($this->decryptionKeys as $k) {
+ if (false !== $decryptedValue = @sodium_crypto_box_seal_open($value, $k)) {
+ $value = $decryptedValue;
+ break;
+ }
+ }
+
+ return $this->marshaller->unmarshall($value);
+ }
+}
diff --git a/symfony/cache/Marshaller/TagAwareMarshaller.php b/symfony/cache/Marshaller/TagAwareMarshaller.php
new file mode 100644
index 0000000000000000000000000000000000000000..825f32cc0e0dc6f0c5bf86f113da59930d58db72
--- /dev/null
+++ b/symfony/cache/Marshaller/TagAwareMarshaller.php
@@ -0,0 +1,83 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Marshaller;
+
+/**
+ * A marshaller optimized for data structures generated by AbstractTagAwareAdapter.
+ *
+ * @author Nicolas Grekas
+ */
+class TagAwareMarshaller implements MarshallerInterface
+{
+ private MarshallerInterface $marshaller;
+
+ public function __construct(?MarshallerInterface $marshaller = null)
+ {
+ $this->marshaller = $marshaller ?? new DefaultMarshaller();
+ }
+
+ public function marshall(array $values, ?array &$failed): array
+ {
+ $failed = $notSerialized = $serialized = [];
+
+ foreach ($values as $id => $value) {
+ if (\is_array($value) && \is_array($value['tags'] ?? null) && \array_key_exists('value', $value) && \count($value) === 2 + (\is_string($value['meta'] ?? null) && 8 === \strlen($value['meta']))) {
+ // if the value is an array with keys "tags", "value" and "meta", use a compact serialization format
+ // magic numbers in the form 9D-..-..-..-..-00-..-..-..-5F allow detecting this format quickly in unmarshall()
+
+ $v = $this->marshaller->marshall($value, $f);
+
+ if ($f) {
+ $f = [];
+ $failed[] = $id;
+ } else {
+ if ([] === $value['tags']) {
+ $v['tags'] = '';
+ }
+
+ $serialized[$id] = "\x9D".($value['meta'] ?? "\0\0\0\0\0\0\0\0").pack('N', \strlen($v['tags'])).$v['tags'].$v['value'];
+ $serialized[$id][9] = "\x5F";
+ }
+ } else {
+ // other arbitrary values are serialized using the decorated marshaller below
+ $notSerialized[$id] = $value;
+ }
+ }
+
+ if ($notSerialized) {
+ $serialized += $this->marshaller->marshall($notSerialized, $f);
+ $failed = array_merge($failed, $f);
+ }
+
+ return $serialized;
+ }
+
+ public function unmarshall(string $value): mixed
+ {
+ // detect the compact format used in marshall() using magic numbers in the form 9D-..-..-..-..-00-..-..-..-5F
+ if (13 >= \strlen($value) || "\x9D" !== $value[0] || "\0" !== $value[5] || "\x5F" !== $value[9]) {
+ return $this->marshaller->unmarshall($value);
+ }
+
+ // data consists of value, tags and metadata which we need to unpack
+ $meta = substr($value, 1, 12);
+ $meta[8] = "\0";
+ $tagLen = unpack('Nlen', $meta, 8)['len'];
+ $meta = substr($meta, 0, 8);
+
+ return [
+ 'value' => $this->marshaller->unmarshall(substr($value, 13 + $tagLen)),
+ 'tags' => $tagLen ? $this->marshaller->unmarshall(substr($value, 13, $tagLen)) : [],
+ 'meta' => "\0\0\0\0\0\0\0\0" === $meta ? null : $meta,
+ ];
+ }
+}
diff --git a/symfony/cache/Messenger/EarlyExpirationDispatcher.php b/symfony/cache/Messenger/EarlyExpirationDispatcher.php
new file mode 100644
index 0000000000000000000000000000000000000000..5c8cf8d6791ed8771c560e9e2e235094595260f1
--- /dev/null
+++ b/symfony/cache/Messenger/EarlyExpirationDispatcher.php
@@ -0,0 +1,64 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Messenger;
+
+use Psr\Log\LoggerInterface;
+use Symfony\Component\Cache\Adapter\AdapterInterface;
+use Symfony\Component\Cache\CacheItem;
+use Symfony\Component\DependencyInjection\ReverseContainer;
+use Symfony\Component\Messenger\MessageBusInterface;
+use Symfony\Component\Messenger\Stamp\HandledStamp;
+
+/**
+ * Sends the computation of cached values to a message bus.
+ */
+class EarlyExpirationDispatcher
+{
+ private MessageBusInterface $bus;
+ private ReverseContainer $reverseContainer;
+ private ?\Closure $callbackWrapper;
+
+ public function __construct(MessageBusInterface $bus, ReverseContainer $reverseContainer, ?callable $callbackWrapper = null)
+ {
+ $this->bus = $bus;
+ $this->reverseContainer = $reverseContainer;
+ $this->callbackWrapper = null === $callbackWrapper ? null : $callbackWrapper(...);
+ }
+
+ /**
+ * @return mixed
+ */
+ public function __invoke(callable $callback, CacheItem $item, bool &$save, AdapterInterface $pool, \Closure $setMetadata, ?LoggerInterface $logger = null, ?float $beta = null)
+ {
+ if (!$item->isHit() || null === $message = EarlyExpirationMessage::create($this->reverseContainer, $callback, $item, $pool)) {
+ // The item is stale or the callback cannot be reversed: we must compute the value now
+ $logger?->info('Computing item "{key}" online: '.($item->isHit() ? 'callback cannot be reversed' : 'item is stale'), ['key' => $item->getKey()]);
+
+ return null !== $this->callbackWrapper ? ($this->callbackWrapper)($callback, $item, $save, $pool, $setMetadata, $logger, $beta) : $callback($item, $save);
+ }
+
+ $envelope = $this->bus->dispatch($message);
+
+ if ($logger) {
+ if ($envelope->last(HandledStamp::class)) {
+ $logger->info('Item "{key}" was computed online', ['key' => $item->getKey()]);
+ } else {
+ $logger->info('Item "{key}" sent for recomputation', ['key' => $item->getKey()]);
+ }
+ }
+
+ // The item's value is not stale, no need to write it to the backend
+ $save = false;
+
+ return $message->getItem()->get() ?? $item->get();
+ }
+}
diff --git a/symfony/cache/Messenger/EarlyExpirationHandler.php b/symfony/cache/Messenger/EarlyExpirationHandler.php
new file mode 100644
index 0000000000000000000000000000000000000000..b7eab8064a65f6fd8dd0a5102453f3868659187e
--- /dev/null
+++ b/symfony/cache/Messenger/EarlyExpirationHandler.php
@@ -0,0 +1,85 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Messenger;
+
+use Symfony\Component\Cache\CacheItem;
+use Symfony\Component\DependencyInjection\ReverseContainer;
+use Symfony\Component\Messenger\Attribute\AsMessageHandler;
+
+/**
+ * Computes cached values sent to a message bus.
+ */
+#[AsMessageHandler]
+class EarlyExpirationHandler
+{
+ private ReverseContainer $reverseContainer;
+ private array $processedNonces = [];
+
+ public function __construct(ReverseContainer $reverseContainer)
+ {
+ $this->reverseContainer = $reverseContainer;
+ }
+
+ /**
+ * @return void
+ */
+ public function __invoke(EarlyExpirationMessage $message)
+ {
+ $item = $message->getItem();
+ $metadata = $item->getMetadata();
+ $expiry = $metadata[CacheItem::METADATA_EXPIRY] ?? 0;
+ $ctime = $metadata[CacheItem::METADATA_CTIME] ?? 0;
+
+ if ($expiry && $ctime) {
+ // skip duplicate or expired messages
+
+ $processingNonce = [$expiry, $ctime];
+ $pool = $message->getPool();
+ $key = $item->getKey();
+
+ if (($this->processedNonces[$pool][$key] ?? null) === $processingNonce) {
+ return;
+ }
+
+ if (microtime(true) >= $expiry) {
+ return;
+ }
+
+ $this->processedNonces[$pool] = [$key => $processingNonce] + ($this->processedNonces[$pool] ?? []);
+
+ if (\count($this->processedNonces[$pool]) > 100) {
+ array_pop($this->processedNonces[$pool]);
+ }
+ }
+
+ static $setMetadata;
+
+ $setMetadata ??= \Closure::bind(
+ function (CacheItem $item, float $startTime) {
+ if ($item->expiry > $endTime = microtime(true)) {
+ $item->newMetadata[CacheItem::METADATA_EXPIRY] = $item->expiry;
+ $item->newMetadata[CacheItem::METADATA_CTIME] = (int) ceil(1000 * ($endTime - $startTime));
+ }
+ },
+ null,
+ CacheItem::class
+ );
+
+ $startTime = microtime(true);
+ $pool = $message->findPool($this->reverseContainer);
+ $callback = $message->findCallback($this->reverseContainer);
+ $save = true;
+ $value = $callback($item, $save);
+ $setMetadata($item, $startTime);
+ $pool->save($item->set($value));
+ }
+}
diff --git a/symfony/cache/Messenger/EarlyExpirationMessage.php b/symfony/cache/Messenger/EarlyExpirationMessage.php
new file mode 100644
index 0000000000000000000000000000000000000000..99cca0499ea7911ec26ab6f343496f918af8db77
--- /dev/null
+++ b/symfony/cache/Messenger/EarlyExpirationMessage.php
@@ -0,0 +1,105 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Messenger;
+
+use Symfony\Component\Cache\Adapter\AdapterInterface;
+use Symfony\Component\Cache\CacheItem;
+use Symfony\Component\DependencyInjection\ReverseContainer;
+
+/**
+ * Conveys a cached value that needs to be computed.
+ */
+final class EarlyExpirationMessage
+{
+ private CacheItem $item;
+ private string $pool;
+ private string|array $callback;
+
+ public static function create(ReverseContainer $reverseContainer, callable $callback, CacheItem $item, AdapterInterface $pool): ?self
+ {
+ try {
+ $item = clone $item;
+ $item->set(null);
+ } catch (\Exception) {
+ return null;
+ }
+
+ $pool = $reverseContainer->getId($pool);
+
+ if ($callback instanceof \Closure && !str_contains(($r = new \ReflectionFunction($callback))->name, '{closure')) {
+ $callback = [$r->getClosureThis() ?? (\PHP_VERSION_ID >= 80111 ? $r->getClosureCalledClass() : $r->getClosureScopeClass())?->name, $r->name];
+ $callback[0] ?: $callback = $r->name;
+ }
+
+ if (\is_object($callback)) {
+ if (null === $id = $reverseContainer->getId($callback)) {
+ return null;
+ }
+
+ $callback = '@'.$id;
+ } elseif (!\is_array($callback)) {
+ $callback = (string) $callback;
+ } elseif (!\is_object($callback[0])) {
+ $callback = [(string) $callback[0], (string) $callback[1]];
+ } else {
+ if (null === $id = $reverseContainer->getId($callback[0])) {
+ return null;
+ }
+
+ $callback = ['@'.$id, (string) $callback[1]];
+ }
+
+ return new self($item, $pool, $callback);
+ }
+
+ public function getItem(): CacheItem
+ {
+ return $this->item;
+ }
+
+ public function getPool(): string
+ {
+ return $this->pool;
+ }
+
+ /**
+ * @return string|string[]
+ */
+ public function getCallback(): string|array
+ {
+ return $this->callback;
+ }
+
+ public function findPool(ReverseContainer $reverseContainer): AdapterInterface
+ {
+ return $reverseContainer->getService($this->pool);
+ }
+
+ public function findCallback(ReverseContainer $reverseContainer): callable
+ {
+ if (\is_string($callback = $this->callback)) {
+ return '@' === $callback[0] ? $reverseContainer->getService(substr($callback, 1)) : $callback;
+ }
+ if ('@' === $callback[0][0]) {
+ $callback[0] = $reverseContainer->getService(substr($callback[0], 1));
+ }
+
+ return $callback;
+ }
+
+ private function __construct(CacheItem $item, string $pool, string|array $callback)
+ {
+ $this->item = $item;
+ $this->pool = $pool;
+ $this->callback = $callback;
+ }
+}
diff --git a/symfony/cache/PruneableInterface.php b/symfony/cache/PruneableInterface.php
new file mode 100644
index 0000000000000000000000000000000000000000..3095c80f40c85928910a71bb4e9aa663df0a3cc6
--- /dev/null
+++ b/symfony/cache/PruneableInterface.php
@@ -0,0 +1,20 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache;
+
+/**
+ * Interface extends psr-6 and psr-16 caches to allow for pruning (deletion) of all expired cache items.
+ */
+interface PruneableInterface
+{
+ public function prune(): bool;
+}
diff --git a/symfony/cache/Psr16Cache.php b/symfony/cache/Psr16Cache.php
new file mode 100644
index 0000000000000000000000000000000000000000..01494d71421ef1179c487bf9af97bcf6e93d5bcb
--- /dev/null
+++ b/symfony/cache/Psr16Cache.php
@@ -0,0 +1,240 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache;
+
+use Psr\Cache\CacheException as Psr6CacheException;
+use Psr\Cache\CacheItemPoolInterface;
+use Psr\SimpleCache\CacheException as SimpleCacheException;
+use Psr\SimpleCache\CacheInterface;
+use Symfony\Component\Cache\Adapter\AdapterInterface;
+use Symfony\Component\Cache\Exception\InvalidArgumentException;
+use Symfony\Component\Cache\Traits\ProxyTrait;
+
+/**
+ * Turns a PSR-6 cache into a PSR-16 one.
+ *
+ * @author Nicolas Grekas
+ */
+class Psr16Cache implements CacheInterface, PruneableInterface, ResettableInterface
+{
+ use ProxyTrait;
+
+ private ?\Closure $createCacheItem = null;
+ private ?CacheItem $cacheItemPrototype = null;
+ private static \Closure $packCacheItem;
+
+ public function __construct(CacheItemPoolInterface $pool)
+ {
+ $this->pool = $pool;
+
+ if (!$pool instanceof AdapterInterface) {
+ return;
+ }
+ $cacheItemPrototype = &$this->cacheItemPrototype;
+ $createCacheItem = \Closure::bind(
+ static function ($key, $value, $allowInt = false) use (&$cacheItemPrototype) {
+ $item = clone $cacheItemPrototype;
+ $item->poolHash = $item->innerItem = null;
+ if ($allowInt && \is_int($key)) {
+ $item->key = (string) $key;
+ } else {
+ \assert('' !== CacheItem::validateKey($key));
+ $item->key = $key;
+ }
+ $item->value = $value;
+ $item->isHit = false;
+
+ return $item;
+ },
+ null,
+ CacheItem::class
+ );
+ $this->createCacheItem = function ($key, $value, $allowInt = false) use ($createCacheItem) {
+ if (null === $this->cacheItemPrototype) {
+ $this->get($allowInt && \is_int($key) ? (string) $key : $key);
+ }
+ $this->createCacheItem = $createCacheItem;
+
+ return $createCacheItem($key, null, $allowInt)->set($value);
+ };
+ self::$packCacheItem ??= \Closure::bind(
+ static function (CacheItem $item) {
+ $item->newMetadata = $item->metadata;
+
+ return $item->pack();
+ },
+ null,
+ CacheItem::class
+ );
+ }
+
+ public function get($key, $default = null): mixed
+ {
+ try {
+ $item = $this->pool->getItem($key);
+ } catch (SimpleCacheException $e) {
+ throw $e;
+ } catch (Psr6CacheException $e) {
+ throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e);
+ }
+ if (null === $this->cacheItemPrototype) {
+ $this->cacheItemPrototype = clone $item;
+ $this->cacheItemPrototype->set(null);
+ }
+
+ return $item->isHit() ? $item->get() : $default;
+ }
+
+ public function set($key, $value, $ttl = null): bool
+ {
+ try {
+ if (null !== $f = $this->createCacheItem) {
+ $item = $f($key, $value);
+ } else {
+ $item = $this->pool->getItem($key)->set($value);
+ }
+ } catch (SimpleCacheException $e) {
+ throw $e;
+ } catch (Psr6CacheException $e) {
+ throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e);
+ }
+ if (null !== $ttl) {
+ $item->expiresAfter($ttl);
+ }
+
+ return $this->pool->save($item);
+ }
+
+ public function delete($key): bool
+ {
+ try {
+ return $this->pool->deleteItem($key);
+ } catch (SimpleCacheException $e) {
+ throw $e;
+ } catch (Psr6CacheException $e) {
+ throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e);
+ }
+ }
+
+ public function clear(): bool
+ {
+ return $this->pool->clear();
+ }
+
+ public function getMultiple($keys, $default = null): iterable
+ {
+ if ($keys instanceof \Traversable) {
+ $keys = iterator_to_array($keys, false);
+ } elseif (!\is_array($keys)) {
+ throw new InvalidArgumentException(\sprintf('Cache keys must be array or Traversable, "%s" given.', get_debug_type($keys)));
+ }
+
+ try {
+ $items = $this->pool->getItems($keys);
+ } catch (SimpleCacheException $e) {
+ throw $e;
+ } catch (Psr6CacheException $e) {
+ throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e);
+ }
+ $values = [];
+
+ if (!$this->pool instanceof AdapterInterface) {
+ foreach ($items as $key => $item) {
+ $values[$key] = $item->isHit() ? $item->get() : $default;
+ }
+
+ return $values;
+ }
+
+ foreach ($items as $key => $item) {
+ $values[$key] = $item->isHit() ? (self::$packCacheItem)($item) : $default;
+ }
+
+ return $values;
+ }
+
+ public function setMultiple($values, $ttl = null): bool
+ {
+ $valuesIsArray = \is_array($values);
+ if (!$valuesIsArray && !$values instanceof \Traversable) {
+ throw new InvalidArgumentException(\sprintf('Cache values must be array or Traversable, "%s" given.', get_debug_type($values)));
+ }
+ $items = [];
+
+ try {
+ if (null !== $f = $this->createCacheItem) {
+ $valuesIsArray = false;
+ foreach ($values as $key => $value) {
+ $items[$key] = $f($key, $value, true);
+ }
+ } elseif ($valuesIsArray) {
+ $items = [];
+ foreach ($values as $key => $value) {
+ $items[] = (string) $key;
+ }
+ $items = $this->pool->getItems($items);
+ } else {
+ foreach ($values as $key => $value) {
+ if (\is_int($key)) {
+ $key = (string) $key;
+ }
+ $items[$key] = $this->pool->getItem($key)->set($value);
+ }
+ }
+ } catch (SimpleCacheException $e) {
+ throw $e;
+ } catch (Psr6CacheException $e) {
+ throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e);
+ }
+ $ok = true;
+
+ foreach ($items as $key => $item) {
+ if ($valuesIsArray) {
+ $item->set($values[$key]);
+ }
+ if (null !== $ttl) {
+ $item->expiresAfter($ttl);
+ }
+ $ok = $this->pool->saveDeferred($item) && $ok;
+ }
+
+ return $this->pool->commit() && $ok;
+ }
+
+ public function deleteMultiple($keys): bool
+ {
+ if ($keys instanceof \Traversable) {
+ $keys = iterator_to_array($keys, false);
+ } elseif (!\is_array($keys)) {
+ throw new InvalidArgumentException(\sprintf('Cache keys must be array or Traversable, "%s" given.', get_debug_type($keys)));
+ }
+
+ try {
+ return $this->pool->deleteItems($keys);
+ } catch (SimpleCacheException $e) {
+ throw $e;
+ } catch (Psr6CacheException $e) {
+ throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e);
+ }
+ }
+
+ public function has($key): bool
+ {
+ try {
+ return $this->pool->hasItem($key);
+ } catch (SimpleCacheException $e) {
+ throw $e;
+ } catch (Psr6CacheException $e) {
+ throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e);
+ }
+ }
+}
diff --git a/symfony/cache/README.md b/symfony/cache/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..c466d57883c2f0deb5eb95cf21150b07afca2c61
--- /dev/null
+++ b/symfony/cache/README.md
@@ -0,0 +1,19 @@
+Symfony PSR-6 implementation for caching
+========================================
+
+The Cache component provides extended
+[PSR-6](https://www.php-fig.org/psr/psr-6/) implementations for adding cache to
+your applications. It is designed to have a low overhead so that caching is
+fastest. It ships with adapters for the most widespread caching backends.
+It also provides a [PSR-16](https://www.php-fig.org/psr/psr-16/) adapter,
+and implementations for [symfony/cache-contracts](https://github.com/symfony/cache-contracts)'
+`CacheInterface` and `TagAwareCacheInterface`.
+
+Resources
+---------
+
+ * [Documentation](https://symfony.com/doc/current/components/cache.html)
+ * [Contributing](https://symfony.com/doc/current/contributing/index.html)
+ * [Report issues](https://github.com/symfony/symfony/issues) and
+ [send Pull Requests](https://github.com/symfony/symfony/pulls)
+ in the [main Symfony repository](https://github.com/symfony/symfony)
diff --git a/symfony/cache/ResettableInterface.php b/symfony/cache/ResettableInterface.php
new file mode 100644
index 0000000000000000000000000000000000000000..7b0a853f234d12df6f9b80b7174e9ac8a6d9da36
--- /dev/null
+++ b/symfony/cache/ResettableInterface.php
@@ -0,0 +1,21 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache;
+
+use Symfony\Contracts\Service\ResetInterface;
+
+/**
+ * Resets a pool's local state.
+ */
+interface ResettableInterface extends ResetInterface
+{
+}
diff --git a/symfony/cache/Traits/AbstractAdapterTrait.php b/symfony/cache/Traits/AbstractAdapterTrait.php
new file mode 100644
index 0000000000000000000000000000000000000000..c5b5e4a91af44f8414d54bc04a167c1647da2efd
--- /dev/null
+++ b/symfony/cache/Traits/AbstractAdapterTrait.php
@@ -0,0 +1,377 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Traits;
+
+use Psr\Cache\CacheItemInterface;
+use Psr\Log\LoggerAwareTrait;
+use Symfony\Component\Cache\CacheItem;
+use Symfony\Component\Cache\Exception\InvalidArgumentException;
+
+/**
+ * @author Nicolas Grekas
+ *
+ * @internal
+ */
+trait AbstractAdapterTrait
+{
+ use LoggerAwareTrait;
+
+ /**
+ * needs to be set by class, signature is function(string , mixed , bool ).
+ */
+ private static \Closure $createCacheItem;
+
+ /**
+ * needs to be set by class, signature is function(array , string , array <&expiredIds>).
+ */
+ private static \Closure $mergeByLifetime;
+
+ private string $namespace = '';
+ private int $defaultLifetime;
+ private string $namespaceVersion = '';
+ private bool $versioningIsEnabled = false;
+ private array $deferred = [];
+ private array $ids = [];
+
+ /**
+ * @var int|null The maximum length to enforce for identifiers or null when no limit applies
+ */
+ protected $maxIdLength;
+
+ /**
+ * Fetches several cache items.
+ *
+ * @param array $ids The cache identifiers to fetch
+ */
+ abstract protected function doFetch(array $ids): iterable;
+
+ /**
+ * Confirms if the cache contains specified cache item.
+ *
+ * @param string $id The identifier for which to check existence
+ */
+ abstract protected function doHave(string $id): bool;
+
+ /**
+ * Deletes all items in the pool.
+ *
+ * @param string $namespace The prefix used for all identifiers managed by this pool
+ */
+ abstract protected function doClear(string $namespace): bool;
+
+ /**
+ * Removes multiple items from the pool.
+ *
+ * @param array $ids An array of identifiers that should be removed from the pool
+ */
+ abstract protected function doDelete(array $ids): bool;
+
+ /**
+ * Persists several cache items immediately.
+ *
+ * @param array $values The values to cache, indexed by their cache identifier
+ * @param int $lifetime The lifetime of the cached values, 0 for persisting until manual cleaning
+ *
+ * @return array|bool The identifiers that failed to be cached or a boolean stating if caching succeeded or not
+ */
+ abstract protected function doSave(array $values, int $lifetime): array|bool;
+
+ public function hasItem(mixed $key): bool
+ {
+ $id = $this->getId($key);
+
+ if (isset($this->deferred[$key])) {
+ $this->commit();
+ }
+
+ try {
+ return $this->doHave($id);
+ } catch (\Exception $e) {
+ CacheItem::log($this->logger, 'Failed to check if key "{key}" is cached: '.$e->getMessage(), ['key' => $key, 'exception' => $e, 'cache-adapter' => get_debug_type($this)]);
+
+ return false;
+ }
+ }
+
+ public function clear(string $prefix = ''): bool
+ {
+ $this->deferred = [];
+ if ($cleared = $this->versioningIsEnabled) {
+ if ('' === $namespaceVersionToClear = $this->namespaceVersion) {
+ foreach ($this->doFetch([static::NS_SEPARATOR.$this->namespace]) as $v) {
+ $namespaceVersionToClear = $v;
+ }
+ }
+ $namespaceToClear = $this->namespace.$namespaceVersionToClear;
+ $namespaceVersion = self::formatNamespaceVersion(mt_rand());
+ try {
+ $e = $this->doSave([static::NS_SEPARATOR.$this->namespace => $namespaceVersion], 0);
+ } catch (\Exception $e) {
+ }
+ if (true !== $e && [] !== $e) {
+ $cleared = false;
+ $message = 'Failed to save the new namespace'.($e instanceof \Exception ? ': '.$e->getMessage() : '.');
+ CacheItem::log($this->logger, $message, ['exception' => $e instanceof \Exception ? $e : null, 'cache-adapter' => get_debug_type($this)]);
+ } else {
+ $this->namespaceVersion = $namespaceVersion;
+ $this->ids = [];
+ }
+ } else {
+ $namespaceToClear = $this->namespace.$prefix;
+ }
+
+ try {
+ return $this->doClear($namespaceToClear) || $cleared;
+ } catch (\Exception $e) {
+ CacheItem::log($this->logger, 'Failed to clear the cache: '.$e->getMessage(), ['exception' => $e, 'cache-adapter' => get_debug_type($this)]);
+
+ return false;
+ }
+ }
+
+ public function deleteItem(mixed $key): bool
+ {
+ return $this->deleteItems([$key]);
+ }
+
+ public function deleteItems(array $keys): bool
+ {
+ $ids = [];
+
+ foreach ($keys as $key) {
+ $ids[$key] = $this->getId($key);
+ unset($this->deferred[$key]);
+ }
+
+ try {
+ if ($this->doDelete($ids)) {
+ return true;
+ }
+ } catch (\Exception) {
+ }
+
+ $ok = true;
+
+ // When bulk-delete failed, retry each item individually
+ foreach ($ids as $key => $id) {
+ try {
+ $e = null;
+ if ($this->doDelete([$id])) {
+ continue;
+ }
+ } catch (\Exception $e) {
+ }
+ $message = 'Failed to delete key "{key}"'.($e instanceof \Exception ? ': '.$e->getMessage() : '.');
+ CacheItem::log($this->logger, $message, ['key' => $key, 'exception' => $e, 'cache-adapter' => get_debug_type($this)]);
+ $ok = false;
+ }
+
+ return $ok;
+ }
+
+ public function getItem(mixed $key): CacheItem
+ {
+ $id = $this->getId($key);
+
+ if (isset($this->deferred[$key])) {
+ $this->commit();
+ }
+
+ $isHit = false;
+ $value = null;
+
+ try {
+ foreach ($this->doFetch([$id]) as $value) {
+ $isHit = true;
+ }
+
+ return (self::$createCacheItem)($key, $value, $isHit);
+ } catch (\Exception $e) {
+ CacheItem::log($this->logger, 'Failed to fetch key "{key}": '.$e->getMessage(), ['key' => $key, 'exception' => $e, 'cache-adapter' => get_debug_type($this)]);
+ }
+
+ return (self::$createCacheItem)($key, null, false);
+ }
+
+ public function getItems(array $keys = []): iterable
+ {
+ $ids = [];
+ $commit = false;
+
+ foreach ($keys as $key) {
+ $ids[] = $this->getId($key);
+ $commit = $commit || isset($this->deferred[$key]);
+ }
+
+ if ($commit) {
+ $this->commit();
+ }
+
+ try {
+ $items = $this->doFetch($ids);
+ } catch (\Exception $e) {
+ CacheItem::log($this->logger, 'Failed to fetch items: '.$e->getMessage(), ['keys' => $keys, 'exception' => $e, 'cache-adapter' => get_debug_type($this)]);
+ $items = [];
+ }
+ $ids = array_combine($ids, $keys);
+
+ return $this->generateItems($items, $ids);
+ }
+
+ public function save(CacheItemInterface $item): bool
+ {
+ if (!$item instanceof CacheItem) {
+ return false;
+ }
+ $this->deferred[$item->getKey()] = $item;
+
+ return $this->commit();
+ }
+
+ public function saveDeferred(CacheItemInterface $item): bool
+ {
+ if (!$item instanceof CacheItem) {
+ return false;
+ }
+ $this->deferred[$item->getKey()] = $item;
+
+ return true;
+ }
+
+ /**
+ * Enables/disables versioning of items.
+ *
+ * When versioning is enabled, clearing the cache is atomic and doesn't require listing existing keys to proceed,
+ * but old keys may need garbage collection and extra round-trips to the back-end are required.
+ *
+ * Calling this method also clears the memoized namespace version and thus forces a resynchronization of it.
+ *
+ * @return bool the previous state of versioning
+ */
+ public function enableVersioning(bool $enable = true): bool
+ {
+ $wasEnabled = $this->versioningIsEnabled;
+ $this->versioningIsEnabled = $enable;
+ $this->namespaceVersion = '';
+ $this->ids = [];
+
+ return $wasEnabled;
+ }
+
+ public function reset(): void
+ {
+ if ($this->deferred) {
+ $this->commit();
+ }
+ $this->namespaceVersion = '';
+ $this->ids = [];
+ }
+
+ public function __serialize(): array
+ {
+ throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
+ }
+
+ public function __unserialize(array $data): void
+ {
+ throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
+ }
+
+ public function __destruct()
+ {
+ if ($this->deferred) {
+ $this->commit();
+ }
+ }
+
+ private function generateItems(iterable $items, array &$keys): \Generator
+ {
+ $f = self::$createCacheItem;
+
+ try {
+ foreach ($items as $id => $value) {
+ if (!isset($keys[$id])) {
+ throw new InvalidArgumentException(\sprintf('Could not match value id "%s" to keys "%s".', $id, implode('", "', $keys)));
+ }
+ $key = $keys[$id];
+ unset($keys[$id]);
+ yield $key => $f($key, $value, true);
+ }
+ } catch (\Exception $e) {
+ CacheItem::log($this->logger, 'Failed to fetch items: '.$e->getMessage(), ['keys' => array_values($keys), 'exception' => $e, 'cache-adapter' => get_debug_type($this)]);
+ }
+
+ foreach ($keys as $key) {
+ yield $key => $f($key, null, false);
+ }
+ }
+
+ /**
+ * @internal
+ */
+ protected function getId(mixed $key): string
+ {
+ if ($this->versioningIsEnabled && '' === $this->namespaceVersion) {
+ $this->ids = [];
+ $this->namespaceVersion = '1'.static::NS_SEPARATOR;
+ try {
+ foreach ($this->doFetch([static::NS_SEPARATOR.$this->namespace]) as $v) {
+ $this->namespaceVersion = $v;
+ }
+ $e = true;
+ if ('1'.static::NS_SEPARATOR === $this->namespaceVersion) {
+ $this->namespaceVersion = self::formatNamespaceVersion(time());
+ $e = $this->doSave([static::NS_SEPARATOR.$this->namespace => $this->namespaceVersion], 0);
+ }
+ } catch (\Exception $e) {
+ }
+ if (true !== $e && [] !== $e) {
+ $message = 'Failed to save the new namespace'.($e instanceof \Exception ? ': '.$e->getMessage() : '.');
+ CacheItem::log($this->logger, $message, ['exception' => $e instanceof \Exception ? $e : null, 'cache-adapter' => get_debug_type($this)]);
+ }
+ }
+
+ if (\is_string($key) && isset($this->ids[$key])) {
+ return $this->namespace.$this->namespaceVersion.$this->ids[$key];
+ }
+ \assert('' !== CacheItem::validateKey($key));
+ $this->ids[$key] = $key;
+
+ if (\count($this->ids) > 1000) {
+ $this->ids = \array_slice($this->ids, 500, null, true); // stop memory leak if there are many keys
+ }
+
+ if (null === $this->maxIdLength) {
+ return $this->namespace.$this->namespaceVersion.$key;
+ }
+ if (\strlen($id = $this->namespace.$this->namespaceVersion.$key) > $this->maxIdLength) {
+ // Use xxh128 to favor speed over security, which is not an issue here
+ $this->ids[$key] = $id = substr_replace(base64_encode(hash('xxh128', $key, true)), static::NS_SEPARATOR, -(\strlen($this->namespaceVersion) + 2));
+ $id = $this->namespace.$this->namespaceVersion.$id;
+ }
+
+ return $id;
+ }
+
+ /**
+ * @internal
+ */
+ public static function handleUnserializeCallback(string $class): never
+ {
+ throw new \DomainException('Class not found: '.$class);
+ }
+
+ private static function formatNamespaceVersion(int $value): string
+ {
+ return strtr(substr_replace(base64_encode(pack('V', $value)), static::NS_SEPARATOR, 5), '/', '_');
+ }
+}
diff --git a/symfony/cache/Traits/CachedValueInterface.php b/symfony/cache/Traits/CachedValueInterface.php
new file mode 100644
index 0000000000000000000000000000000000000000..8e95f60b07b656eacc77c781135e9228aa043ec4
--- /dev/null
+++ b/symfony/cache/Traits/CachedValueInterface.php
@@ -0,0 +1,20 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Traits;
+
+/**
+ * @internal
+ */
+interface CachedValueInterface
+{
+ public function getValue(): mixed;
+}
diff --git a/symfony/cache/Traits/ContractsTrait.php b/symfony/cache/Traits/ContractsTrait.php
new file mode 100644
index 0000000000000000000000000000000000000000..c93256ebae18ac6edd938e4558e0bc66c3e1776d
--- /dev/null
+++ b/symfony/cache/Traits/ContractsTrait.php
@@ -0,0 +1,113 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Traits;
+
+use Psr\Log\LoggerInterface;
+use Symfony\Component\Cache\Adapter\AdapterInterface;
+use Symfony\Component\Cache\CacheItem;
+use Symfony\Component\Cache\Exception\InvalidArgumentException;
+use Symfony\Component\Cache\LockRegistry;
+use Symfony\Contracts\Cache\CacheInterface;
+use Symfony\Contracts\Cache\CacheTrait;
+use Symfony\Contracts\Cache\ItemInterface;
+
+/**
+ * @author Nicolas Grekas
+ *
+ * @internal
+ */
+trait ContractsTrait
+{
+ use CacheTrait {
+ doGet as private contractsGet;
+ }
+
+ private \Closure $callbackWrapper;
+ private array $computing = [];
+
+ /**
+ * Wraps the callback passed to ->get() in a callable.
+ *
+ * @return callable the previous callback wrapper
+ */
+ public function setCallbackWrapper(?callable $callbackWrapper): callable
+ {
+ if (!isset($this->callbackWrapper)) {
+ $this->callbackWrapper = LockRegistry::compute(...);
+
+ if (\in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) {
+ $this->setCallbackWrapper(null);
+ }
+ }
+
+ if (null !== $callbackWrapper && !$callbackWrapper instanceof \Closure) {
+ $callbackWrapper = $callbackWrapper(...);
+ }
+
+ $previousWrapper = $this->callbackWrapper;
+ $this->callbackWrapper = $callbackWrapper ?? static fn (callable $callback, ItemInterface $item, bool &$save, CacheInterface $pool, \Closure $setMetadata, ?LoggerInterface $logger, ?float $beta = null) => $callback($item, $save);
+
+ return $previousWrapper;
+ }
+
+ private function doGet(AdapterInterface $pool, string $key, callable $callback, ?float $beta, ?array &$metadata = null): mixed
+ {
+ if (0 > $beta ??= 1.0) {
+ throw new InvalidArgumentException(\sprintf('Argument "$beta" provided to "%s::get()" must be a positive number, %f given.', static::class, $beta));
+ }
+
+ static $setMetadata;
+
+ $setMetadata ??= \Closure::bind(
+ static function (CacheItem $item, float $startTime, ?array &$metadata) {
+ if ($item->expiry > $endTime = microtime(true)) {
+ $item->newMetadata[CacheItem::METADATA_EXPIRY] = $metadata[CacheItem::METADATA_EXPIRY] = $item->expiry;
+ $item->newMetadata[CacheItem::METADATA_CTIME] = $metadata[CacheItem::METADATA_CTIME] = (int) ceil(1000 * ($endTime - $startTime));
+ } else {
+ unset($metadata[CacheItem::METADATA_EXPIRY], $metadata[CacheItem::METADATA_CTIME], $metadata[CacheItem::METADATA_TAGS]);
+ }
+ },
+ null,
+ CacheItem::class
+ );
+
+ $this->callbackWrapper ??= LockRegistry::compute(...);
+
+ return $this->contractsGet($pool, $key, function (CacheItem $item, bool &$save) use ($pool, $callback, $setMetadata, &$metadata, $key, $beta) {
+ // don't wrap nor save recursive calls
+ if (isset($this->computing[$key])) {
+ $value = $callback($item, $save);
+ $save = false;
+
+ return $value;
+ }
+
+ $this->computing[$key] = $key;
+ $startTime = microtime(true);
+
+ if (!isset($this->callbackWrapper)) {
+ $this->setCallbackWrapper($this->setCallbackWrapper(null));
+ }
+
+ try {
+ $value = ($this->callbackWrapper)($callback, $item, $save, $pool, function (CacheItem $item) use ($setMetadata, $startTime, &$metadata) {
+ $setMetadata($item, $startTime, $metadata);
+ }, $this->logger ?? null, $beta);
+ $setMetadata($item, $startTime, $metadata);
+
+ return $value;
+ } finally {
+ unset($this->computing[$key]);
+ }
+ }, $beta, $metadata, $this->logger ?? null);
+ }
+}
diff --git a/symfony/cache/Traits/FilesystemCommonTrait.php b/symfony/cache/Traits/FilesystemCommonTrait.php
new file mode 100644
index 0000000000000000000000000000000000000000..09e8e26fdd4357747fcf3f2c4e8a6726f5407741
--- /dev/null
+++ b/symfony/cache/Traits/FilesystemCommonTrait.php
@@ -0,0 +1,194 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Traits;
+
+use Symfony\Component\Cache\Exception\InvalidArgumentException;
+
+/**
+ * @author Nicolas Grekas
+ *
+ * @internal
+ */
+trait FilesystemCommonTrait
+{
+ private string $directory;
+ private string $tmpSuffix;
+
+ private function init(string $namespace, ?string $directory): void
+ {
+ if (!isset($directory[0])) {
+ $directory = sys_get_temp_dir().\DIRECTORY_SEPARATOR.'symfony-cache';
+ } else {
+ $directory = realpath($directory) ?: $directory;
+ }
+ if (isset($namespace[0])) {
+ if (preg_match('#[^-+_.A-Za-z0-9]#', $namespace, $match)) {
+ throw new InvalidArgumentException(\sprintf('Namespace contains "%s" but only characters in [-+_.A-Za-z0-9] are allowed.', $match[0]));
+ }
+ $directory .= \DIRECTORY_SEPARATOR.$namespace;
+ } else {
+ $directory .= \DIRECTORY_SEPARATOR.'@';
+ }
+ if (!is_dir($directory)) {
+ @mkdir($directory, 0777, true);
+ }
+ $directory .= \DIRECTORY_SEPARATOR;
+ // On Windows the whole path is limited to 258 chars
+ if ('\\' === \DIRECTORY_SEPARATOR && \strlen($directory) > 234) {
+ throw new InvalidArgumentException(\sprintf('Cache directory too long (%s).', $directory));
+ }
+
+ $this->directory = $directory;
+ }
+
+ protected function doClear(string $namespace): bool
+ {
+ $ok = true;
+
+ foreach ($this->scanHashDir($this->directory) as $file) {
+ if ('' !== $namespace && !str_starts_with($this->getFileKey($file), $namespace)) {
+ continue;
+ }
+
+ $ok = ($this->doUnlink($file) || !file_exists($file)) && $ok;
+ }
+
+ return $ok;
+ }
+
+ protected function doDelete(array $ids): bool
+ {
+ $ok = true;
+
+ foreach ($ids as $id) {
+ $file = $this->getFile($id);
+ $ok = (!is_file($file) || $this->doUnlink($file) || !file_exists($file)) && $ok;
+ }
+
+ return $ok;
+ }
+
+ /**
+ * @return bool
+ */
+ protected function doUnlink(string $file)
+ {
+ return @unlink($file);
+ }
+
+ private function write(string $file, string $data, ?int $expiresAt = null): bool
+ {
+ $unlink = false;
+ set_error_handler(static fn ($type, $message, $file, $line) => throw new \ErrorException($message, 0, $type, $file, $line));
+ try {
+ $tmp = $this->directory.$this->tmpSuffix ??= str_replace('/', '-', base64_encode(random_bytes(6)));
+ try {
+ $h = fopen($tmp, 'x');
+ } catch (\ErrorException $e) {
+ if (!str_contains($e->getMessage(), 'File exists')) {
+ throw $e;
+ }
+
+ $tmp = $this->directory.$this->tmpSuffix = str_replace('/', '-', base64_encode(random_bytes(6)));
+ $h = fopen($tmp, 'x');
+ }
+ fwrite($h, $data);
+ fclose($h);
+ $unlink = true;
+
+ if (null !== $expiresAt) {
+ touch($tmp, $expiresAt ?: time() + 31556952); // 1 year in seconds
+ }
+
+ if ('\\' === \DIRECTORY_SEPARATOR) {
+ $success = copy($tmp, $file);
+ $unlink = true;
+ } else {
+ $success = rename($tmp, $file);
+ $unlink = !$success;
+ }
+
+ return $success;
+ } finally {
+ restore_error_handler();
+
+ if ($unlink) {
+ @unlink($tmp);
+ }
+ }
+ }
+
+ private function getFile(string $id, bool $mkdir = false, ?string $directory = null): string
+ {
+ // Use xxh128 to favor speed over security, which is not an issue here
+ $hash = str_replace('/', '-', base64_encode(hash('xxh128', static::class.$id, true)));
+ $dir = ($directory ?? $this->directory).strtoupper($hash[0].\DIRECTORY_SEPARATOR.$hash[1].\DIRECTORY_SEPARATOR);
+
+ if ($mkdir && !is_dir($dir)) {
+ @mkdir($dir, 0777, true);
+ }
+
+ return $dir.substr($hash, 2, 20);
+ }
+
+ private function getFileKey(string $file): string
+ {
+ return '';
+ }
+
+ private function scanHashDir(string $directory): \Generator
+ {
+ if (!is_dir($directory)) {
+ return;
+ }
+
+ $chars = '+-ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
+
+ for ($i = 0; $i < 38; ++$i) {
+ if (!is_dir($directory.$chars[$i])) {
+ continue;
+ }
+
+ for ($j = 0; $j < 38; ++$j) {
+ if (!is_dir($dir = $directory.$chars[$i].\DIRECTORY_SEPARATOR.$chars[$j])) {
+ continue;
+ }
+
+ foreach (@scandir($dir, \SCANDIR_SORT_NONE) ?: [] as $file) {
+ if ('.' !== $file && '..' !== $file) {
+ yield $dir.\DIRECTORY_SEPARATOR.$file;
+ }
+ }
+ }
+ }
+ }
+
+ public function __serialize(): array
+ {
+ throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
+ }
+
+ public function __unserialize(array $data): void
+ {
+ throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
+ }
+
+ public function __destruct()
+ {
+ if (method_exists(parent::class, '__destruct')) {
+ parent::__destruct();
+ }
+ if (isset($this->tmpSuffix) && is_file($this->directory.$this->tmpSuffix)) {
+ unlink($this->directory.$this->tmpSuffix);
+ }
+ }
+}
diff --git a/symfony/cache/Traits/FilesystemTrait.php b/symfony/cache/Traits/FilesystemTrait.php
new file mode 100644
index 0000000000000000000000000000000000000000..05fa10e9640985c52614631426533f5bf0879302
--- /dev/null
+++ b/symfony/cache/Traits/FilesystemTrait.php
@@ -0,0 +1,113 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Traits;
+
+use Symfony\Component\Cache\Exception\CacheException;
+use Symfony\Component\Cache\Marshaller\MarshallerInterface;
+
+/**
+ * @author Nicolas Grekas
+ * @author Rob Frawley 2nd
+ *
+ * @internal
+ */
+trait FilesystemTrait
+{
+ use FilesystemCommonTrait;
+
+ private MarshallerInterface $marshaller;
+
+ public function prune(): bool
+ {
+ $time = time();
+ $pruned = true;
+
+ foreach ($this->scanHashDir($this->directory) as $file) {
+ if (!$h = @fopen($file, 'r')) {
+ continue;
+ }
+
+ if (($expiresAt = (int) fgets($h)) && $time >= $expiresAt) {
+ fclose($h);
+ $pruned = (@unlink($file) || !file_exists($file)) && $pruned;
+ } else {
+ fclose($h);
+ }
+ }
+
+ return $pruned;
+ }
+
+ protected function doFetch(array $ids): iterable
+ {
+ $values = [];
+ $now = time();
+
+ foreach ($ids as $id) {
+ $file = $this->getFile($id);
+ if (!is_file($file) || !$h = @fopen($file, 'r')) {
+ continue;
+ }
+ if (($expiresAt = (int) fgets($h)) && $now >= $expiresAt) {
+ fclose($h);
+ @unlink($file);
+ } else {
+ $i = rawurldecode(rtrim(fgets($h)));
+ $value = stream_get_contents($h);
+ fclose($h);
+ if ($i === $id) {
+ $values[$id] = $this->marshaller->unmarshall($value);
+ }
+ }
+ }
+
+ return $values;
+ }
+
+ protected function doHave(string $id): bool
+ {
+ $file = $this->getFile($id);
+
+ return is_file($file) && (@filemtime($file) > time() || $this->doFetch([$id]));
+ }
+
+ protected function doSave(array $values, int $lifetime): array|bool
+ {
+ $expiresAt = $lifetime ? (time() + $lifetime) : 0;
+ $values = $this->marshaller->marshall($values, $failed);
+
+ foreach ($values as $id => $value) {
+ if (!$this->write($this->getFile($id, true), $expiresAt."\n".rawurlencode($id)."\n".$value, $expiresAt)) {
+ $failed[] = $id;
+ }
+ }
+
+ if ($failed && !is_writable($this->directory)) {
+ throw new CacheException(\sprintf('Cache directory is not writable (%s).', $this->directory));
+ }
+
+ return $failed;
+ }
+
+ private function getFileKey(string $file): string
+ {
+ if (!$h = @fopen($file, 'r')) {
+ return '';
+ }
+
+ fgets($h); // expiry
+ $encodedKey = fgets($h);
+ fclose($h);
+
+ return rawurldecode(rtrim($encodedKey));
+ }
+}
diff --git a/symfony/cache/Traits/ProxyTrait.php b/symfony/cache/Traits/ProxyTrait.php
new file mode 100644
index 0000000000000000000000000000000000000000..ba7c11fbe173c2856e2723cc93912a831fe4bb21
--- /dev/null
+++ b/symfony/cache/Traits/ProxyTrait.php
@@ -0,0 +1,37 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Traits;
+
+use Symfony\Component\Cache\PruneableInterface;
+use Symfony\Contracts\Service\ResetInterface;
+
+/**
+ * @author Nicolas Grekas
+ *
+ * @internal
+ */
+trait ProxyTrait
+{
+ private object $pool;
+
+ public function prune(): bool
+ {
+ return $this->pool instanceof PruneableInterface && $this->pool->prune();
+ }
+
+ public function reset(): void
+ {
+ if ($this->pool instanceof ResetInterface) {
+ $this->pool->reset();
+ }
+ }
+}
diff --git a/symfony/cache/Traits/Redis5Proxy.php b/symfony/cache/Traits/Redis5Proxy.php
new file mode 100644
index 0000000000000000000000000000000000000000..0b2794ee18b4618efa194c2bfd349fd2640858b1
--- /dev/null
+++ b/symfony/cache/Traits/Redis5Proxy.php
@@ -0,0 +1,1228 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Traits;
+
+use Symfony\Component\VarExporter\LazyObjectInterface;
+use Symfony\Component\VarExporter\LazyProxyTrait;
+use Symfony\Contracts\Service\ResetInterface;
+
+// Help opcache.preload discover always-needed symbols
+class_exists(\Symfony\Component\VarExporter\Internal\Hydrator::class);
+class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectRegistry::class);
+class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectState::class);
+
+/**
+ * @internal
+ */
+class Redis5Proxy extends \Redis implements ResetInterface, LazyObjectInterface
+{
+ use LazyProxyTrait {
+ resetLazyObject as reset;
+ }
+
+ private const LAZY_OBJECT_PROPERTY_SCOPES = [];
+
+ public function __construct()
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->__construct(...\func_get_args());
+ }
+
+ public function _prefix($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->_prefix(...\func_get_args());
+ }
+
+ public function _serialize($value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->_serialize(...\func_get_args());
+ }
+
+ public function _unserialize($value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->_unserialize(...\func_get_args());
+ }
+
+ public function _pack($value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->_pack(...\func_get_args());
+ }
+
+ public function _unpack($value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->_unpack(...\func_get_args());
+ }
+
+ public function _compress($value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->_compress(...\func_get_args());
+ }
+
+ public function _uncompress($value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->_uncompress(...\func_get_args());
+ }
+
+ public function acl($subcmd, ...$args)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->acl(...\func_get_args());
+ }
+
+ public function append($key, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->append(...\func_get_args());
+ }
+
+ public function auth(#[\SensitiveParameter] $auth)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->auth(...\func_get_args());
+ }
+
+ public function bgSave()
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->bgSave(...\func_get_args());
+ }
+
+ public function bgrewriteaof()
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->bgrewriteaof(...\func_get_args());
+ }
+
+ public function bitcount($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->bitcount(...\func_get_args());
+ }
+
+ public function bitop($operation, $ret_key, $key, ...$other_keys)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->bitop(...\func_get_args());
+ }
+
+ public function bitpos($key, $bit, $start = null, $end = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->bitpos(...\func_get_args());
+ }
+
+ public function blPop($key, $timeout_or_key, ...$extra_args)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->blPop(...\func_get_args());
+ }
+
+ public function brPop($key, $timeout_or_key, ...$extra_args)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->brPop(...\func_get_args());
+ }
+
+ public function brpoplpush($src, $dst, $timeout)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->brpoplpush(...\func_get_args());
+ }
+
+ public function bzPopMax($key, $timeout_or_key, ...$extra_args)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->bzPopMax(...\func_get_args());
+ }
+
+ public function bzPopMin($key, $timeout_or_key, ...$extra_args)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->bzPopMin(...\func_get_args());
+ }
+
+ public function clearLastError()
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->clearLastError(...\func_get_args());
+ }
+
+ public function client($cmd, ...$args)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->client(...\func_get_args());
+ }
+
+ public function close()
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->close(...\func_get_args());
+ }
+
+ public function command(...$args)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->command(...\func_get_args());
+ }
+
+ public function config($cmd, $key, $value = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->config(...\func_get_args());
+ }
+
+ public function connect($host, $port = null, $timeout = null, $retry_interval = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->connect(...\func_get_args());
+ }
+
+ public function dbSize()
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->dbSize(...\func_get_args());
+ }
+
+ public function debug($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->debug(...\func_get_args());
+ }
+
+ public function decr($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->decr(...\func_get_args());
+ }
+
+ public function decrBy($key, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->decrBy(...\func_get_args());
+ }
+
+ public function del($key, ...$other_keys)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->del(...\func_get_args());
+ }
+
+ public function discard()
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->discard(...\func_get_args());
+ }
+
+ public function dump($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->dump(...\func_get_args());
+ }
+
+ public function echo($msg)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->echo(...\func_get_args());
+ }
+
+ public function eval($script, $args = null, $num_keys = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->eval(...\func_get_args());
+ }
+
+ public function evalsha($script_sha, $args = null, $num_keys = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->evalsha(...\func_get_args());
+ }
+
+ public function exec()
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->exec(...\func_get_args());
+ }
+
+ public function exists($key, ...$other_keys)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->exists(...\func_get_args());
+ }
+
+ public function expire($key, $timeout)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->expire(...\func_get_args());
+ }
+
+ public function expireAt($key, $timestamp)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->expireAt(...\func_get_args());
+ }
+
+ public function flushAll($async = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->flushAll(...\func_get_args());
+ }
+
+ public function flushDB($async = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->flushDB(...\func_get_args());
+ }
+
+ public function geoadd($key, $lng, $lat, $member, ...$other_triples)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->geoadd(...\func_get_args());
+ }
+
+ public function geodist($key, $src, $dst, $unit = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->geodist(...\func_get_args());
+ }
+
+ public function geohash($key, $member, ...$other_members)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->geohash(...\func_get_args());
+ }
+
+ public function geopos($key, $member, ...$other_members)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->geopos(...\func_get_args());
+ }
+
+ public function georadius($key, $lng, $lan, $radius, $unit, $opts = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->georadius(...\func_get_args());
+ }
+
+ public function georadius_ro($key, $lng, $lan, $radius, $unit, $opts = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->georadius_ro(...\func_get_args());
+ }
+
+ public function georadiusbymember($key, $member, $radius, $unit, $opts = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->georadiusbymember(...\func_get_args());
+ }
+
+ public function georadiusbymember_ro($key, $member, $radius, $unit, $opts = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->georadiusbymember_ro(...\func_get_args());
+ }
+
+ public function get($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->get(...\func_get_args());
+ }
+
+ public function getAuth()
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getAuth(...\func_get_args());
+ }
+
+ public function getBit($key, $offset)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getBit(...\func_get_args());
+ }
+
+ public function getDBNum()
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getDBNum(...\func_get_args());
+ }
+
+ public function getHost()
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getHost(...\func_get_args());
+ }
+
+ public function getLastError()
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getLastError(...\func_get_args());
+ }
+
+ public function getMode()
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getMode(...\func_get_args());
+ }
+
+ public function getOption($option)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getOption(...\func_get_args());
+ }
+
+ public function getPersistentID()
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getPersistentID(...\func_get_args());
+ }
+
+ public function getPort()
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getPort(...\func_get_args());
+ }
+
+ public function getRange($key, $start, $end)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getRange(...\func_get_args());
+ }
+
+ public function getReadTimeout()
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getReadTimeout(...\func_get_args());
+ }
+
+ public function getSet($key, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getSet(...\func_get_args());
+ }
+
+ public function getTimeout()
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getTimeout(...\func_get_args());
+ }
+
+ public function hDel($key, $member, ...$other_members)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hDel(...\func_get_args());
+ }
+
+ public function hExists($key, $member)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hExists(...\func_get_args());
+ }
+
+ public function hGet($key, $member)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hGet(...\func_get_args());
+ }
+
+ public function hGetAll($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hGetAll(...\func_get_args());
+ }
+
+ public function hIncrBy($key, $member, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hIncrBy(...\func_get_args());
+ }
+
+ public function hIncrByFloat($key, $member, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hIncrByFloat(...\func_get_args());
+ }
+
+ public function hKeys($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hKeys(...\func_get_args());
+ }
+
+ public function hLen($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hLen(...\func_get_args());
+ }
+
+ public function hMget($key, $keys)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hMget(...\func_get_args());
+ }
+
+ public function hMset($key, $pairs)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hMset(...\func_get_args());
+ }
+
+ public function hSet($key, $member, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hSet(...\func_get_args());
+ }
+
+ public function hSetNx($key, $member, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hSetNx(...\func_get_args());
+ }
+
+ public function hStrLen($key, $member)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hStrLen(...\func_get_args());
+ }
+
+ public function hVals($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hVals(...\func_get_args());
+ }
+
+ public function hscan($str_key, &$i_iterator, $str_pattern = null, $i_count = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hscan($str_key, $i_iterator, ...\array_slice(\func_get_args(), 2));
+ }
+
+ public function incr($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->incr(...\func_get_args());
+ }
+
+ public function incrBy($key, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->incrBy(...\func_get_args());
+ }
+
+ public function incrByFloat($key, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->incrByFloat(...\func_get_args());
+ }
+
+ public function info($option = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->info(...\func_get_args());
+ }
+
+ public function isConnected()
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->isConnected(...\func_get_args());
+ }
+
+ public function keys($pattern)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->keys(...\func_get_args());
+ }
+
+ public function lInsert($key, $position, $pivot, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lInsert(...\func_get_args());
+ }
+
+ public function lLen($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lLen(...\func_get_args());
+ }
+
+ public function lPop($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lPop(...\func_get_args());
+ }
+
+ public function lPush($key, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lPush(...\func_get_args());
+ }
+
+ public function lPushx($key, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lPushx(...\func_get_args());
+ }
+
+ public function lSet($key, $index, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lSet(...\func_get_args());
+ }
+
+ public function lastSave()
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lastSave(...\func_get_args());
+ }
+
+ public function lindex($key, $index)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lindex(...\func_get_args());
+ }
+
+ public function lrange($key, $start, $end)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lrange(...\func_get_args());
+ }
+
+ public function lrem($key, $value, $count)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lrem(...\func_get_args());
+ }
+
+ public function ltrim($key, $start, $stop)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ltrim(...\func_get_args());
+ }
+
+ public function mget($keys)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->mget(...\func_get_args());
+ }
+
+ public function migrate($host, $port, $key, $db, $timeout, $copy = null, $replace = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->migrate(...\func_get_args());
+ }
+
+ public function move($key, $dbindex)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->move(...\func_get_args());
+ }
+
+ public function mset($pairs)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->mset(...\func_get_args());
+ }
+
+ public function msetnx($pairs)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->msetnx(...\func_get_args());
+ }
+
+ public function multi($mode = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->multi(...\func_get_args());
+ }
+
+ public function object($field, $key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->object(...\func_get_args());
+ }
+
+ public function pconnect($host, $port = null, $timeout = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->pconnect(...\func_get_args());
+ }
+
+ public function persist($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->persist(...\func_get_args());
+ }
+
+ public function pexpire($key, $timestamp)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->pexpire(...\func_get_args());
+ }
+
+ public function pexpireAt($key, $timestamp)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->pexpireAt(...\func_get_args());
+ }
+
+ public function pfadd($key, $elements)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->pfadd(...\func_get_args());
+ }
+
+ public function pfcount($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->pfcount(...\func_get_args());
+ }
+
+ public function pfmerge($dstkey, $keys)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->pfmerge(...\func_get_args());
+ }
+
+ public function ping()
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ping(...\func_get_args());
+ }
+
+ public function pipeline()
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->pipeline(...\func_get_args());
+ }
+
+ public function psetex($key, $expire, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->psetex(...\func_get_args());
+ }
+
+ public function psubscribe($patterns, $callback)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->psubscribe(...\func_get_args());
+ }
+
+ public function pttl($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->pttl(...\func_get_args());
+ }
+
+ public function publish($channel, $message)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->publish(...\func_get_args());
+ }
+
+ public function pubsub($cmd, ...$args)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->pubsub(...\func_get_args());
+ }
+
+ public function punsubscribe($pattern, ...$other_patterns)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->punsubscribe(...\func_get_args());
+ }
+
+ public function rPop($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->rPop(...\func_get_args());
+ }
+
+ public function rPush($key, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->rPush(...\func_get_args());
+ }
+
+ public function rPushx($key, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->rPushx(...\func_get_args());
+ }
+
+ public function randomKey()
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->randomKey(...\func_get_args());
+ }
+
+ public function rawcommand($cmd, ...$args)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->rawcommand(...\func_get_args());
+ }
+
+ public function rename($key, $newkey)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->rename(...\func_get_args());
+ }
+
+ public function renameNx($key, $newkey)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->renameNx(...\func_get_args());
+ }
+
+ public function restore($ttl, $key, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->restore(...\func_get_args());
+ }
+
+ public function role()
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->role(...\func_get_args());
+ }
+
+ public function rpoplpush($src, $dst)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->rpoplpush(...\func_get_args());
+ }
+
+ public function sAdd($key, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sAdd(...\func_get_args());
+ }
+
+ public function sAddArray($key, $options)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sAddArray(...\func_get_args());
+ }
+
+ public function sDiff($key, ...$other_keys)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sDiff(...\func_get_args());
+ }
+
+ public function sDiffStore($dst, $key, ...$other_keys)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sDiffStore(...\func_get_args());
+ }
+
+ public function sInter($key, ...$other_keys)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sInter(...\func_get_args());
+ }
+
+ public function sInterStore($dst, $key, ...$other_keys)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sInterStore(...\func_get_args());
+ }
+
+ public function sMembers($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sMembers(...\func_get_args());
+ }
+
+ public function sMisMember($key, $member, ...$other_members)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sMisMember(...\func_get_args());
+ }
+
+ public function sMove($src, $dst, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sMove(...\func_get_args());
+ }
+
+ public function sPop($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sPop(...\func_get_args());
+ }
+
+ public function sRandMember($key, $count = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sRandMember(...\func_get_args());
+ }
+
+ public function sUnion($key, ...$other_keys)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sUnion(...\func_get_args());
+ }
+
+ public function sUnionStore($dst, $key, ...$other_keys)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sUnionStore(...\func_get_args());
+ }
+
+ public function save()
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->save(...\func_get_args());
+ }
+
+ public function scan(&$i_iterator, $str_pattern = null, $i_count = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->scan($i_iterator, ...\array_slice(\func_get_args(), 1));
+ }
+
+ public function scard($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->scard(...\func_get_args());
+ }
+
+ public function script($cmd, ...$args)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->script(...\func_get_args());
+ }
+
+ public function select($dbindex)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->select(...\func_get_args());
+ }
+
+ public function set($key, $value, $opts = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->set(...\func_get_args());
+ }
+
+ public function setBit($key, $offset, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->setBit(...\func_get_args());
+ }
+
+ public function setOption($option, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->setOption(...\func_get_args());
+ }
+
+ public function setRange($key, $offset, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->setRange(...\func_get_args());
+ }
+
+ public function setex($key, $expire, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->setex(...\func_get_args());
+ }
+
+ public function setnx($key, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->setnx(...\func_get_args());
+ }
+
+ public function sismember($key, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sismember(...\func_get_args());
+ }
+
+ public function slaveof($host = null, $port = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->slaveof(...\func_get_args());
+ }
+
+ public function slowlog($arg, $option = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->slowlog(...\func_get_args());
+ }
+
+ public function sort($key, $options = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sort(...\func_get_args());
+ }
+
+ public function sortAsc($key, $pattern = null, $get = null, $start = null, $end = null, $getList = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sortAsc(...\func_get_args());
+ }
+
+ public function sortAscAlpha($key, $pattern = null, $get = null, $start = null, $end = null, $getList = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sortAscAlpha(...\func_get_args());
+ }
+
+ public function sortDesc($key, $pattern = null, $get = null, $start = null, $end = null, $getList = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sortDesc(...\func_get_args());
+ }
+
+ public function sortDescAlpha($key, $pattern = null, $get = null, $start = null, $end = null, $getList = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sortDescAlpha(...\func_get_args());
+ }
+
+ public function srem($key, $member, ...$other_members)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->srem(...\func_get_args());
+ }
+
+ public function sscan($str_key, &$i_iterator, $str_pattern = null, $i_count = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sscan($str_key, $i_iterator, ...\array_slice(\func_get_args(), 2));
+ }
+
+ public function strlen($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->strlen(...\func_get_args());
+ }
+
+ public function subscribe($channels, $callback)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->subscribe(...\func_get_args());
+ }
+
+ public function swapdb($srcdb, $dstdb)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->swapdb(...\func_get_args());
+ }
+
+ public function time()
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->time(...\func_get_args());
+ }
+
+ public function ttl($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ttl(...\func_get_args());
+ }
+
+ public function type($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->type(...\func_get_args());
+ }
+
+ public function unlink($key, ...$other_keys)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->unlink(...\func_get_args());
+ }
+
+ public function unsubscribe($channel, ...$other_channels)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->unsubscribe(...\func_get_args());
+ }
+
+ public function unwatch()
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->unwatch(...\func_get_args());
+ }
+
+ public function wait($numslaves, $timeout)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->wait(...\func_get_args());
+ }
+
+ public function watch($key, ...$other_keys)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->watch(...\func_get_args());
+ }
+
+ public function xack($str_key, $str_group, $arr_ids)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xack(...\func_get_args());
+ }
+
+ public function xadd($str_key, $str_id, $arr_fields, $i_maxlen = null, $boo_approximate = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xadd(...\func_get_args());
+ }
+
+ public function xclaim($str_key, $str_group, $str_consumer, $i_min_idle, $arr_ids, $arr_opts = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xclaim(...\func_get_args());
+ }
+
+ public function xdel($str_key, $arr_ids)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xdel(...\func_get_args());
+ }
+
+ public function xgroup($str_operation, $str_key = null, $str_arg1 = null, $str_arg2 = null, $str_arg3 = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xgroup(...\func_get_args());
+ }
+
+ public function xinfo($str_cmd, $str_key = null, $str_group = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xinfo(...\func_get_args());
+ }
+
+ public function xlen($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xlen(...\func_get_args());
+ }
+
+ public function xpending($str_key, $str_group, $str_start = null, $str_end = null, $i_count = null, $str_consumer = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xpending(...\func_get_args());
+ }
+
+ public function xrange($str_key, $str_start, $str_end, $i_count = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xrange(...\func_get_args());
+ }
+
+ public function xread($arr_streams, $i_count = null, $i_block = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xread(...\func_get_args());
+ }
+
+ public function xreadgroup($str_group, $str_consumer, $arr_streams, $i_count = null, $i_block = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xreadgroup(...\func_get_args());
+ }
+
+ public function xrevrange($str_key, $str_start, $str_end, $i_count = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xrevrange(...\func_get_args());
+ }
+
+ public function xtrim($str_key, $i_maxlen, $boo_approximate = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xtrim(...\func_get_args());
+ }
+
+ public function zAdd($key, $score, $value, ...$extra_args)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zAdd(...\func_get_args());
+ }
+
+ public function zCard($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zCard(...\func_get_args());
+ }
+
+ public function zCount($key, $min, $max)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zCount(...\func_get_args());
+ }
+
+ public function zIncrBy($key, $value, $member)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zIncrBy(...\func_get_args());
+ }
+
+ public function zLexCount($key, $min, $max)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zLexCount(...\func_get_args());
+ }
+
+ public function zPopMax($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zPopMax(...\func_get_args());
+ }
+
+ public function zPopMin($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zPopMin(...\func_get_args());
+ }
+
+ public function zRange($key, $start, $end, $scores = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zRange(...\func_get_args());
+ }
+
+ public function zRangeByLex($key, $min, $max, $offset = null, $limit = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zRangeByLex(...\func_get_args());
+ }
+
+ public function zRangeByScore($key, $start, $end, $options = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zRangeByScore(...\func_get_args());
+ }
+
+ public function zRank($key, $member)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zRank(...\func_get_args());
+ }
+
+ public function zRem($key, $member, ...$other_members)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zRem(...\func_get_args());
+ }
+
+ public function zRemRangeByLex($key, $min, $max)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zRemRangeByLex(...\func_get_args());
+ }
+
+ public function zRemRangeByRank($key, $start, $end)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zRemRangeByRank(...\func_get_args());
+ }
+
+ public function zRemRangeByScore($key, $min, $max)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zRemRangeByScore(...\func_get_args());
+ }
+
+ public function zRevRange($key, $start, $end, $scores = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zRevRange(...\func_get_args());
+ }
+
+ public function zRevRangeByLex($key, $min, $max, $offset = null, $limit = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zRevRangeByLex(...\func_get_args());
+ }
+
+ public function zRevRangeByScore($key, $start, $end, $options = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zRevRangeByScore(...\func_get_args());
+ }
+
+ public function zRevRank($key, $member)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zRevRank(...\func_get_args());
+ }
+
+ public function zScore($key, $member)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zScore(...\func_get_args());
+ }
+
+ public function zinterstore($key, $keys, $weights = null, $aggregate = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zinterstore(...\func_get_args());
+ }
+
+ public function zscan($str_key, &$i_iterator, $str_pattern = null, $i_count = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zscan($str_key, $i_iterator, ...\array_slice(\func_get_args(), 2));
+ }
+
+ public function zunionstore($key, $keys, $weights = null, $aggregate = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zunionstore(...\func_get_args());
+ }
+
+ public function delete($key, ...$other_keys)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->delete(...\func_get_args());
+ }
+
+ public function evaluate($script, $args = null, $num_keys = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->evaluate(...\func_get_args());
+ }
+
+ public function evaluateSha($script_sha, $args = null, $num_keys = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->evaluateSha(...\func_get_args());
+ }
+
+ public function getKeys($pattern)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getKeys(...\func_get_args());
+ }
+
+ public function getMultiple($keys)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getMultiple(...\func_get_args());
+ }
+
+ public function lGet($key, $index)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lGet(...\func_get_args());
+ }
+
+ public function lGetRange($key, $start, $end)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lGetRange(...\func_get_args());
+ }
+
+ public function lRemove($key, $value, $count)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lRemove(...\func_get_args());
+ }
+
+ public function lSize($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lSize(...\func_get_args());
+ }
+
+ public function listTrim($key, $start, $stop)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->listTrim(...\func_get_args());
+ }
+
+ public function open($host, $port = null, $timeout = null, $retry_interval = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->open(...\func_get_args());
+ }
+
+ public function popen($host, $port = null, $timeout = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->popen(...\func_get_args());
+ }
+
+ public function renameKey($key, $newkey)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->renameKey(...\func_get_args());
+ }
+
+ public function sContains($key, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sContains(...\func_get_args());
+ }
+
+ public function sGetMembers($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sGetMembers(...\func_get_args());
+ }
+
+ public function sRemove($key, $member, ...$other_members)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sRemove(...\func_get_args());
+ }
+
+ public function sSize($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sSize(...\func_get_args());
+ }
+
+ public function sendEcho($msg)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sendEcho(...\func_get_args());
+ }
+
+ public function setTimeout($key, $timeout)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->setTimeout(...\func_get_args());
+ }
+
+ public function substr($key, $start, $end)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->substr(...\func_get_args());
+ }
+
+ public function zDelete($key, $member, ...$other_members)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zDelete(...\func_get_args());
+ }
+
+ public function zDeleteRangeByRank($key, $min, $max)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zDeleteRangeByRank(...\func_get_args());
+ }
+
+ public function zDeleteRangeByScore($key, $min, $max)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zDeleteRangeByScore(...\func_get_args());
+ }
+
+ public function zInter($key, $keys, $weights = null, $aggregate = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zInter(...\func_get_args());
+ }
+
+ public function zRemove($key, $member, ...$other_members)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zRemove(...\func_get_args());
+ }
+
+ public function zRemoveRangeByScore($key, $min, $max)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zRemoveRangeByScore(...\func_get_args());
+ }
+
+ public function zReverseRange($key, $start, $end, $scores = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zReverseRange(...\func_get_args());
+ }
+
+ public function zSize($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zSize(...\func_get_args());
+ }
+
+ public function zUnion($key, $keys, $weights = null, $aggregate = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zUnion(...\func_get_args());
+ }
+}
diff --git a/symfony/cache/Traits/Redis61ProxyTrait.php b/symfony/cache/Traits/Redis61ProxyTrait.php
new file mode 100644
index 0000000000000000000000000000000000000000..0ec7b57625acb430530de43bda633d5a7a108388
--- /dev/null
+++ b/symfony/cache/Traits/Redis61ProxyTrait.php
@@ -0,0 +1,81 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Traits;
+
+if (version_compare(phpversion('redis'), '6.1.0-dev', '>=')) {
+ /**
+ * @internal
+ */
+ trait Redis61ProxyTrait
+ {
+ public function dump($key): \Redis|string|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->dump(...\func_get_args());
+ }
+
+ public function hRandField($key, $options = null): \Redis|array|string|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hRandField(...\func_get_args());
+ }
+
+ public function hSet($key, ...$fields_and_vals): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hSet(...\func_get_args());
+ }
+
+ public function mget($keys): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->mget(...\func_get_args());
+ }
+
+ public function sRandMember($key, $count = 0): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sRandMember(...\func_get_args());
+ }
+
+ public function waitaof($numlocal, $numreplicas, $timeout): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->waitaof(...\func_get_args());
+ }
+ }
+} else {
+ /**
+ * @internal
+ */
+ trait Redis61ProxyTrait
+ {
+ public function dump($key): \Redis|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->dump(...\func_get_args());
+ }
+
+ public function hRandField($key, $options = null): \Redis|array|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hRandField(...\func_get_args());
+ }
+
+ public function hSet($key, $member, $value): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hSet(...\func_get_args());
+ }
+
+ public function mget($keys): \Redis|array
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->mget(...\func_get_args());
+ }
+
+ public function sRandMember($key, $count = 0): \Redis|array|false|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sRandMember(...\func_get_args());
+ }
+ }
+}
diff --git a/symfony/cache/Traits/Redis62ProxyTrait.php b/symfony/cache/Traits/Redis62ProxyTrait.php
new file mode 100644
index 0000000000000000000000000000000000000000..4ea807220e72b72e79afea48d0f550ca8524c7c6
--- /dev/null
+++ b/symfony/cache/Traits/Redis62ProxyTrait.php
@@ -0,0 +1,52 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Traits;
+
+if (version_compare(phpversion('redis'), '6.2.0', '>=')) {
+ /**
+ * @internal
+ */
+ trait Redis62ProxyTrait
+ {
+ public function expiremember($key, $field, $ttl, $unit = null): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->expiremember(...\func_get_args());
+ }
+
+ public function expirememberat($key, $field, $timestamp): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->expirememberat(...\func_get_args());
+ }
+
+ public function getWithMeta($key): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getWithMeta(...\func_get_args());
+ }
+
+ public function serverName(): false|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->serverName(...\func_get_args());
+ }
+
+ public function serverVersion(): false|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->serverVersion(...\func_get_args());
+ }
+ }
+} else {
+ /**
+ * @internal
+ */
+ trait Redis62ProxyTrait
+ {
+ }
+}
diff --git a/symfony/cache/Traits/Redis63ProxyTrait.php b/symfony/cache/Traits/Redis63ProxyTrait.php
new file mode 100644
index 0000000000000000000000000000000000000000..6f6b370173aa441e13df8cdb81490749098e6db9
--- /dev/null
+++ b/symfony/cache/Traits/Redis63ProxyTrait.php
@@ -0,0 +1,162 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Traits;
+
+if (version_compare(phpversion('redis'), '6.3.0', '>=')) {
+ /**
+ * @internal
+ */
+ trait Redis63ProxyTrait
+ {
+ public function delifeq($key, $value): \Redis|int|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->delifeq(...\func_get_args());
+ }
+
+ public function hexpire($key, $ttl, $fields, $mode = null): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hexpire(...\func_get_args());
+ }
+
+ public function hexpireat($key, $time, $fields, $mode = null): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hexpireat(...\func_get_args());
+ }
+
+ public function hexpiretime($key, $fields): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hexpiretime(...\func_get_args());
+ }
+
+ public function hgetdel($key, $fields): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hgetdel(...\func_get_args());
+ }
+
+ public function hgetex($key, $fields, $expiry = null): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hgetex(...\func_get_args());
+ }
+
+ public function hGetWithMeta($key, $member): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hGetWithMeta(...\func_get_args());
+ }
+
+ public function hpersist($key, $fields): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hpersist(...\func_get_args());
+ }
+
+ public function hpexpire($key, $ttl, $fields, $mode = null): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hpexpire(...\func_get_args());
+ }
+
+ public function hpexpireat($key, $mstime, $fields, $mode = null): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hpexpireat(...\func_get_args());
+ }
+
+ public function hpexpiretime($key, $fields): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hpexpiretime(...\func_get_args());
+ }
+
+ public function hpttl($key, $fields): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hpttl(...\func_get_args());
+ }
+
+ public function hsetex($key, $fields, $expiry = null): \Redis|int|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hsetex(...\func_get_args());
+ }
+
+ public function httl($key, $fields): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->httl(...\func_get_args());
+ }
+
+ public function vadd($key, $values, $element, $options = null): \Redis|int|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->vadd(...\func_get_args());
+ }
+
+ public function vcard($key): \Redis|int|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->vcard(...\func_get_args());
+ }
+
+ public function vdim($key): \Redis|int|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->vdim(...\func_get_args());
+ }
+
+ public function vemb($key, $member, $raw = false): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->vemb(...\func_get_args());
+ }
+
+ public function vgetattr($key, $member, $decode = true): \Redis|array|string|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->vgetattr(...\func_get_args());
+ }
+
+ public function vinfo($key): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->vinfo(...\func_get_args());
+ }
+
+ public function vismember($key, $member): \Redis|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->vismember(...\func_get_args());
+ }
+
+ public function vlinks($key, $member, $withscores = false): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->vlinks(...\func_get_args());
+ }
+
+ public function vrandmember($key, $count = 0): \Redis|array|string|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->vrandmember(...\func_get_args());
+ }
+
+ public function vrange($key, $min, $max, $count = -1): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->vrange(...\func_get_args());
+ }
+
+ public function vrem($key, $member): \Redis|int|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->vrem(...\func_get_args());
+ }
+
+ public function vsetattr($key, $member, $attributes): \Redis|int|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->vsetattr(...\func_get_args());
+ }
+
+ public function vsim($key, $member, $options = null): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->vsim(...\func_get_args());
+ }
+ }
+} else {
+ /**
+ * @internal
+ */
+ trait Redis63ProxyTrait
+ {
+ }
+}
diff --git a/symfony/cache/Traits/Redis6Proxy.php b/symfony/cache/Traits/Redis6Proxy.php
new file mode 100644
index 0000000000000000000000000000000000000000..e321fee6244ed6016136d7567ae60e5528ddec99
--- /dev/null
+++ b/symfony/cache/Traits/Redis6Proxy.php
@@ -0,0 +1,1271 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Traits;
+
+use Symfony\Component\VarExporter\LazyObjectInterface;
+use Symfony\Component\VarExporter\LazyProxyTrait;
+use Symfony\Contracts\Service\ResetInterface;
+
+// Help opcache.preload discover always-needed symbols
+class_exists(\Symfony\Component\VarExporter\Internal\Hydrator::class);
+class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectRegistry::class);
+class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectState::class);
+
+/**
+ * @internal
+ */
+class Redis6Proxy extends \Redis implements ResetInterface, LazyObjectInterface
+{
+ use Redis61ProxyTrait;
+ use Redis62ProxyTrait;
+ use Redis63ProxyTrait;
+ use LazyProxyTrait {
+ resetLazyObject as reset;
+ }
+
+ private const LAZY_OBJECT_PROPERTY_SCOPES = [];
+
+ public function __construct($options = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->__construct(...\func_get_args());
+ }
+
+ public function _compress($value): string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->_compress(...\func_get_args());
+ }
+
+ public function _uncompress($value): string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->_uncompress(...\func_get_args());
+ }
+
+ public function _prefix($key): string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->_prefix(...\func_get_args());
+ }
+
+ public function _serialize($value): string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->_serialize(...\func_get_args());
+ }
+
+ public function _unserialize($value): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->_unserialize(...\func_get_args());
+ }
+
+ public function _pack($value): string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->_pack(...\func_get_args());
+ }
+
+ public function _unpack($value): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->_unpack(...\func_get_args());
+ }
+
+ public function acl($subcmd, ...$args): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->acl(...\func_get_args());
+ }
+
+ public function append($key, $value): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->append(...\func_get_args());
+ }
+
+ public function auth(#[\SensitiveParameter] $credentials): \Redis|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->auth(...\func_get_args());
+ }
+
+ public function bgSave(): \Redis|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->bgSave(...\func_get_args());
+ }
+
+ public function bgrewriteaof(): \Redis|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->bgrewriteaof(...\func_get_args());
+ }
+
+ public function bitcount($key, $start = 0, $end = -1, $bybit = false): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->bitcount(...\func_get_args());
+ }
+
+ public function bitop($operation, $deskey, $srckey, ...$other_keys): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->bitop(...\func_get_args());
+ }
+
+ public function bitpos($key, $bit, $start = 0, $end = -1, $bybit = false): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->bitpos(...\func_get_args());
+ }
+
+ public function blPop($key_or_keys, $timeout_or_key, ...$extra_args): \Redis|array|false|null
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->blPop(...\func_get_args());
+ }
+
+ public function brPop($key_or_keys, $timeout_or_key, ...$extra_args): \Redis|array|false|null
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->brPop(...\func_get_args());
+ }
+
+ public function brpoplpush($src, $dst, $timeout): \Redis|false|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->brpoplpush(...\func_get_args());
+ }
+
+ public function bzPopMax($key, $timeout_or_key, ...$extra_args): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->bzPopMax(...\func_get_args());
+ }
+
+ public function bzPopMin($key, $timeout_or_key, ...$extra_args): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->bzPopMin(...\func_get_args());
+ }
+
+ public function bzmpop($timeout, $keys, $from, $count = 1): \Redis|array|false|null
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->bzmpop(...\func_get_args());
+ }
+
+ public function zmpop($keys, $from, $count = 1): \Redis|array|false|null
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zmpop(...\func_get_args());
+ }
+
+ public function blmpop($timeout, $keys, $from, $count = 1): \Redis|array|false|null
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->blmpop(...\func_get_args());
+ }
+
+ public function lmpop($keys, $from, $count = 1): \Redis|array|false|null
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lmpop(...\func_get_args());
+ }
+
+ public function clearLastError(): bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->clearLastError(...\func_get_args());
+ }
+
+ public function client($opt, ...$args): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->client(...\func_get_args());
+ }
+
+ public function close(): bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->close(...\func_get_args());
+ }
+
+ public function command($opt = null, ...$args): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->command(...\func_get_args());
+ }
+
+ public function config($operation, $key_or_settings = null, $value = null): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->config(...\func_get_args());
+ }
+
+ public function connect($host, $port = 6379, $timeout = 0, $persistent_id = null, $retry_interval = 0, $read_timeout = 0, $context = null): bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->connect(...\func_get_args());
+ }
+
+ public function copy($src, $dst, $options = null): \Redis|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->copy(...\func_get_args());
+ }
+
+ public function dbSize(): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->dbSize(...\func_get_args());
+ }
+
+ public function debug($key): \Redis|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->debug(...\func_get_args());
+ }
+
+ public function decr($key, $by = 1): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->decr(...\func_get_args());
+ }
+
+ public function decrBy($key, $value): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->decrBy(...\func_get_args());
+ }
+
+ public function del($key, ...$other_keys): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->del(...\func_get_args());
+ }
+
+ public function delete($key, ...$other_keys): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->delete(...\func_get_args());
+ }
+
+ public function discard(): \Redis|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->discard(...\func_get_args());
+ }
+
+ public function echo($str): \Redis|false|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->echo(...\func_get_args());
+ }
+
+ public function eval($script, $args = [], $num_keys = 0): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->eval(...\func_get_args());
+ }
+
+ public function eval_ro($script_sha, $args = [], $num_keys = 0): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->eval_ro(...\func_get_args());
+ }
+
+ public function evalsha($sha1, $args = [], $num_keys = 0): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->evalsha(...\func_get_args());
+ }
+
+ public function evalsha_ro($sha1, $args = [], $num_keys = 0): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->evalsha_ro(...\func_get_args());
+ }
+
+ public function exec(): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->exec(...\func_get_args());
+ }
+
+ public function exists($key, ...$other_keys): \Redis|bool|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->exists(...\func_get_args());
+ }
+
+ public function expire($key, $timeout, $mode = null): \Redis|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->expire(...\func_get_args());
+ }
+
+ public function expireAt($key, $timestamp, $mode = null): \Redis|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->expireAt(...\func_get_args());
+ }
+
+ public function failover($to = null, $abort = false, $timeout = 0): \Redis|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->failover(...\func_get_args());
+ }
+
+ public function expiretime($key): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->expiretime(...\func_get_args());
+ }
+
+ public function pexpiretime($key): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->pexpiretime(...\func_get_args());
+ }
+
+ public function fcall($fn, $keys = [], $args = []): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->fcall(...\func_get_args());
+ }
+
+ public function fcall_ro($fn, $keys = [], $args = []): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->fcall_ro(...\func_get_args());
+ }
+
+ public function flushAll($sync = null): \Redis|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->flushAll(...\func_get_args());
+ }
+
+ public function flushDB($sync = null): \Redis|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->flushDB(...\func_get_args());
+ }
+
+ public function function($operation, ...$args): \Redis|array|bool|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->function(...\func_get_args());
+ }
+
+ public function geoadd($key, $lng, $lat, $member, ...$other_triples_and_options): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->geoadd(...\func_get_args());
+ }
+
+ public function geodist($key, $src, $dst, $unit = null): \Redis|false|float
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->geodist(...\func_get_args());
+ }
+
+ public function geohash($key, $member, ...$other_members): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->geohash(...\func_get_args());
+ }
+
+ public function geopos($key, $member, ...$other_members): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->geopos(...\func_get_args());
+ }
+
+ public function georadius($key, $lng, $lat, $radius, $unit, $options = []): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->georadius(...\func_get_args());
+ }
+
+ public function georadius_ro($key, $lng, $lat, $radius, $unit, $options = []): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->georadius_ro(...\func_get_args());
+ }
+
+ public function georadiusbymember($key, $member, $radius, $unit, $options = []): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->georadiusbymember(...\func_get_args());
+ }
+
+ public function georadiusbymember_ro($key, $member, $radius, $unit, $options = []): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->georadiusbymember_ro(...\func_get_args());
+ }
+
+ public function geosearch($key, $position, $shape, $unit, $options = []): array
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->geosearch(...\func_get_args());
+ }
+
+ public function geosearchstore($dst, $src, $position, $shape, $unit, $options = []): \Redis|array|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->geosearchstore(...\func_get_args());
+ }
+
+ public function get($key): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->get(...\func_get_args());
+ }
+
+ public function getAuth(): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getAuth(...\func_get_args());
+ }
+
+ public function getBit($key, $idx): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getBit(...\func_get_args());
+ }
+
+ public function getEx($key, $options = []): \Redis|bool|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getEx(...\func_get_args());
+ }
+
+ public function getDBNum(): int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getDBNum(...\func_get_args());
+ }
+
+ public function getDel($key): \Redis|bool|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getDel(...\func_get_args());
+ }
+
+ public function getHost(): string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getHost(...\func_get_args());
+ }
+
+ public function getLastError(): ?string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getLastError(...\func_get_args());
+ }
+
+ public function getMode(): int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getMode(...\func_get_args());
+ }
+
+ public function getOption($option): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getOption(...\func_get_args());
+ }
+
+ public function getPersistentID(): ?string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getPersistentID(...\func_get_args());
+ }
+
+ public function getPort(): int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getPort(...\func_get_args());
+ }
+
+ public function getRange($key, $start, $end): \Redis|false|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getRange(...\func_get_args());
+ }
+
+ public function lcs($key1, $key2, $options = null): \Redis|array|false|int|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lcs(...\func_get_args());
+ }
+
+ public function getReadTimeout(): float
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getReadTimeout(...\func_get_args());
+ }
+
+ public function getset($key, $value): \Redis|false|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getset(...\func_get_args());
+ }
+
+ public function getTimeout(): false|float
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getTimeout(...\func_get_args());
+ }
+
+ public function getTransferredBytes(): array
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getTransferredBytes(...\func_get_args());
+ }
+
+ public function clearTransferredBytes(): void
+ {
+ ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->clearTransferredBytes(...\func_get_args());
+ }
+
+ public function hDel($key, $field, ...$other_fields): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hDel(...\func_get_args());
+ }
+
+ public function hExists($key, $field): \Redis|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hExists(...\func_get_args());
+ }
+
+ public function hGet($key, $member): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hGet(...\func_get_args());
+ }
+
+ public function hGetAll($key): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hGetAll(...\func_get_args());
+ }
+
+ public function hIncrBy($key, $field, $value): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hIncrBy(...\func_get_args());
+ }
+
+ public function hIncrByFloat($key, $field, $value): \Redis|false|float
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hIncrByFloat(...\func_get_args());
+ }
+
+ public function hKeys($key): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hKeys(...\func_get_args());
+ }
+
+ public function hLen($key): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hLen(...\func_get_args());
+ }
+
+ public function hMget($key, $fields): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hMget(...\func_get_args());
+ }
+
+ public function hMset($key, $fieldvals): \Redis|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hMset(...\func_get_args());
+ }
+
+ public function hSetNx($key, $field, $value): \Redis|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hSetNx(...\func_get_args());
+ }
+
+ public function hStrLen($key, $field): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hStrLen(...\func_get_args());
+ }
+
+ public function hVals($key): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hVals(...\func_get_args());
+ }
+
+ public function hscan($key, &$iterator, $pattern = null, $count = 0): \Redis|array|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hscan($key, $iterator, ...\array_slice(\func_get_args(), 2));
+ }
+
+ public function incr($key, $by = 1): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->incr(...\func_get_args());
+ }
+
+ public function incrBy($key, $value): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->incrBy(...\func_get_args());
+ }
+
+ public function incrByFloat($key, $value): \Redis|false|float
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->incrByFloat(...\func_get_args());
+ }
+
+ public function info(...$sections): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->info(...\func_get_args());
+ }
+
+ public function isConnected(): bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->isConnected(...\func_get_args());
+ }
+
+ public function keys($pattern)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->keys(...\func_get_args());
+ }
+
+ public function lInsert($key, $pos, $pivot, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lInsert(...\func_get_args());
+ }
+
+ public function lLen($key): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lLen(...\func_get_args());
+ }
+
+ public function lMove($src, $dst, $wherefrom, $whereto): \Redis|false|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lMove(...\func_get_args());
+ }
+
+ public function blmove($src, $dst, $wherefrom, $whereto, $timeout): \Redis|false|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->blmove(...\func_get_args());
+ }
+
+ public function lPop($key, $count = 0): \Redis|array|bool|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lPop(...\func_get_args());
+ }
+
+ public function lPos($key, $value, $options = null): \Redis|array|bool|int|null
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lPos(...\func_get_args());
+ }
+
+ public function lPush($key, ...$elements): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lPush(...\func_get_args());
+ }
+
+ public function rPush($key, ...$elements): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->rPush(...\func_get_args());
+ }
+
+ public function lPushx($key, $value): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lPushx(...\func_get_args());
+ }
+
+ public function rPushx($key, $value): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->rPushx(...\func_get_args());
+ }
+
+ public function lSet($key, $index, $value): \Redis|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lSet(...\func_get_args());
+ }
+
+ public function lastSave(): int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lastSave(...\func_get_args());
+ }
+
+ public function lindex($key, $index): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lindex(...\func_get_args());
+ }
+
+ public function lrange($key, $start, $end): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lrange(...\func_get_args());
+ }
+
+ public function lrem($key, $value, $count = 0): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lrem(...\func_get_args());
+ }
+
+ public function ltrim($key, $start, $end): \Redis|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ltrim(...\func_get_args());
+ }
+
+ public function migrate($host, $port, $key, $dstdb, $timeout, $copy = false, $replace = false, #[\SensitiveParameter] $credentials = null): \Redis|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->migrate(...\func_get_args());
+ }
+
+ public function move($key, $index): \Redis|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->move(...\func_get_args());
+ }
+
+ public function mset($key_values): \Redis|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->mset(...\func_get_args());
+ }
+
+ public function msetnx($key_values): \Redis|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->msetnx(...\func_get_args());
+ }
+
+ public function multi($value = \Redis::MULTI): \Redis|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->multi(...\func_get_args());
+ }
+
+ public function object($subcommand, $key): \Redis|false|int|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->object(...\func_get_args());
+ }
+
+ public function open($host, $port = 6379, $timeout = 0, $persistent_id = null, $retry_interval = 0, $read_timeout = 0, $context = null): bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->open(...\func_get_args());
+ }
+
+ public function pconnect($host, $port = 6379, $timeout = 0, $persistent_id = null, $retry_interval = 0, $read_timeout = 0, $context = null): bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->pconnect(...\func_get_args());
+ }
+
+ public function persist($key): \Redis|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->persist(...\func_get_args());
+ }
+
+ public function pexpire($key, $timeout, $mode = null): bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->pexpire(...\func_get_args());
+ }
+
+ public function pexpireAt($key, $timestamp, $mode = null): \Redis|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->pexpireAt(...\func_get_args());
+ }
+
+ public function pfadd($key, $elements): \Redis|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->pfadd(...\func_get_args());
+ }
+
+ public function pfcount($key_or_keys): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->pfcount(...\func_get_args());
+ }
+
+ public function pfmerge($dst, $srckeys): \Redis|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->pfmerge(...\func_get_args());
+ }
+
+ public function ping($message = null): \Redis|bool|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ping(...\func_get_args());
+ }
+
+ public function pipeline(): \Redis|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->pipeline(...\func_get_args());
+ }
+
+ public function popen($host, $port = 6379, $timeout = 0, $persistent_id = null, $retry_interval = 0, $read_timeout = 0, $context = null): bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->popen(...\func_get_args());
+ }
+
+ public function psetex($key, $expire, $value): \Redis|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->psetex(...\func_get_args());
+ }
+
+ public function psubscribe($patterns, $cb): bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->psubscribe(...\func_get_args());
+ }
+
+ public function pttl($key): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->pttl(...\func_get_args());
+ }
+
+ public function publish($channel, $message): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->publish(...\func_get_args());
+ }
+
+ public function pubsub($command, $arg = null): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->pubsub(...\func_get_args());
+ }
+
+ public function punsubscribe($patterns): \Redis|array|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->punsubscribe(...\func_get_args());
+ }
+
+ public function rPop($key, $count = 0): \Redis|array|bool|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->rPop(...\func_get_args());
+ }
+
+ public function randomKey(): \Redis|false|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->randomKey(...\func_get_args());
+ }
+
+ public function rawcommand($command, ...$args): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->rawcommand(...\func_get_args());
+ }
+
+ public function rename($old_name, $new_name): \Redis|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->rename(...\func_get_args());
+ }
+
+ public function renameNx($key_src, $key_dst): \Redis|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->renameNx(...\func_get_args());
+ }
+
+ public function restore($key, $ttl, $value, $options = null): \Redis|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->restore(...\func_get_args());
+ }
+
+ public function role(): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->role(...\func_get_args());
+ }
+
+ public function rpoplpush($srckey, $dstkey): \Redis|false|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->rpoplpush(...\func_get_args());
+ }
+
+ public function sAdd($key, $value, ...$other_values): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sAdd(...\func_get_args());
+ }
+
+ public function sAddArray($key, $values): int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sAddArray(...\func_get_args());
+ }
+
+ public function sDiff($key, ...$other_keys): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sDiff(...\func_get_args());
+ }
+
+ public function sDiffStore($dst, $key, ...$other_keys): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sDiffStore(...\func_get_args());
+ }
+
+ public function sInter($key, ...$other_keys): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sInter(...\func_get_args());
+ }
+
+ public function sintercard($keys, $limit = -1): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sintercard(...\func_get_args());
+ }
+
+ public function sInterStore($key, ...$other_keys): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sInterStore(...\func_get_args());
+ }
+
+ public function sMembers($key): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sMembers(...\func_get_args());
+ }
+
+ public function sMisMember($key, $member, ...$other_members): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sMisMember(...\func_get_args());
+ }
+
+ public function sMove($src, $dst, $value): \Redis|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sMove(...\func_get_args());
+ }
+
+ public function sPop($key, $count = 0): \Redis|array|false|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sPop(...\func_get_args());
+ }
+
+ public function sUnion($key, ...$other_keys): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sUnion(...\func_get_args());
+ }
+
+ public function sUnionStore($dst, $key, ...$other_keys): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sUnionStore(...\func_get_args());
+ }
+
+ public function save(): \Redis|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->save(...\func_get_args());
+ }
+
+ public function scan(&$iterator, $pattern = null, $count = 0, $type = null): array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->scan($iterator, ...\array_slice(\func_get_args(), 1));
+ }
+
+ public function scard($key): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->scard(...\func_get_args());
+ }
+
+ public function script($command, ...$args): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->script(...\func_get_args());
+ }
+
+ public function select($db): \Redis|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->select(...\func_get_args());
+ }
+
+ public function set($key, $value, $options = null): \Redis|bool|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->set(...\func_get_args());
+ }
+
+ public function setBit($key, $idx, $value): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->setBit(...\func_get_args());
+ }
+
+ public function setRange($key, $index, $value): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->setRange(...\func_get_args());
+ }
+
+ public function setOption($option, $value): bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->setOption(...\func_get_args());
+ }
+
+ public function setex($key, $expire, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->setex(...\func_get_args());
+ }
+
+ public function setnx($key, $value): \Redis|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->setnx(...\func_get_args());
+ }
+
+ public function sismember($key, $value): \Redis|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sismember(...\func_get_args());
+ }
+
+ public function slaveof($host = null, $port = 6379): \Redis|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->slaveof(...\func_get_args());
+ }
+
+ public function replicaof($host = null, $port = 6379): \Redis|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->replicaof(...\func_get_args());
+ }
+
+ public function touch($key_or_array, ...$more_keys): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->touch(...\func_get_args());
+ }
+
+ public function slowlog($operation, $length = 0): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->slowlog(...\func_get_args());
+ }
+
+ public function sort($key, $options = null): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sort(...\func_get_args());
+ }
+
+ public function sort_ro($key, $options = null): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sort_ro(...\func_get_args());
+ }
+
+ public function sortAsc($key, $pattern = null, $get = null, $offset = -1, $count = -1, $store = null): array
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sortAsc(...\func_get_args());
+ }
+
+ public function sortAscAlpha($key, $pattern = null, $get = null, $offset = -1, $count = -1, $store = null): array
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sortAscAlpha(...\func_get_args());
+ }
+
+ public function sortDesc($key, $pattern = null, $get = null, $offset = -1, $count = -1, $store = null): array
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sortDesc(...\func_get_args());
+ }
+
+ public function sortDescAlpha($key, $pattern = null, $get = null, $offset = -1, $count = -1, $store = null): array
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sortDescAlpha(...\func_get_args());
+ }
+
+ public function srem($key, $value, ...$other_values): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->srem(...\func_get_args());
+ }
+
+ public function sscan($key, &$iterator, $pattern = null, $count = 0): array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sscan($key, $iterator, ...\array_slice(\func_get_args(), 2));
+ }
+
+ public function ssubscribe($channels, $cb): bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ssubscribe(...\func_get_args());
+ }
+
+ public function strlen($key): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->strlen(...\func_get_args());
+ }
+
+ public function subscribe($channels, $cb): bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->subscribe(...\func_get_args());
+ }
+
+ public function sunsubscribe($channels): \Redis|array|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sunsubscribe(...\func_get_args());
+ }
+
+ public function swapdb($src, $dst): \Redis|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->swapdb(...\func_get_args());
+ }
+
+ public function time(): \Redis|array
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->time(...\func_get_args());
+ }
+
+ public function ttl($key): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ttl(...\func_get_args());
+ }
+
+ public function type($key): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->type(...\func_get_args());
+ }
+
+ public function unlink($key, ...$other_keys): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->unlink(...\func_get_args());
+ }
+
+ public function unsubscribe($channels): \Redis|array|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->unsubscribe(...\func_get_args());
+ }
+
+ public function unwatch(): \Redis|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->unwatch(...\func_get_args());
+ }
+
+ public function watch($key, ...$other_keys): \Redis|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->watch(...\func_get_args());
+ }
+
+ public function wait($numreplicas, $timeout): false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->wait(...\func_get_args());
+ }
+
+ public function xack($key, $group, $ids): false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xack(...\func_get_args());
+ }
+
+ public function xadd($key, $id, $values, $maxlen = 0, $approx = false, $nomkstream = false): \Redis|false|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xadd(...\func_get_args());
+ }
+
+ public function xautoclaim($key, $group, $consumer, $min_idle, $start, $count = -1, $justid = false): \Redis|array|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xautoclaim(...\func_get_args());
+ }
+
+ public function xclaim($key, $group, $consumer, $min_idle, $ids, $options): \Redis|array|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xclaim(...\func_get_args());
+ }
+
+ public function xdel($key, $ids): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xdel(...\func_get_args());
+ }
+
+ public function xgroup($operation, $key = null, $group = null, $id_or_consumer = null, $mkstream = false, $entries_read = -2): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xgroup(...\func_get_args());
+ }
+
+ public function xinfo($operation, $arg1 = null, $arg2 = null, $count = -1): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xinfo(...\func_get_args());
+ }
+
+ public function xlen($key): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xlen(...\func_get_args());
+ }
+
+ public function xpending($key, $group, $start = null, $end = null, $count = -1, $consumer = null): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xpending(...\func_get_args());
+ }
+
+ public function xrange($key, $start, $end, $count = -1): \Redis|array|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xrange(...\func_get_args());
+ }
+
+ public function xread($streams, $count = -1, $block = -1): \Redis|array|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xread(...\func_get_args());
+ }
+
+ public function xreadgroup($group, $consumer, $streams, $count = 1, $block = 1): \Redis|array|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xreadgroup(...\func_get_args());
+ }
+
+ public function xrevrange($key, $end, $start, $count = -1): \Redis|array|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xrevrange(...\func_get_args());
+ }
+
+ public function xtrim($key, $threshold, $approx = false, $minid = false, $limit = -1): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xtrim(...\func_get_args());
+ }
+
+ public function zAdd($key, $score_or_options, ...$more_scores_and_mems): \Redis|false|float|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zAdd(...\func_get_args());
+ }
+
+ public function zCard($key): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zCard(...\func_get_args());
+ }
+
+ public function zCount($key, $start, $end): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zCount(...\func_get_args());
+ }
+
+ public function zIncrBy($key, $value, $member): \Redis|false|float
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zIncrBy(...\func_get_args());
+ }
+
+ public function zLexCount($key, $min, $max): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zLexCount(...\func_get_args());
+ }
+
+ public function zMscore($key, $member, ...$other_members): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zMscore(...\func_get_args());
+ }
+
+ public function zPopMax($key, $count = null): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zPopMax(...\func_get_args());
+ }
+
+ public function zPopMin($key, $count = null): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zPopMin(...\func_get_args());
+ }
+
+ public function zRange($key, $start, $end, $options = null): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zRange(...\func_get_args());
+ }
+
+ public function zRangeByLex($key, $min, $max, $offset = -1, $count = -1): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zRangeByLex(...\func_get_args());
+ }
+
+ public function zRangeByScore($key, $start, $end, $options = []): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zRangeByScore(...\func_get_args());
+ }
+
+ public function zrangestore($dstkey, $srckey, $start, $end, $options = null): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zrangestore(...\func_get_args());
+ }
+
+ public function zRandMember($key, $options = null): \Redis|array|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zRandMember(...\func_get_args());
+ }
+
+ public function zRank($key, $member): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zRank(...\func_get_args());
+ }
+
+ public function zRem($key, $member, ...$other_members): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zRem(...\func_get_args());
+ }
+
+ public function zRemRangeByLex($key, $min, $max): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zRemRangeByLex(...\func_get_args());
+ }
+
+ public function zRemRangeByRank($key, $start, $end): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zRemRangeByRank(...\func_get_args());
+ }
+
+ public function zRemRangeByScore($key, $start, $end): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zRemRangeByScore(...\func_get_args());
+ }
+
+ public function zRevRange($key, $start, $end, $scores = null): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zRevRange(...\func_get_args());
+ }
+
+ public function zRevRangeByLex($key, $max, $min, $offset = -1, $count = -1): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zRevRangeByLex(...\func_get_args());
+ }
+
+ public function zRevRangeByScore($key, $max, $min, $options = []): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zRevRangeByScore(...\func_get_args());
+ }
+
+ public function zRevRank($key, $member): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zRevRank(...\func_get_args());
+ }
+
+ public function zScore($key, $member): \Redis|false|float
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zScore(...\func_get_args());
+ }
+
+ public function zdiff($keys, $options = null): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zdiff(...\func_get_args());
+ }
+
+ public function zdiffstore($dst, $keys): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zdiffstore(...\func_get_args());
+ }
+
+ public function zinter($keys, $weights = null, $options = null): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zinter(...\func_get_args());
+ }
+
+ public function zintercard($keys, $limit = -1): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zintercard(...\func_get_args());
+ }
+
+ public function zinterstore($dst, $keys, $weights = null, $aggregate = null): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zinterstore(...\func_get_args());
+ }
+
+ public function zscan($key, &$iterator, $pattern = null, $count = 0): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zscan($key, $iterator, ...\array_slice(\func_get_args(), 2));
+ }
+
+ public function zunion($keys, $weights = null, $options = null): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zunion(...\func_get_args());
+ }
+
+ public function zunionstore($dst, $keys, $weights = null, $aggregate = null): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zunionstore(...\func_get_args());
+ }
+}
diff --git a/symfony/cache/Traits/RedisCluster5Proxy.php b/symfony/cache/Traits/RedisCluster5Proxy.php
new file mode 100644
index 0000000000000000000000000000000000000000..511c53dd718a3dfc8946940166849538c48428a3
--- /dev/null
+++ b/symfony/cache/Traits/RedisCluster5Proxy.php
@@ -0,0 +1,983 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Traits;
+
+use Symfony\Component\VarExporter\LazyObjectInterface;
+use Symfony\Component\VarExporter\LazyProxyTrait;
+use Symfony\Contracts\Service\ResetInterface;
+
+// Help opcache.preload discover always-needed symbols
+class_exists(\Symfony\Component\VarExporter\Internal\Hydrator::class);
+class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectRegistry::class);
+class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectState::class);
+
+/**
+ * @internal
+ */
+class RedisCluster5Proxy extends \RedisCluster implements ResetInterface, LazyObjectInterface
+{
+ use LazyProxyTrait {
+ resetLazyObject as reset;
+ }
+
+ private const LAZY_OBJECT_PROPERTY_SCOPES = [];
+
+ public function __construct($name, $seeds = null, $timeout = null, $read_timeout = null, $persistent = null, #[\SensitiveParameter] $auth = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->__construct(...\func_get_args());
+ }
+
+ public function _masters()
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->_masters(...\func_get_args());
+ }
+
+ public function _prefix($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->_prefix(...\func_get_args());
+ }
+
+ public function _redir()
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->_redir(...\func_get_args());
+ }
+
+ public function _serialize($value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->_serialize(...\func_get_args());
+ }
+
+ public function _unserialize($value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->_unserialize(...\func_get_args());
+ }
+
+ public function _compress($value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->_compress(...\func_get_args());
+ }
+
+ public function _uncompress($value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->_uncompress(...\func_get_args());
+ }
+
+ public function _pack($value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->_pack(...\func_get_args());
+ }
+
+ public function _unpack($value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->_unpack(...\func_get_args());
+ }
+
+ public function acl($key_or_address, $subcmd, ...$args)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->acl(...\func_get_args());
+ }
+
+ public function append($key, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->append(...\func_get_args());
+ }
+
+ public function bgrewriteaof($key_or_address)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->bgrewriteaof(...\func_get_args());
+ }
+
+ public function bgsave($key_or_address)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->bgsave(...\func_get_args());
+ }
+
+ public function bitcount($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->bitcount(...\func_get_args());
+ }
+
+ public function bitop($operation, $ret_key, $key, ...$other_keys)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->bitop(...\func_get_args());
+ }
+
+ public function bitpos($key, $bit, $start = null, $end = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->bitpos(...\func_get_args());
+ }
+
+ public function blpop($key, $timeout_or_key, ...$extra_args)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->blpop(...\func_get_args());
+ }
+
+ public function brpop($key, $timeout_or_key, ...$extra_args)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->brpop(...\func_get_args());
+ }
+
+ public function brpoplpush($src, $dst, $timeout)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->brpoplpush(...\func_get_args());
+ }
+
+ public function clearlasterror()
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->clearlasterror(...\func_get_args());
+ }
+
+ public function bzpopmax($key, $timeout_or_key, ...$extra_args)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->bzpopmax(...\func_get_args());
+ }
+
+ public function bzpopmin($key, $timeout_or_key, ...$extra_args)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->bzpopmin(...\func_get_args());
+ }
+
+ public function client($key_or_address, $arg = null, ...$other_args)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->client(...\func_get_args());
+ }
+
+ public function close()
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->close(...\func_get_args());
+ }
+
+ public function cluster($key_or_address, $arg = null, ...$other_args)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->cluster(...\func_get_args());
+ }
+
+ public function command(...$args)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->command(...\func_get_args());
+ }
+
+ public function config($key_or_address, $arg = null, ...$other_args)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->config(...\func_get_args());
+ }
+
+ public function dbsize($key_or_address)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->dbsize(...\func_get_args());
+ }
+
+ public function decr($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->decr(...\func_get_args());
+ }
+
+ public function decrby($key, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->decrby(...\func_get_args());
+ }
+
+ public function del($key, ...$other_keys)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->del(...\func_get_args());
+ }
+
+ public function discard()
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->discard(...\func_get_args());
+ }
+
+ public function dump($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->dump(...\func_get_args());
+ }
+
+ public function echo($msg)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->echo(...\func_get_args());
+ }
+
+ public function eval($script, $args = null, $num_keys = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->eval(...\func_get_args());
+ }
+
+ public function evalsha($script_sha, $args = null, $num_keys = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->evalsha(...\func_get_args());
+ }
+
+ public function exec()
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->exec(...\func_get_args());
+ }
+
+ public function exists($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->exists(...\func_get_args());
+ }
+
+ public function expire($key, $timeout)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->expire(...\func_get_args());
+ }
+
+ public function expireat($key, $timestamp)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->expireat(...\func_get_args());
+ }
+
+ public function flushall($key_or_address, $async = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->flushall(...\func_get_args());
+ }
+
+ public function flushdb($key_or_address, $async = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->flushdb(...\func_get_args());
+ }
+
+ public function geoadd($key, $lng, $lat, $member, ...$other_triples)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->geoadd(...\func_get_args());
+ }
+
+ public function geodist($key, $src, $dst, $unit = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->geodist(...\func_get_args());
+ }
+
+ public function geohash($key, $member, ...$other_members)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->geohash(...\func_get_args());
+ }
+
+ public function geopos($key, $member, ...$other_members)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->geopos(...\func_get_args());
+ }
+
+ public function georadius($key, $lng, $lan, $radius, $unit, $opts = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->georadius(...\func_get_args());
+ }
+
+ public function georadius_ro($key, $lng, $lan, $radius, $unit, $opts = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->georadius_ro(...\func_get_args());
+ }
+
+ public function georadiusbymember($key, $member, $radius, $unit, $opts = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->georadiusbymember(...\func_get_args());
+ }
+
+ public function georadiusbymember_ro($key, $member, $radius, $unit, $opts = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->georadiusbymember_ro(...\func_get_args());
+ }
+
+ public function get($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->get(...\func_get_args());
+ }
+
+ public function getbit($key, $offset)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getbit(...\func_get_args());
+ }
+
+ public function getlasterror()
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getlasterror(...\func_get_args());
+ }
+
+ public function getmode()
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getmode(...\func_get_args());
+ }
+
+ public function getoption($option)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getoption(...\func_get_args());
+ }
+
+ public function getrange($key, $start, $end)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getrange(...\func_get_args());
+ }
+
+ public function getset($key, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getset(...\func_get_args());
+ }
+
+ public function hdel($key, $member, ...$other_members)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hdel(...\func_get_args());
+ }
+
+ public function hexists($key, $member)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hexists(...\func_get_args());
+ }
+
+ public function hget($key, $member)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hget(...\func_get_args());
+ }
+
+ public function hgetall($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hgetall(...\func_get_args());
+ }
+
+ public function hincrby($key, $member, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hincrby(...\func_get_args());
+ }
+
+ public function hincrbyfloat($key, $member, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hincrbyfloat(...\func_get_args());
+ }
+
+ public function hkeys($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hkeys(...\func_get_args());
+ }
+
+ public function hlen($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hlen(...\func_get_args());
+ }
+
+ public function hmget($key, $keys)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hmget(...\func_get_args());
+ }
+
+ public function hmset($key, $pairs)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hmset(...\func_get_args());
+ }
+
+ public function hscan($str_key, &$i_iterator, $str_pattern = null, $i_count = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hscan($str_key, $i_iterator, ...\array_slice(\func_get_args(), 2));
+ }
+
+ public function hset($key, $member, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hset(...\func_get_args());
+ }
+
+ public function hsetnx($key, $member, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hsetnx(...\func_get_args());
+ }
+
+ public function hstrlen($key, $member)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hstrlen(...\func_get_args());
+ }
+
+ public function hvals($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hvals(...\func_get_args());
+ }
+
+ public function incr($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->incr(...\func_get_args());
+ }
+
+ public function incrby($key, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->incrby(...\func_get_args());
+ }
+
+ public function incrbyfloat($key, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->incrbyfloat(...\func_get_args());
+ }
+
+ public function info($key_or_address, $option = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->info(...\func_get_args());
+ }
+
+ public function keys($pattern)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->keys(...\func_get_args());
+ }
+
+ public function lastsave($key_or_address)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lastsave(...\func_get_args());
+ }
+
+ public function lget($key, $index)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lget(...\func_get_args());
+ }
+
+ public function lindex($key, $index)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lindex(...\func_get_args());
+ }
+
+ public function linsert($key, $position, $pivot, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->linsert(...\func_get_args());
+ }
+
+ public function llen($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->llen(...\func_get_args());
+ }
+
+ public function lpop($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lpop(...\func_get_args());
+ }
+
+ public function lpush($key, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lpush(...\func_get_args());
+ }
+
+ public function lpushx($key, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lpushx(...\func_get_args());
+ }
+
+ public function lrange($key, $start, $end)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lrange(...\func_get_args());
+ }
+
+ public function lrem($key, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lrem(...\func_get_args());
+ }
+
+ public function lset($key, $index, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lset(...\func_get_args());
+ }
+
+ public function ltrim($key, $start, $stop)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ltrim(...\func_get_args());
+ }
+
+ public function mget($keys)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->mget(...\func_get_args());
+ }
+
+ public function mset($pairs)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->mset(...\func_get_args());
+ }
+
+ public function msetnx($pairs)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->msetnx(...\func_get_args());
+ }
+
+ public function multi()
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->multi(...\func_get_args());
+ }
+
+ public function object($field, $key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->object(...\func_get_args());
+ }
+
+ public function persist($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->persist(...\func_get_args());
+ }
+
+ public function pexpire($key, $timestamp)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->pexpire(...\func_get_args());
+ }
+
+ public function pexpireat($key, $timestamp)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->pexpireat(...\func_get_args());
+ }
+
+ public function pfadd($key, $elements)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->pfadd(...\func_get_args());
+ }
+
+ public function pfcount($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->pfcount(...\func_get_args());
+ }
+
+ public function pfmerge($dstkey, $keys)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->pfmerge(...\func_get_args());
+ }
+
+ public function ping($key_or_address)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ping(...\func_get_args());
+ }
+
+ public function psetex($key, $expire, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->psetex(...\func_get_args());
+ }
+
+ public function psubscribe($patterns, $callback)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->psubscribe(...\func_get_args());
+ }
+
+ public function pttl($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->pttl(...\func_get_args());
+ }
+
+ public function publish($channel, $message)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->publish(...\func_get_args());
+ }
+
+ public function pubsub($key_or_address, $arg = null, ...$other_args)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->pubsub(...\func_get_args());
+ }
+
+ public function punsubscribe($pattern, ...$other_patterns)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->punsubscribe(...\func_get_args());
+ }
+
+ public function randomkey($key_or_address)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->randomkey(...\func_get_args());
+ }
+
+ public function rawcommand($cmd, ...$args)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->rawcommand(...\func_get_args());
+ }
+
+ public function rename($key, $newkey)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->rename(...\func_get_args());
+ }
+
+ public function renamenx($key, $newkey)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->renamenx(...\func_get_args());
+ }
+
+ public function restore($ttl, $key, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->restore(...\func_get_args());
+ }
+
+ public function role()
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->role(...\func_get_args());
+ }
+
+ public function rpop($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->rpop(...\func_get_args());
+ }
+
+ public function rpoplpush($src, $dst)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->rpoplpush(...\func_get_args());
+ }
+
+ public function rpush($key, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->rpush(...\func_get_args());
+ }
+
+ public function rpushx($key, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->rpushx(...\func_get_args());
+ }
+
+ public function sadd($key, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sadd(...\func_get_args());
+ }
+
+ public function saddarray($key, $options)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->saddarray(...\func_get_args());
+ }
+
+ public function save($key_or_address)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->save(...\func_get_args());
+ }
+
+ public function scan(&$i_iterator, $str_node, $str_pattern = null, $i_count = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->scan($i_iterator, ...\array_slice(\func_get_args(), 1));
+ }
+
+ public function scard($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->scard(...\func_get_args());
+ }
+
+ public function script($key_or_address, $arg = null, ...$other_args)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->script(...\func_get_args());
+ }
+
+ public function sdiff($key, ...$other_keys)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sdiff(...\func_get_args());
+ }
+
+ public function sdiffstore($dst, $key, ...$other_keys)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sdiffstore(...\func_get_args());
+ }
+
+ public function set($key, $value, $opts = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->set(...\func_get_args());
+ }
+
+ public function setbit($key, $offset, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->setbit(...\func_get_args());
+ }
+
+ public function setex($key, $expire, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->setex(...\func_get_args());
+ }
+
+ public function setnx($key, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->setnx(...\func_get_args());
+ }
+
+ public function setoption($option, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->setoption(...\func_get_args());
+ }
+
+ public function setrange($key, $offset, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->setrange(...\func_get_args());
+ }
+
+ public function sinter($key, ...$other_keys)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sinter(...\func_get_args());
+ }
+
+ public function sinterstore($dst, $key, ...$other_keys)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sinterstore(...\func_get_args());
+ }
+
+ public function sismember($key, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sismember(...\func_get_args());
+ }
+
+ public function slowlog($key_or_address, $arg = null, ...$other_args)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->slowlog(...\func_get_args());
+ }
+
+ public function smembers($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->smembers(...\func_get_args());
+ }
+
+ public function smove($src, $dst, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->smove(...\func_get_args());
+ }
+
+ public function sort($key, $options = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sort(...\func_get_args());
+ }
+
+ public function spop($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->spop(...\func_get_args());
+ }
+
+ public function srandmember($key, $count = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->srandmember(...\func_get_args());
+ }
+
+ public function srem($key, $value)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->srem(...\func_get_args());
+ }
+
+ public function sscan($str_key, &$i_iterator, $str_pattern = null, $i_count = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sscan($str_key, $i_iterator, ...\array_slice(\func_get_args(), 2));
+ }
+
+ public function strlen($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->strlen(...\func_get_args());
+ }
+
+ public function subscribe($channels, $callback)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->subscribe(...\func_get_args());
+ }
+
+ public function sunion($key, ...$other_keys)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sunion(...\func_get_args());
+ }
+
+ public function sunionstore($dst, $key, ...$other_keys)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sunionstore(...\func_get_args());
+ }
+
+ public function time()
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->time(...\func_get_args());
+ }
+
+ public function ttl($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ttl(...\func_get_args());
+ }
+
+ public function type($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->type(...\func_get_args());
+ }
+
+ public function unsubscribe($channel, ...$other_channels)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->unsubscribe(...\func_get_args());
+ }
+
+ public function unlink($key, ...$other_keys)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->unlink(...\func_get_args());
+ }
+
+ public function unwatch()
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->unwatch(...\func_get_args());
+ }
+
+ public function watch($key, ...$other_keys)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->watch(...\func_get_args());
+ }
+
+ public function xack($str_key, $str_group, $arr_ids)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xack(...\func_get_args());
+ }
+
+ public function xadd($str_key, $str_id, $arr_fields, $i_maxlen = null, $boo_approximate = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xadd(...\func_get_args());
+ }
+
+ public function xclaim($str_key, $str_group, $str_consumer, $i_min_idle, $arr_ids, $arr_opts = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xclaim(...\func_get_args());
+ }
+
+ public function xdel($str_key, $arr_ids)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xdel(...\func_get_args());
+ }
+
+ public function xgroup($str_operation, $str_key = null, $str_arg1 = null, $str_arg2 = null, $str_arg3 = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xgroup(...\func_get_args());
+ }
+
+ public function xinfo($str_cmd, $str_key = null, $str_group = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xinfo(...\func_get_args());
+ }
+
+ public function xlen($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xlen(...\func_get_args());
+ }
+
+ public function xpending($str_key, $str_group, $str_start = null, $str_end = null, $i_count = null, $str_consumer = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xpending(...\func_get_args());
+ }
+
+ public function xrange($str_key, $str_start, $str_end, $i_count = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xrange(...\func_get_args());
+ }
+
+ public function xread($arr_streams, $i_count = null, $i_block = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xread(...\func_get_args());
+ }
+
+ public function xreadgroup($str_group, $str_consumer, $arr_streams, $i_count = null, $i_block = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xreadgroup(...\func_get_args());
+ }
+
+ public function xrevrange($str_key, $str_start, $str_end, $i_count = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xrevrange(...\func_get_args());
+ }
+
+ public function xtrim($str_key, $i_maxlen, $boo_approximate = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xtrim(...\func_get_args());
+ }
+
+ public function zadd($key, $score, $value, ...$extra_args)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zadd(...\func_get_args());
+ }
+
+ public function zcard($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zcard(...\func_get_args());
+ }
+
+ public function zcount($key, $min, $max)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zcount(...\func_get_args());
+ }
+
+ public function zincrby($key, $value, $member)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zincrby(...\func_get_args());
+ }
+
+ public function zinterstore($key, $keys, $weights = null, $aggregate = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zinterstore(...\func_get_args());
+ }
+
+ public function zlexcount($key, $min, $max)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zlexcount(...\func_get_args());
+ }
+
+ public function zpopmax($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zpopmax(...\func_get_args());
+ }
+
+ public function zpopmin($key)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zpopmin(...\func_get_args());
+ }
+
+ public function zrange($key, $start, $end, $scores = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zrange(...\func_get_args());
+ }
+
+ public function zrangebylex($key, $min, $max, $offset = null, $limit = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zrangebylex(...\func_get_args());
+ }
+
+ public function zrangebyscore($key, $start, $end, $options = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zrangebyscore(...\func_get_args());
+ }
+
+ public function zrank($key, $member)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zrank(...\func_get_args());
+ }
+
+ public function zrem($key, $member, ...$other_members)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zrem(...\func_get_args());
+ }
+
+ public function zremrangebylex($key, $min, $max)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zremrangebylex(...\func_get_args());
+ }
+
+ public function zremrangebyrank($key, $min, $max)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zremrangebyrank(...\func_get_args());
+ }
+
+ public function zremrangebyscore($key, $min, $max)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zremrangebyscore(...\func_get_args());
+ }
+
+ public function zrevrange($key, $start, $end, $scores = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zrevrange(...\func_get_args());
+ }
+
+ public function zrevrangebylex($key, $min, $max, $offset = null, $limit = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zrevrangebylex(...\func_get_args());
+ }
+
+ public function zrevrangebyscore($key, $start, $end, $options = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zrevrangebyscore(...\func_get_args());
+ }
+
+ public function zrevrank($key, $member)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zrevrank(...\func_get_args());
+ }
+
+ public function zscan($str_key, &$i_iterator, $str_pattern = null, $i_count = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zscan($str_key, $i_iterator, ...\array_slice(\func_get_args(), 2));
+ }
+
+ public function zscore($key, $member)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zscore(...\func_get_args());
+ }
+
+ public function zunionstore($key, $keys, $weights = null, $aggregate = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zunionstore(...\func_get_args());
+ }
+}
diff --git a/symfony/cache/Traits/RedisCluster61ProxyTrait.php b/symfony/cache/Traits/RedisCluster61ProxyTrait.php
new file mode 100644
index 0000000000000000000000000000000000000000..9ff5b19da54190122205fbc3097c99e299bfec52
--- /dev/null
+++ b/symfony/cache/Traits/RedisCluster61ProxyTrait.php
@@ -0,0 +1,46 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Traits;
+
+if (version_compare(phpversion('redis'), '6.1.0-dev', '>')) {
+ /**
+ * @internal
+ */
+ trait RedisCluster61ProxyTrait
+ {
+ public function getex($key, $options = []): \RedisCluster|string|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getex(...\func_get_args());
+ }
+
+ public function publish($channel, $message): \RedisCluster|bool|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->publish(...\func_get_args());
+ }
+
+ public function waitaof($key_or_address, $numlocal, $numreplicas, $timeout): \RedisCluster|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->waitaof(...\func_get_args());
+ }
+ }
+} else {
+ /**
+ * @internal
+ */
+ trait RedisCluster61ProxyTrait
+ {
+ public function publish($channel, $message): \RedisCluster|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->publish(...\func_get_args());
+ }
+ }
+}
diff --git a/symfony/cache/Traits/RedisCluster62ProxyTrait.php b/symfony/cache/Traits/RedisCluster62ProxyTrait.php
new file mode 100644
index 0000000000000000000000000000000000000000..e8f864a05f0037bda0b4c3a34a497ee8943d6519
--- /dev/null
+++ b/symfony/cache/Traits/RedisCluster62ProxyTrait.php
@@ -0,0 +1,47 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Traits;
+
+if (version_compare(phpversion('redis'), '6.2.0', '>=')) {
+ /**
+ * @internal
+ */
+ trait RedisCluster62ProxyTrait
+ {
+ public function expiremember($key, $field, $ttl, $unit = null): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->expiremember(...\func_get_args());
+ }
+
+ public function expirememberat($key, $field, $timestamp): \Redis|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->expirememberat(...\func_get_args());
+ }
+
+ public function getdel($key): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getdel(...\func_get_args());
+ }
+
+ public function getWithMeta($key): \RedisCluster|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getWithMeta(...\func_get_args());
+ }
+ }
+} else {
+ /**
+ * @internal
+ */
+ trait RedisCluster62ProxyTrait
+ {
+ }
+}
diff --git a/symfony/cache/Traits/RedisCluster63ProxyTrait.php b/symfony/cache/Traits/RedisCluster63ProxyTrait.php
new file mode 100644
index 0000000000000000000000000000000000000000..374f96214b8cdd74eefad477f363cd76ac8717b9
--- /dev/null
+++ b/symfony/cache/Traits/RedisCluster63ProxyTrait.php
@@ -0,0 +1,162 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Traits;
+
+if (version_compare(phpversion('redis'), '6.3.0', '>=')) {
+ /**
+ * @internal
+ */
+ trait RedisCluster63ProxyTrait
+ {
+ public function delifeq($key, $value): \RedisCluster|int|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->delifeq(...\func_get_args());
+ }
+
+ public function hexpire($key, $ttl, $fields, $mode = null): \RedisCluster|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hexpire(...\func_get_args());
+ }
+
+ public function hexpireat($key, $time, $fields, $mode = null): \RedisCluster|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hexpireat(...\func_get_args());
+ }
+
+ public function hexpiretime($key, $fields): \RedisCluster|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hexpiretime(...\func_get_args());
+ }
+
+ public function hgetdel($key, $fields): \RedisCluster|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hgetdel(...\func_get_args());
+ }
+
+ public function hgetex($key, $fields, $expiry = null): \RedisCluster|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hgetex(...\func_get_args());
+ }
+
+ public function hgetWithMeta($key, $member): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hgetWithMeta(...\func_get_args());
+ }
+
+ public function hpersist($key, $fields): \RedisCluster|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hpersist(...\func_get_args());
+ }
+
+ public function hpexpire($key, $ttl, $fields, $mode = null): \RedisCluster|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hpexpire(...\func_get_args());
+ }
+
+ public function hpexpireat($key, $mstime, $fields, $mode = null): \RedisCluster|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hpexpireat(...\func_get_args());
+ }
+
+ public function hpexpiretime($key, $fields): \RedisCluster|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hpexpiretime(...\func_get_args());
+ }
+
+ public function hpttl($key, $fields): \RedisCluster|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hpttl(...\func_get_args());
+ }
+
+ public function hsetex($key, $fields, $expiry = null): \RedisCluster|int|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hsetex(...\func_get_args());
+ }
+
+ public function httl($key, $fields): \RedisCluster|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->httl(...\func_get_args());
+ }
+
+ public function vadd($key, $values, $element, $options = null): \RedisCluster|int|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->vadd(...\func_get_args());
+ }
+
+ public function vcard($key): \RedisCluster|int|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->vcard(...\func_get_args());
+ }
+
+ public function vdim($key): \RedisCluster|int|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->vdim(...\func_get_args());
+ }
+
+ public function vemb($key, $member, $raw = false): \RedisCluster|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->vemb(...\func_get_args());
+ }
+
+ public function vgetattr($key, $member, $decode = true): \RedisCluster|array|string|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->vgetattr(...\func_get_args());
+ }
+
+ public function vinfo($key): \RedisCluster|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->vinfo(...\func_get_args());
+ }
+
+ public function vismember($key, $member): \RedisCluster|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->vismember(...\func_get_args());
+ }
+
+ public function vlinks($key, $member, $withscores = false): \RedisCluster|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->vlinks(...\func_get_args());
+ }
+
+ public function vrandmember($key, $count = 0): \RedisCluster|array|string|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->vrandmember(...\func_get_args());
+ }
+
+ public function vrange($key, $min, $max, $count = -1): \RedisCluster|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->vrange(...\func_get_args());
+ }
+
+ public function vrem($key, $member): \RedisCluster|int|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->vrem(...\func_get_args());
+ }
+
+ public function vsetattr($key, $member, $attributes): \RedisCluster|int|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->vsetattr(...\func_get_args());
+ }
+
+ public function vsim($key, $member, $options = null): \RedisCluster|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->vsim(...\func_get_args());
+ }
+ }
+} else {
+ /**
+ * @internal
+ */
+ trait RedisCluster63ProxyTrait
+ {
+ }
+}
diff --git a/symfony/cache/Traits/RedisCluster6Proxy.php b/symfony/cache/Traits/RedisCluster6Proxy.php
new file mode 100644
index 0000000000000000000000000000000000000000..1ea025dd0fa11b4eca5159bbe98bf2707b171731
--- /dev/null
+++ b/symfony/cache/Traits/RedisCluster6Proxy.php
@@ -0,0 +1,1141 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Traits;
+
+use Symfony\Component\VarExporter\LazyObjectInterface;
+use Symfony\Component\VarExporter\LazyProxyTrait;
+use Symfony\Contracts\Service\ResetInterface;
+
+// Help opcache.preload discover always-needed symbols
+class_exists(\Symfony\Component\VarExporter\Internal\Hydrator::class);
+class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectRegistry::class);
+class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectState::class);
+
+/**
+ * @internal
+ */
+class RedisCluster6Proxy extends \RedisCluster implements ResetInterface, LazyObjectInterface
+{
+ use RedisCluster61ProxyTrait;
+ use RedisCluster62ProxyTrait;
+ use RedisCluster63ProxyTrait;
+ use LazyProxyTrait {
+ resetLazyObject as reset;
+ }
+
+ private const LAZY_OBJECT_PROPERTY_SCOPES = [];
+
+ public function __construct($name, $seeds = null, $timeout = 0, $read_timeout = 0, $persistent = false, #[\SensitiveParameter] $auth = null, $context = null)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->__construct(...\func_get_args());
+ }
+
+ public function _compress($value): string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->_compress(...\func_get_args());
+ }
+
+ public function _uncompress($value): string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->_uncompress(...\func_get_args());
+ }
+
+ public function _serialize($value): bool|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->_serialize(...\func_get_args());
+ }
+
+ public function _unserialize($value): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->_unserialize(...\func_get_args());
+ }
+
+ public function _pack($value): string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->_pack(...\func_get_args());
+ }
+
+ public function _unpack($value): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->_unpack(...\func_get_args());
+ }
+
+ public function _prefix($key): bool|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->_prefix(...\func_get_args());
+ }
+
+ public function _masters(): array
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->_masters(...\func_get_args());
+ }
+
+ public function _redir(): ?string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->_redir(...\func_get_args());
+ }
+
+ public function acl($key_or_address, $subcmd, ...$args): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->acl(...\func_get_args());
+ }
+
+ public function append($key, $value): \RedisCluster|bool|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->append(...\func_get_args());
+ }
+
+ public function bgrewriteaof($key_or_address): \RedisCluster|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->bgrewriteaof(...\func_get_args());
+ }
+
+ public function bgsave($key_or_address): \RedisCluster|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->bgsave(...\func_get_args());
+ }
+
+ public function bitcount($key, $start = 0, $end = -1, $bybit = false): \RedisCluster|bool|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->bitcount(...\func_get_args());
+ }
+
+ public function bitop($operation, $deskey, $srckey, ...$otherkeys): \RedisCluster|bool|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->bitop(...\func_get_args());
+ }
+
+ public function bitpos($key, $bit, $start = 0, $end = -1, $bybit = false): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->bitpos(...\func_get_args());
+ }
+
+ public function blpop($key, $timeout_or_key, ...$extra_args): \RedisCluster|array|false|null
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->blpop(...\func_get_args());
+ }
+
+ public function brpop($key, $timeout_or_key, ...$extra_args): \RedisCluster|array|false|null
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->brpop(...\func_get_args());
+ }
+
+ public function brpoplpush($srckey, $deskey, $timeout): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->brpoplpush(...\func_get_args());
+ }
+
+ public function lmove($src, $dst, $wherefrom, $whereto): \Redis|false|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lmove(...\func_get_args());
+ }
+
+ public function blmove($src, $dst, $wherefrom, $whereto, $timeout): \Redis|false|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->blmove(...\func_get_args());
+ }
+
+ public function bzpopmax($key, $timeout_or_key, ...$extra_args): array
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->bzpopmax(...\func_get_args());
+ }
+
+ public function bzpopmin($key, $timeout_or_key, ...$extra_args): array
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->bzpopmin(...\func_get_args());
+ }
+
+ public function bzmpop($timeout, $keys, $from, $count = 1): \RedisCluster|array|false|null
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->bzmpop(...\func_get_args());
+ }
+
+ public function zmpop($keys, $from, $count = 1): \RedisCluster|array|false|null
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zmpop(...\func_get_args());
+ }
+
+ public function blmpop($timeout, $keys, $from, $count = 1): \RedisCluster|array|false|null
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->blmpop(...\func_get_args());
+ }
+
+ public function lmpop($keys, $from, $count = 1): \RedisCluster|array|false|null
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lmpop(...\func_get_args());
+ }
+
+ public function clearlasterror(): bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->clearlasterror(...\func_get_args());
+ }
+
+ public function client($key_or_address, $subcommand, $arg = null): array|bool|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->client(...\func_get_args());
+ }
+
+ public function close(): bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->close(...\func_get_args());
+ }
+
+ public function cluster($key_or_address, $command, ...$extra_args): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->cluster(...\func_get_args());
+ }
+
+ public function command(...$extra_args): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->command(...\func_get_args());
+ }
+
+ public function config($key_or_address, $subcommand, ...$extra_args): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->config(...\func_get_args());
+ }
+
+ public function dbsize($key_or_address): \RedisCluster|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->dbsize(...\func_get_args());
+ }
+
+ public function copy($src, $dst, $options = null): \RedisCluster|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->copy(...\func_get_args());
+ }
+
+ public function decr($key, $by = 1): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->decr(...\func_get_args());
+ }
+
+ public function decrby($key, $value): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->decrby(...\func_get_args());
+ }
+
+ public function decrbyfloat($key, $value): float
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->decrbyfloat(...\func_get_args());
+ }
+
+ public function del($key, ...$other_keys): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->del(...\func_get_args());
+ }
+
+ public function discard(): bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->discard(...\func_get_args());
+ }
+
+ public function dump($key): \RedisCluster|false|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->dump(...\func_get_args());
+ }
+
+ public function echo($key_or_address, $msg): \RedisCluster|false|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->echo(...\func_get_args());
+ }
+
+ public function eval($script, $args = [], $num_keys = 0): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->eval(...\func_get_args());
+ }
+
+ public function eval_ro($script, $args = [], $num_keys = 0): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->eval_ro(...\func_get_args());
+ }
+
+ public function evalsha($script_sha, $args = [], $num_keys = 0): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->evalsha(...\func_get_args());
+ }
+
+ public function evalsha_ro($script_sha, $args = [], $num_keys = 0): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->evalsha_ro(...\func_get_args());
+ }
+
+ public function exec(): array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->exec(...\func_get_args());
+ }
+
+ public function exists($key, ...$other_keys): \RedisCluster|bool|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->exists(...\func_get_args());
+ }
+
+ public function touch($key, ...$other_keys): \RedisCluster|bool|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->touch(...\func_get_args());
+ }
+
+ public function expire($key, $timeout, $mode = null): \RedisCluster|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->expire(...\func_get_args());
+ }
+
+ public function expireat($key, $timestamp, $mode = null): \RedisCluster|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->expireat(...\func_get_args());
+ }
+
+ public function expiretime($key): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->expiretime(...\func_get_args());
+ }
+
+ public function pexpiretime($key): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->pexpiretime(...\func_get_args());
+ }
+
+ public function flushall($key_or_address, $async = false): \RedisCluster|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->flushall(...\func_get_args());
+ }
+
+ public function flushdb($key_or_address, $async = false): \RedisCluster|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->flushdb(...\func_get_args());
+ }
+
+ public function geoadd($key, $lng, $lat, $member, ...$other_triples_and_options): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->geoadd(...\func_get_args());
+ }
+
+ public function geodist($key, $src, $dest, $unit = null): \RedisCluster|false|float
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->geodist(...\func_get_args());
+ }
+
+ public function geohash($key, $member, ...$other_members): \RedisCluster|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->geohash(...\func_get_args());
+ }
+
+ public function geopos($key, $member, ...$other_members): \RedisCluster|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->geopos(...\func_get_args());
+ }
+
+ public function georadius($key, $lng, $lat, $radius, $unit, $options = []): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->georadius(...\func_get_args());
+ }
+
+ public function georadius_ro($key, $lng, $lat, $radius, $unit, $options = []): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->georadius_ro(...\func_get_args());
+ }
+
+ public function georadiusbymember($key, $member, $radius, $unit, $options = []): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->georadiusbymember(...\func_get_args());
+ }
+
+ public function georadiusbymember_ro($key, $member, $radius, $unit, $options = []): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->georadiusbymember_ro(...\func_get_args());
+ }
+
+ public function geosearch($key, $position, $shape, $unit, $options = []): \RedisCluster|array
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->geosearch(...\func_get_args());
+ }
+
+ public function geosearchstore($dst, $src, $position, $shape, $unit, $options = []): \RedisCluster|array|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->geosearchstore(...\func_get_args());
+ }
+
+ public function get($key): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->get(...\func_get_args());
+ }
+
+ public function getbit($key, $value): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getbit(...\func_get_args());
+ }
+
+ public function getlasterror(): ?string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getlasterror(...\func_get_args());
+ }
+
+ public function getmode(): int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getmode(...\func_get_args());
+ }
+
+ public function getoption($option): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getoption(...\func_get_args());
+ }
+
+ public function getrange($key, $start, $end): \RedisCluster|false|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getrange(...\func_get_args());
+ }
+
+ public function lcs($key1, $key2, $options = null): \RedisCluster|array|false|int|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lcs(...\func_get_args());
+ }
+
+ public function getset($key, $value): \RedisCluster|bool|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getset(...\func_get_args());
+ }
+
+ public function gettransferredbytes(): array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->gettransferredbytes(...\func_get_args());
+ }
+
+ public function cleartransferredbytes(): void
+ {
+ ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->cleartransferredbytes(...\func_get_args());
+ }
+
+ public function hdel($key, $member, ...$other_members): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hdel(...\func_get_args());
+ }
+
+ public function hexists($key, $member): \RedisCluster|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hexists(...\func_get_args());
+ }
+
+ public function hget($key, $member): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hget(...\func_get_args());
+ }
+
+ public function hgetall($key): \RedisCluster|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hgetall(...\func_get_args());
+ }
+
+ public function hincrby($key, $member, $value): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hincrby(...\func_get_args());
+ }
+
+ public function hincrbyfloat($key, $member, $value): \RedisCluster|false|float
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hincrbyfloat(...\func_get_args());
+ }
+
+ public function hkeys($key): \RedisCluster|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hkeys(...\func_get_args());
+ }
+
+ public function hlen($key): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hlen(...\func_get_args());
+ }
+
+ public function hmget($key, $keys): \RedisCluster|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hmget(...\func_get_args());
+ }
+
+ public function hmset($key, $key_values): \RedisCluster|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hmset(...\func_get_args());
+ }
+
+ public function hscan($key, &$iterator, $pattern = null, $count = 0): array|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hscan($key, $iterator, ...\array_slice(\func_get_args(), 2));
+ }
+
+ public function hrandfield($key, $options = null): \RedisCluster|array|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hrandfield(...\func_get_args());
+ }
+
+ public function hset($key, $member, $value): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hset(...\func_get_args());
+ }
+
+ public function hsetnx($key, $member, $value): \RedisCluster|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hsetnx(...\func_get_args());
+ }
+
+ public function hstrlen($key, $field): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hstrlen(...\func_get_args());
+ }
+
+ public function hvals($key): \RedisCluster|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hvals(...\func_get_args());
+ }
+
+ public function incr($key, $by = 1): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->incr(...\func_get_args());
+ }
+
+ public function incrby($key, $value): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->incrby(...\func_get_args());
+ }
+
+ public function incrbyfloat($key, $value): \RedisCluster|false|float
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->incrbyfloat(...\func_get_args());
+ }
+
+ public function info($key_or_address, ...$sections): \RedisCluster|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->info(...\func_get_args());
+ }
+
+ public function keys($pattern): \RedisCluster|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->keys(...\func_get_args());
+ }
+
+ public function lastsave($key_or_address): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lastsave(...\func_get_args());
+ }
+
+ public function lget($key, $index): \RedisCluster|bool|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lget(...\func_get_args());
+ }
+
+ public function lindex($key, $index): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lindex(...\func_get_args());
+ }
+
+ public function linsert($key, $pos, $pivot, $value): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->linsert(...\func_get_args());
+ }
+
+ public function llen($key): \RedisCluster|bool|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->llen(...\func_get_args());
+ }
+
+ public function lpop($key, $count = 0): \RedisCluster|array|bool|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lpop(...\func_get_args());
+ }
+
+ public function lpos($key, $value, $options = null): \Redis|array|bool|int|null
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lpos(...\func_get_args());
+ }
+
+ public function lpush($key, $value, ...$other_values): \RedisCluster|bool|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lpush(...\func_get_args());
+ }
+
+ public function lpushx($key, $value): \RedisCluster|bool|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lpushx(...\func_get_args());
+ }
+
+ public function lrange($key, $start, $end): \RedisCluster|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lrange(...\func_get_args());
+ }
+
+ public function lrem($key, $value, $count = 0): \RedisCluster|bool|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lrem(...\func_get_args());
+ }
+
+ public function lset($key, $index, $value): \RedisCluster|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lset(...\func_get_args());
+ }
+
+ public function ltrim($key, $start, $end): \RedisCluster|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ltrim(...\func_get_args());
+ }
+
+ public function mget($keys): \RedisCluster|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->mget(...\func_get_args());
+ }
+
+ public function mset($key_values): \RedisCluster|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->mset(...\func_get_args());
+ }
+
+ public function msetnx($key_values): \RedisCluster|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->msetnx(...\func_get_args());
+ }
+
+ public function multi($value = \Redis::MULTI): \RedisCluster|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->multi(...\func_get_args());
+ }
+
+ public function object($subcommand, $key): \RedisCluster|false|int|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->object(...\func_get_args());
+ }
+
+ public function persist($key): \RedisCluster|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->persist(...\func_get_args());
+ }
+
+ public function pexpire($key, $timeout, $mode = null): \RedisCluster|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->pexpire(...\func_get_args());
+ }
+
+ public function pexpireat($key, $timestamp, $mode = null): \RedisCluster|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->pexpireat(...\func_get_args());
+ }
+
+ public function pfadd($key, $elements): \RedisCluster|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->pfadd(...\func_get_args());
+ }
+
+ public function pfcount($key): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->pfcount(...\func_get_args());
+ }
+
+ public function pfmerge($key, $keys): \RedisCluster|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->pfmerge(...\func_get_args());
+ }
+
+ public function ping($key_or_address, $message = null): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ping(...\func_get_args());
+ }
+
+ public function psetex($key, $timeout, $value): \RedisCluster|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->psetex(...\func_get_args());
+ }
+
+ public function psubscribe($patterns, $callback): void
+ {
+ ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->psubscribe(...\func_get_args());
+ }
+
+ public function pttl($key): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->pttl(...\func_get_args());
+ }
+
+ public function pubsub($key_or_address, ...$values): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->pubsub(...\func_get_args());
+ }
+
+ public function punsubscribe($pattern, ...$other_patterns): array|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->punsubscribe(...\func_get_args());
+ }
+
+ public function randomkey($key_or_address): \RedisCluster|bool|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->randomkey(...\func_get_args());
+ }
+
+ public function rawcommand($key_or_address, $command, ...$args): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->rawcommand(...\func_get_args());
+ }
+
+ public function rename($key_src, $key_dst): \RedisCluster|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->rename(...\func_get_args());
+ }
+
+ public function renamenx($key, $newkey): \RedisCluster|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->renamenx(...\func_get_args());
+ }
+
+ public function restore($key, $timeout, $value, $options = null): \RedisCluster|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->restore(...\func_get_args());
+ }
+
+ public function role($key_or_address): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->role(...\func_get_args());
+ }
+
+ public function rpop($key, $count = 0): \RedisCluster|array|bool|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->rpop(...\func_get_args());
+ }
+
+ public function rpoplpush($src, $dst): \RedisCluster|bool|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->rpoplpush(...\func_get_args());
+ }
+
+ public function rpush($key, ...$elements): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->rpush(...\func_get_args());
+ }
+
+ public function rpushx($key, $value): \RedisCluster|bool|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->rpushx(...\func_get_args());
+ }
+
+ public function sadd($key, $value, ...$other_values): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sadd(...\func_get_args());
+ }
+
+ public function saddarray($key, $values): \RedisCluster|bool|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->saddarray(...\func_get_args());
+ }
+
+ public function save($key_or_address): \RedisCluster|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->save(...\func_get_args());
+ }
+
+ public function scan(&$iterator, $key_or_address, $pattern = null, $count = 0): array|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->scan($iterator, ...\array_slice(\func_get_args(), 1));
+ }
+
+ public function scard($key): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->scard(...\func_get_args());
+ }
+
+ public function script($key_or_address, ...$args): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->script(...\func_get_args());
+ }
+
+ public function sdiff($key, ...$other_keys): \RedisCluster|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sdiff(...\func_get_args());
+ }
+
+ public function sdiffstore($dst, $key, ...$other_keys): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sdiffstore(...\func_get_args());
+ }
+
+ public function set($key, $value, $options = null): \RedisCluster|bool|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->set(...\func_get_args());
+ }
+
+ public function setbit($key, $offset, $onoff): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->setbit(...\func_get_args());
+ }
+
+ public function setex($key, $expire, $value): \RedisCluster|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->setex(...\func_get_args());
+ }
+
+ public function setnx($key, $value): \RedisCluster|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->setnx(...\func_get_args());
+ }
+
+ public function setoption($option, $value): bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->setoption(...\func_get_args());
+ }
+
+ public function setrange($key, $offset, $value): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->setrange(...\func_get_args());
+ }
+
+ public function sinter($key, ...$other_keys): \RedisCluster|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sinter(...\func_get_args());
+ }
+
+ public function sintercard($keys, $limit = -1): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sintercard(...\func_get_args());
+ }
+
+ public function sinterstore($key, ...$other_keys): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sinterstore(...\func_get_args());
+ }
+
+ public function sismember($key, $value): \RedisCluster|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sismember(...\func_get_args());
+ }
+
+ public function smismember($key, $member, ...$other_members): \RedisCluster|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->smismember(...\func_get_args());
+ }
+
+ public function slowlog($key_or_address, ...$args): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->slowlog(...\func_get_args());
+ }
+
+ public function smembers($key): \RedisCluster|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->smembers(...\func_get_args());
+ }
+
+ public function smove($src, $dst, $member): \RedisCluster|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->smove(...\func_get_args());
+ }
+
+ public function sort($key, $options = null): \RedisCluster|array|bool|int|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sort(...\func_get_args());
+ }
+
+ public function sort_ro($key, $options = null): \RedisCluster|array|bool|int|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sort_ro(...\func_get_args());
+ }
+
+ public function spop($key, $count = 0): \RedisCluster|array|false|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->spop(...\func_get_args());
+ }
+
+ public function srandmember($key, $count = 0): \RedisCluster|array|false|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->srandmember(...\func_get_args());
+ }
+
+ public function srem($key, $value, ...$other_values): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->srem(...\func_get_args());
+ }
+
+ public function sscan($key, &$iterator, $pattern = null, $count = 0): array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sscan($key, $iterator, ...\array_slice(\func_get_args(), 2));
+ }
+
+ public function strlen($key): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->strlen(...\func_get_args());
+ }
+
+ public function subscribe($channels, $cb): void
+ {
+ ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->subscribe(...\func_get_args());
+ }
+
+ public function sunion($key, ...$other_keys): \RedisCluster|array|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sunion(...\func_get_args());
+ }
+
+ public function sunionstore($dst, $key, ...$other_keys): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sunionstore(...\func_get_args());
+ }
+
+ public function time($key_or_address): \RedisCluster|array|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->time(...\func_get_args());
+ }
+
+ public function ttl($key): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ttl(...\func_get_args());
+ }
+
+ public function type($key): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->type(...\func_get_args());
+ }
+
+ public function unsubscribe($channels): array|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->unsubscribe(...\func_get_args());
+ }
+
+ public function unlink($key, ...$other_keys): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->unlink(...\func_get_args());
+ }
+
+ public function unwatch(): bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->unwatch(...\func_get_args());
+ }
+
+ public function watch($key, ...$other_keys): \RedisCluster|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->watch(...\func_get_args());
+ }
+
+ public function xack($key, $group, $ids): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xack(...\func_get_args());
+ }
+
+ public function xadd($key, $id, $values, $maxlen = 0, $approx = false): \RedisCluster|false|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xadd(...\func_get_args());
+ }
+
+ public function xclaim($key, $group, $consumer, $min_iddle, $ids, $options): \RedisCluster|array|false|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xclaim(...\func_get_args());
+ }
+
+ public function xdel($key, $ids): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xdel(...\func_get_args());
+ }
+
+ public function xgroup($operation, $key = null, $group = null, $id_or_consumer = null, $mkstream = false, $entries_read = -2): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xgroup(...\func_get_args());
+ }
+
+ public function xautoclaim($key, $group, $consumer, $min_idle, $start, $count = -1, $justid = false): \RedisCluster|array|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xautoclaim(...\func_get_args());
+ }
+
+ public function xinfo($operation, $arg1 = null, $arg2 = null, $count = -1): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xinfo(...\func_get_args());
+ }
+
+ public function xlen($key): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xlen(...\func_get_args());
+ }
+
+ public function xpending($key, $group, $start = null, $end = null, $count = -1, $consumer = null): \RedisCluster|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xpending(...\func_get_args());
+ }
+
+ public function xrange($key, $start, $end, $count = -1): \RedisCluster|array|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xrange(...\func_get_args());
+ }
+
+ public function xread($streams, $count = -1, $block = -1): \RedisCluster|array|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xread(...\func_get_args());
+ }
+
+ public function xreadgroup($group, $consumer, $streams, $count = 1, $block = 1): \RedisCluster|array|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xreadgroup(...\func_get_args());
+ }
+
+ public function xrevrange($key, $start, $end, $count = -1): \RedisCluster|array|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xrevrange(...\func_get_args());
+ }
+
+ public function xtrim($key, $maxlen, $approx = false, $minid = false, $limit = -1): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xtrim(...\func_get_args());
+ }
+
+ public function zadd($key, $score_or_options, ...$more_scores_and_mems): \RedisCluster|false|float|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zadd(...\func_get_args());
+ }
+
+ public function zcard($key): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zcard(...\func_get_args());
+ }
+
+ public function zcount($key, $start, $end): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zcount(...\func_get_args());
+ }
+
+ public function zincrby($key, $value, $member): \RedisCluster|false|float
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zincrby(...\func_get_args());
+ }
+
+ public function zinterstore($dst, $keys, $weights = null, $aggregate = null): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zinterstore(...\func_get_args());
+ }
+
+ public function zintercard($keys, $limit = -1): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zintercard(...\func_get_args());
+ }
+
+ public function zlexcount($key, $min, $max): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zlexcount(...\func_get_args());
+ }
+
+ public function zpopmax($key, $value = null): \RedisCluster|array|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zpopmax(...\func_get_args());
+ }
+
+ public function zpopmin($key, $value = null): \RedisCluster|array|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zpopmin(...\func_get_args());
+ }
+
+ public function zrange($key, $start, $end, $options = null): \RedisCluster|array|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zrange(...\func_get_args());
+ }
+
+ public function zrangestore($dstkey, $srckey, $start, $end, $options = null): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zrangestore(...\func_get_args());
+ }
+
+ public function zrandmember($key, $options = null): \RedisCluster|array|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zrandmember(...\func_get_args());
+ }
+
+ public function zrangebylex($key, $min, $max, $offset = -1, $count = -1): \RedisCluster|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zrangebylex(...\func_get_args());
+ }
+
+ public function zrangebyscore($key, $start, $end, $options = []): \RedisCluster|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zrangebyscore(...\func_get_args());
+ }
+
+ public function zrank($key, $member): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zrank(...\func_get_args());
+ }
+
+ public function zrem($key, $value, ...$other_values): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zrem(...\func_get_args());
+ }
+
+ public function zremrangebylex($key, $min, $max): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zremrangebylex(...\func_get_args());
+ }
+
+ public function zremrangebyrank($key, $min, $max): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zremrangebyrank(...\func_get_args());
+ }
+
+ public function zremrangebyscore($key, $min, $max): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zremrangebyscore(...\func_get_args());
+ }
+
+ public function zrevrange($key, $min, $max, $options = null): \RedisCluster|array|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zrevrange(...\func_get_args());
+ }
+
+ public function zrevrangebylex($key, $min, $max, $options = null): \RedisCluster|array|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zrevrangebylex(...\func_get_args());
+ }
+
+ public function zrevrangebyscore($key, $min, $max, $options = null): \RedisCluster|array|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zrevrangebyscore(...\func_get_args());
+ }
+
+ public function zrevrank($key, $member): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zrevrank(...\func_get_args());
+ }
+
+ public function zscan($key, &$iterator, $pattern = null, $count = 0): \RedisCluster|array|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zscan($key, $iterator, ...\array_slice(\func_get_args(), 2));
+ }
+
+ public function zscore($key, $member): \RedisCluster|false|float
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zscore(...\func_get_args());
+ }
+
+ public function zmscore($key, $member, ...$other_members): \Redis|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zmscore(...\func_get_args());
+ }
+
+ public function zunionstore($dst, $keys, $weights = null, $aggregate = null): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zunionstore(...\func_get_args());
+ }
+
+ public function zinter($keys, $weights = null, $options = null): \RedisCluster|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zinter(...\func_get_args());
+ }
+
+ public function zdiffstore($dst, $keys): \RedisCluster|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zdiffstore(...\func_get_args());
+ }
+
+ public function zunion($keys, $weights = null, $options = null): \RedisCluster|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zunion(...\func_get_args());
+ }
+
+ public function zdiff($keys, $options = null): \RedisCluster|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zdiff(...\func_get_args());
+ }
+}
diff --git a/symfony/cache/Traits/RedisClusterNodeProxy.php b/symfony/cache/Traits/RedisClusterNodeProxy.php
new file mode 100644
index 0000000000000000000000000000000000000000..f5c0baa3e506d6d3afd6e962404117949e854c75
--- /dev/null
+++ b/symfony/cache/Traits/RedisClusterNodeProxy.php
@@ -0,0 +1,47 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Traits;
+
+/**
+ * This file acts as a wrapper to the \RedisCluster implementation so it can accept the same type of calls as
+ * individual \Redis objects.
+ *
+ * Calls are made to individual nodes via: RedisCluster->{method}($host, ...args)'
+ * according to https://github.com/phpredis/phpredis/blob/develop/cluster.markdown#directed-node-commands
+ *
+ * @author Jack Thomas
+ *
+ * @internal
+ */
+class RedisClusterNodeProxy
+{
+ public function __construct(
+ private array $host,
+ private \RedisCluster $redis,
+ ) {
+ }
+
+ public function __call(string $method, array $args)
+ {
+ return $this->redis->{$method}($this->host, ...$args);
+ }
+
+ public function scan(&$iIterator, $strPattern = null, $iCount = null)
+ {
+ return $this->redis->scan($iIterator, $this->host, $strPattern, $iCount);
+ }
+
+ public function getOption($name)
+ {
+ return $this->redis->getOption($name);
+ }
+}
diff --git a/symfony/cache/Traits/RedisClusterProxy.php b/symfony/cache/Traits/RedisClusterProxy.php
new file mode 100644
index 0000000000000000000000000000000000000000..c67d5341c78f235121c9f6feb9b61183871111b4
--- /dev/null
+++ b/symfony/cache/Traits/RedisClusterProxy.php
@@ -0,0 +1,23 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Traits;
+
+class_alias(6.0 <= (float) phpversion('redis') ? RedisCluster6Proxy::class : RedisCluster5Proxy::class, RedisClusterProxy::class);
+
+if (false) {
+ /**
+ * @internal
+ */
+ class RedisClusterProxy extends \RedisCluster
+ {
+ }
+}
diff --git a/symfony/cache/Traits/RedisProxy.php b/symfony/cache/Traits/RedisProxy.php
new file mode 100644
index 0000000000000000000000000000000000000000..7f4537b1569f919dc6e2d182e70f496604664fef
--- /dev/null
+++ b/symfony/cache/Traits/RedisProxy.php
@@ -0,0 +1,23 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Traits;
+
+class_alias(6.0 <= (float) phpversion('redis') ? Redis6Proxy::class : Redis5Proxy::class, RedisProxy::class);
+
+if (false) {
+ /**
+ * @internal
+ */
+ class RedisProxy extends \Redis
+ {
+ }
+}
diff --git a/symfony/cache/Traits/RedisTrait.php b/symfony/cache/Traits/RedisTrait.php
new file mode 100644
index 0000000000000000000000000000000000000000..c3fc6899097f9c64352ed8568b71837432b3a747
--- /dev/null
+++ b/symfony/cache/Traits/RedisTrait.php
@@ -0,0 +1,681 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Traits;
+
+use Predis\Command\Redis\UNLINK;
+use Predis\Connection\Aggregate\ClusterInterface;
+use Predis\Connection\Aggregate\RedisCluster;
+use Predis\Connection\Aggregate\ReplicationInterface;
+use Predis\Connection\Cluster\ClusterInterface as Predis2ClusterInterface;
+use Predis\Connection\Cluster\RedisCluster as Predis2RedisCluster;
+use Predis\Connection\Replication\ReplicationInterface as Predis2ReplicationInterface;
+use Predis\Response\ErrorInterface;
+use Predis\Response\Status;
+use Relay\Relay;
+use Relay\Sentinel;
+use Symfony\Component\Cache\Exception\CacheException;
+use Symfony\Component\Cache\Exception\InvalidArgumentException;
+use Symfony\Component\Cache\Marshaller\DefaultMarshaller;
+use Symfony\Component\Cache\Marshaller\MarshallerInterface;
+
+/**
+ * @author Aurimas Niekis
+ * @author Nicolas Grekas
+ *
+ * @internal
+ */
+trait RedisTrait
+{
+ private static array $defaultConnectionOptions = [
+ 'class' => null,
+ 'auth' => null,
+ 'persistent' => 0,
+ 'persistent_id' => null,
+ 'timeout' => 30,
+ 'read_timeout' => 0,
+ 'retry_interval' => 0,
+ 'tcp_keepalive' => 0,
+ 'lazy' => null,
+ 'redis_cluster' => false,
+ 'redis_sentinel' => null,
+ 'dbindex' => 0,
+ 'failover' => 'none',
+ 'ssl' => null, // see https://php.net/context.ssl
+ ];
+ private \Redis|Relay|\RedisArray|\RedisCluster|\Predis\ClientInterface $redis;
+ private MarshallerInterface $marshaller;
+
+ private function init(\Redis|Relay|\RedisArray|\RedisCluster|\Predis\ClientInterface $redis, string $namespace, int $defaultLifetime, ?MarshallerInterface $marshaller): void
+ {
+ parent::__construct($namespace, $defaultLifetime);
+
+ if (preg_match('#[^-+_.A-Za-z0-9]#', $namespace, $match)) {
+ throw new InvalidArgumentException(\sprintf('RedisAdapter namespace contains "%s" but only characters in [-+_.A-Za-z0-9] are allowed.', $match[0]));
+ }
+
+ if ($redis instanceof \Predis\ClientInterface && $redis->getOptions()->exceptions) {
+ $options = clone $redis->getOptions();
+ \Closure::bind(function () { $this->options['exceptions'] = false; }, $options, $options)();
+ $redis = new $redis($redis->getConnection(), $options);
+ }
+
+ $this->redis = $redis;
+ $this->marshaller = $marshaller ?? new DefaultMarshaller();
+ }
+
+ /**
+ * Creates a Redis connection using a DSN configuration.
+ *
+ * Example DSN:
+ * - redis://localhost
+ * - redis://example.com:1234
+ * - redis://secret@example.com/13
+ * - redis:///var/run/redis.sock
+ * - redis://secret@/var/run/redis.sock/13
+ *
+ * @param array $options See self::$defaultConnectionOptions
+ *
+ * @throws InvalidArgumentException when the DSN is invalid
+ */
+ public static function createConnection(#[\SensitiveParameter] string $dsn, array $options = []): \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface|Relay
+ {
+ if (str_starts_with($dsn, 'redis:')) {
+ $scheme = 'redis';
+ } elseif (str_starts_with($dsn, 'rediss:')) {
+ $scheme = 'rediss';
+ } else {
+ throw new InvalidArgumentException('Invalid Redis DSN: it does not start with "redis[s]:".');
+ }
+
+ if (!\extension_loaded('redis') && !\extension_loaded('relay') && !class_exists(\Predis\Client::class)) {
+ throw new CacheException('Cannot find the "redis" extension nor the "relay" extension nor the "predis/predis" package.');
+ }
+
+ $auth = null;
+ $params = preg_replace_callback('#^'.$scheme.':(//)?(?:(?:(?[^:@]*+):)?(?[^@]*+)@)?#', function ($m) use (&$auth) {
+ if (isset($m['password'])) {
+ if (\in_array($m['user'], ['', 'default'], true)) {
+ $auth = rawurldecode($m['password']);
+ } else {
+ $auth = [rawurldecode($m['user']), rawurldecode($m['password'])];
+ }
+
+ if ('' === $auth) {
+ $auth = null;
+ }
+ }
+
+ return 'file:'.($m[1] ?? '');
+ }, $dsn);
+
+ if (false === $params = parse_url($params)) {
+ throw new InvalidArgumentException('Invalid Redis DSN.');
+ }
+
+ $query = $hosts = [];
+
+ $tls = 'rediss' === $scheme;
+ $tcpScheme = $tls ? 'tls' : 'tcp';
+
+ if (isset($params['query'])) {
+ parse_str($params['query'], $query);
+
+ if (isset($query['host'])) {
+ if (!\is_array($hosts = $query['host'])) {
+ throw new InvalidArgumentException('Invalid Redis DSN: query parameter "host" must be an array.');
+ }
+ foreach ($hosts as $host => $parameters) {
+ if (\is_string($parameters)) {
+ parse_str($parameters, $parameters);
+ }
+ if (false === $i = strrpos($host, ':')) {
+ $hosts[$host] = ['scheme' => $tcpScheme, 'host' => $host, 'port' => 6379] + $parameters;
+ } elseif ($port = (int) substr($host, 1 + $i)) {
+ $hosts[$host] = ['scheme' => $tcpScheme, 'host' => substr($host, 0, $i), 'port' => $port] + $parameters;
+ } else {
+ $hosts[$host] = ['scheme' => 'unix', 'path' => substr($host, 0, $i)] + $parameters;
+ }
+ }
+ $hosts = array_values($hosts);
+ }
+ }
+
+ if (isset($params['host']) || isset($params['path'])) {
+ if (!isset($params['dbindex']) && isset($params['path'])) {
+ if (preg_match('#/(\d+)?$#', $params['path'], $m)) {
+ $params['dbindex'] = $m[1] ?? $query['dbindex'] ?? '0';
+ $params['path'] = substr($params['path'], 0, -\strlen($m[0]));
+ } elseif (isset($params['host'])) {
+ throw new InvalidArgumentException('Invalid Redis DSN: parameter "dbindex" must be a number.');
+ }
+ }
+
+ if (isset($params['host'])) {
+ array_unshift($hosts, ['scheme' => $tcpScheme, 'host' => $params['host'], 'port' => $params['port'] ?? 6379]);
+ } else {
+ array_unshift($hosts, ['scheme' => 'unix', 'path' => $params['path']]);
+ }
+ }
+
+ if (!$hosts) {
+ throw new InvalidArgumentException('Invalid Redis DSN: missing host.');
+ }
+
+ if (isset($params['dbindex'], $query['dbindex']) && $params['dbindex'] !== $query['dbindex']) {
+ throw new InvalidArgumentException('Invalid Redis DSN: path and query "dbindex" parameters mismatch.');
+ }
+
+ $params += $query + $options + self::$defaultConnectionOptions;
+ $params['auth'] ??= $auth;
+
+ if (isset($params['redis_sentinel']) && !class_exists(\Predis\Client::class) && !class_exists(\RedisSentinel::class) && !class_exists(Sentinel::class)) {
+ throw new CacheException('Redis Sentinel support requires one of: "predis/predis", "ext-redis >= 5.2", "ext-relay".');
+ }
+
+ if (isset($params['lazy'])) {
+ $params['lazy'] = filter_var($params['lazy'], \FILTER_VALIDATE_BOOLEAN);
+ }
+ $params['redis_cluster'] = filter_var($params['redis_cluster'], \FILTER_VALIDATE_BOOLEAN);
+
+ if ($params['redis_cluster'] && isset($params['redis_sentinel'])) {
+ throw new InvalidArgumentException('Cannot use both "redis_cluster" and "redis_sentinel" at the same time.');
+ }
+
+ $class = $params['class'] ?? match (true) {
+ $params['redis_cluster'] => \extension_loaded('redis') ? \RedisCluster::class : \Predis\Client::class,
+ isset($params['redis_sentinel']) => match (true) {
+ \extension_loaded('redis') => \Redis::class,
+ \extension_loaded('relay') => Relay::class,
+ default => \Predis\Client::class,
+ },
+ 1 < \count($hosts) && \extension_loaded('redis') => 1 < \count($hosts) ? \RedisArray::class : \Redis::class,
+ \extension_loaded('redis') => \Redis::class,
+ \extension_loaded('relay') => Relay::class,
+ default => \Predis\Client::class,
+ };
+
+ if (isset($params['redis_sentinel']) && !is_a($class, \Predis\Client::class, true) && !class_exists(\RedisSentinel::class) && !class_exists(Sentinel::class)) {
+ throw new CacheException(\sprintf('Cannot use Redis Sentinel: class "%s" does not extend "Predis\Client" and neither ext-redis >= 5.2 nor ext-relay have been found.', $class));
+ }
+
+ $isRedisExt = is_a($class, \Redis::class, true);
+ $isRelayExt = !$isRedisExt && is_a($class, Relay::class, true);
+
+ if ($isRedisExt || $isRelayExt) {
+ $connect = $params['persistent'] || $params['persistent_id'] ? 'pconnect' : 'connect';
+
+ $initializer = static function () use ($class, $isRedisExt, $connect, $params, $auth, $hosts, $tls) {
+ $sentinelClass = $isRedisExt ? \RedisSentinel::class : Sentinel::class;
+ $redis = new $class();
+ $hostIndex = 0;
+ do {
+ $host = $hosts[$hostIndex]['host'] ?? $hosts[$hostIndex]['path'];
+ $port = $hosts[$hostIndex]['port'] ?? 0;
+ $passAuth = null !== $params['auth'] && (!$isRedisExt || \defined('Redis::OPT_NULL_MULTIBULK_AS_NULL'));
+ $address = false;
+
+ if (isset($hosts[$hostIndex]['host']) && $tls) {
+ $host = 'tls://'.$host;
+ }
+
+ if (!isset($params['redis_sentinel'])) {
+ break;
+ }
+
+ try {
+ if ($isRedisExt && version_compare(phpversion('redis'), '6.0.0', '>=')) {
+ $options = [
+ 'host' => $host,
+ 'port' => $port,
+ 'connectTimeout' => (float) $params['timeout'],
+ 'persistent' => $params['persistent_id'],
+ 'retryInterval' => (int) $params['retry_interval'],
+ 'readTimeout' => (float) $params['read_timeout'],
+ ];
+
+ if ($passAuth) {
+ $options['auth'] = $params['auth'];
+ }
+
+ $sentinel = new \RedisSentinel($options);
+ } else {
+ $extra = $passAuth ? [$params['auth']] : [];
+
+ $sentinel = @new $sentinelClass($host, $port, $params['timeout'], (string) $params['persistent_id'], $params['retry_interval'], $params['read_timeout'], ...$extra);
+ }
+
+ if ($address = @$sentinel->getMasterAddrByName($params['redis_sentinel'])) {
+ [$host, $port] = $address;
+ }
+ } catch (\RedisException|\Relay\Exception $redisException) {
+ }
+ } while (++$hostIndex < \count($hosts) && !$address);
+
+ if (isset($params['redis_sentinel']) && !$address) {
+ throw new InvalidArgumentException(\sprintf('Failed to retrieve master information from sentinel "%s".', $params['redis_sentinel']), previous: $redisException ?? null);
+ }
+
+ try {
+ $extra = [
+ 'stream' => $params['ssl'] ?? null,
+ ];
+ $booleanStreamOptions = [
+ 'allow_self_signed',
+ 'capture_peer_cert',
+ 'capture_peer_cert_chain',
+ 'disable_compression',
+ 'SNI_enabled',
+ 'verify_peer',
+ 'verify_peer_name',
+ ];
+
+ foreach ($extra['stream'] ?? [] as $streamOption => $value) {
+ if (\in_array($streamOption, $booleanStreamOptions, true) && \is_string($value)) {
+ $extra['stream'][$streamOption] = filter_var($value, \FILTER_VALIDATE_BOOL);
+ }
+ }
+
+ if (null !== $params['auth']) {
+ $extra['auth'] = $params['auth'];
+ }
+ @$redis->{$connect}($host, $port, (float) $params['timeout'], (string) $params['persistent_id'], $params['retry_interval'], $params['read_timeout'], ...\defined('Redis::SCAN_PREFIX') || !$isRedisExt ? [$extra] : []);
+
+ set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; });
+ try {
+ $isConnected = $redis->isConnected();
+ } finally {
+ restore_error_handler();
+ }
+ if (!$isConnected) {
+ $error = preg_match('/^Redis::p?connect\(\): (.*)/', $error ?? $redis->getLastError() ?? '', $error) ? \sprintf(' (%s)', $error[1]) : '';
+ throw new InvalidArgumentException('Redis connection failed: '.$error.'.');
+ }
+
+ if (0 < $params['tcp_keepalive'] && (!$isRedisExt || \defined('Redis::OPT_TCP_KEEPALIVE'))) {
+ $redis->setOption($isRedisExt ? \Redis::OPT_TCP_KEEPALIVE : Relay::OPT_TCP_KEEPALIVE, $params['tcp_keepalive']);
+ }
+
+ if ((!\defined('Redis::SCAN_PREFIX') && null !== $auth && $isRedisExt && !$redis->auth($auth)) || !$redis->select($params['dbindex'])) {
+ $e = preg_replace('/^ERR /', '', $redis->getLastError());
+ throw new InvalidArgumentException('Redis connection failed: '.$e.'.');
+ }
+
+ } catch (\RedisException|\Relay\Exception $e) {
+ throw new InvalidArgumentException('Redis connection failed: '.$e->getMessage());
+ }
+
+ return $redis;
+ };
+
+ if ($params['lazy']) {
+ $redis = $isRedisExt ? RedisProxy::createLazyProxy($initializer) : RelayProxy::createLazyProxy($initializer);
+ } else {
+ $redis = $initializer();
+ }
+ } elseif (is_a($class, \RedisArray::class, true)) {
+ foreach ($hosts as $i => $host) {
+ $hosts[$i] = match ($host['scheme']) {
+ 'tcp' => $host['host'].':'.$host['port'],
+ 'tls' => 'tls://'.$host['host'].':'.$host['port'],
+ default => $host['path'],
+ };
+ }
+ $params['lazy_connect'] = $params['lazy'] ?? true;
+ $params['connect_timeout'] = $params['timeout'];
+
+ try {
+ $redis = new $class($hosts, $params);
+ } catch (\RedisClusterException $e) {
+ throw new InvalidArgumentException('Redis connection failed: '.$e->getMessage());
+ }
+
+ if (0 < $params['tcp_keepalive'] && (!$isRedisExt || \defined('Redis::OPT_TCP_KEEPALIVE'))) {
+ $redis->setOption($isRedisExt ? \Redis::OPT_TCP_KEEPALIVE : Relay::OPT_TCP_KEEPALIVE, $params['tcp_keepalive']);
+ }
+ } elseif (is_a($class, \RedisCluster::class, true)) {
+ $initializer = static function () use ($isRedisExt, $class, $params, $hosts) {
+ foreach ($hosts as $i => $host) {
+ $hosts[$i] = match ($host['scheme']) {
+ 'tcp' => $host['host'].':'.$host['port'],
+ 'tls' => 'tls://'.$host['host'].':'.$host['port'],
+ default => $host['path'],
+ };
+ }
+
+ try {
+ $redis = new $class(null, $hosts, $params['timeout'], $params['read_timeout'], (bool) $params['persistent'], $params['auth'] ?? '', ...\defined('Redis::SCAN_PREFIX') ? [$params['ssl'] ?? null] : []);
+ } catch (\RedisClusterException $e) {
+ throw new InvalidArgumentException('Redis connection failed: '.$e->getMessage());
+ }
+
+ if (0 < $params['tcp_keepalive'] && (!$isRedisExt || \defined('Redis::OPT_TCP_KEEPALIVE'))) {
+ $redis->setOption($isRedisExt ? \Redis::OPT_TCP_KEEPALIVE : Relay::OPT_TCP_KEEPALIVE, $params['tcp_keepalive']);
+ }
+ $redis->setOption(\RedisCluster::OPT_SLAVE_FAILOVER, match ($params['failover']) {
+ 'error' => \RedisCluster::FAILOVER_ERROR,
+ 'distribute' => \RedisCluster::FAILOVER_DISTRIBUTE,
+ 'slaves' => \RedisCluster::FAILOVER_DISTRIBUTE_SLAVES,
+ 'none' => \RedisCluster::FAILOVER_NONE,
+ });
+
+ return $redis;
+ };
+
+ $redis = $params['lazy'] ? RedisClusterProxy::createLazyProxy($initializer) : $initializer();
+ } elseif (is_a($class, \Predis\ClientInterface::class, true)) {
+ if ($params['redis_cluster']) {
+ $params['cluster'] = 'redis';
+ } elseif (isset($params['redis_sentinel'])) {
+ $params['replication'] = 'sentinel';
+ $params['service'] = $params['redis_sentinel'];
+ }
+ $params += ['parameters' => []];
+ $params['parameters'] += [
+ 'persistent' => $params['persistent'],
+ 'timeout' => $params['timeout'],
+ 'read_write_timeout' => $params['read_timeout'],
+ 'tcp_nodelay' => true,
+ ];
+ if ($params['dbindex']) {
+ $params['parameters']['database'] = $params['dbindex'];
+ }
+ if (\is_array($params['auth'])) {
+ // ACL
+ $params['parameters']['username'] = $params['auth'][0];
+ $params['parameters']['password'] = $params['auth'][1];
+ } elseif (null !== $params['auth']) {
+ $params['parameters']['password'] = $params['auth'];
+ }
+
+ if (isset($params['ssl'])) {
+ foreach ($hosts as $i => $host) {
+ $hosts[$i]['ssl'] ??= $params['ssl'];
+ }
+ }
+
+ if (1 === \count($hosts) && !($params['redis_cluster'] || $params['redis_sentinel'])) {
+ $hosts = $hosts[0];
+ } elseif (\in_array($params['failover'], ['slaves', 'distribute'], true) && !isset($params['replication'])) {
+ $params['replication'] = true;
+ $hosts[0] += ['alias' => 'master'];
+ }
+ $params['exceptions'] = false;
+
+ $redis = new $class($hosts, array_diff_key($params, self::$defaultConnectionOptions));
+ if (isset($params['redis_sentinel'])) {
+ $redis->getConnection()->setSentinelTimeout($params['timeout']);
+ }
+ } elseif (class_exists($class, false)) {
+ throw new InvalidArgumentException(\sprintf('"%s" is not a subclass of "Redis", "RedisArray", "RedisCluster", "Relay\Relay" nor "Predis\ClientInterface".', $class));
+ } else {
+ throw new InvalidArgumentException(\sprintf('Class "%s" does not exist.', $class));
+ }
+
+ return $redis;
+ }
+
+ protected function doFetch(array $ids): iterable
+ {
+ if (!$ids) {
+ return [];
+ }
+
+ $result = [];
+
+ if (($this->redis instanceof \Predis\ClientInterface && ($this->redis->getConnection() instanceof ClusterInterface || $this->redis->getConnection() instanceof Predis2ClusterInterface)) || $this->redis instanceof RelayCluster) {
+ $values = $this->pipeline(function () use ($ids) {
+ foreach ($ids as $id) {
+ yield 'get' => [$id];
+ }
+ });
+ } else {
+ $values = $this->redis->mget($ids);
+
+ if (!\is_array($values) || \count($values) !== \count($ids)) {
+ return [];
+ }
+
+ $values = array_combine($ids, $values);
+ }
+
+ foreach ($values as $id => $v) {
+ if ($v) {
+ $result[$id] = $this->marshaller->unmarshall($v);
+ }
+ }
+
+ return $result;
+ }
+
+ protected function doHave(string $id): bool
+ {
+ return (bool) $this->redis->exists($id);
+ }
+
+ protected function doClear(string $namespace): bool
+ {
+ if ($this->redis instanceof \Predis\ClientInterface) {
+ $prefix = $this->redis->getOptions()->prefix ? $this->redis->getOptions()->prefix->getPrefix() : '';
+ $prefixLen = \strlen($prefix ?? '');
+ }
+
+ $cleared = true;
+ $hosts = $this->getHosts();
+ $host = reset($hosts);
+ if ($host instanceof \Predis\Client) {
+ $connection = $host->getConnection();
+
+ if ($connection instanceof ReplicationInterface) {
+ $hosts = [$host->getClientFor('master')];
+ } elseif ($connection instanceof Predis2ReplicationInterface) {
+ $connection->switchToMaster();
+
+ $hosts = [$host];
+ }
+ }
+
+ foreach ($hosts as $host) {
+ if (!isset($namespace[0])) {
+ $cleared = $host->flushDb() && $cleared;
+ continue;
+ }
+
+ $info = $host->info('Server');
+ $info = !$info instanceof ErrorInterface ? $info['Server'] ?? $info : ['redis_version' => '2.0'];
+
+ if ($host instanceof Relay) {
+ $prefix = Relay::SCAN_PREFIX & $host->getOption(Relay::OPT_SCAN) ? '' : $host->getOption(Relay::OPT_PREFIX);
+ $prefixLen = \strlen($host->getOption(Relay::OPT_PREFIX) ?? '');
+ } elseif (!$host instanceof \Predis\ClientInterface) {
+ $prefix = \defined('Redis::SCAN_PREFIX') && (\Redis::SCAN_PREFIX & $host->getOption(\Redis::OPT_SCAN)) ? '' : $host->getOption(\Redis::OPT_PREFIX);
+ $prefixLen = \strlen($host->getOption(\Redis::OPT_PREFIX) ?? '');
+ }
+ $pattern = $prefix.$namespace.'*';
+
+ if (!version_compare($info['redis_version'], '2.8', '>=')) {
+ // As documented in Redis documentation (http://redis.io/commands/keys) using KEYS
+ // can hang your server when it is executed against large databases (millions of items).
+ // Whenever you hit this scale, you should really consider upgrading to Redis 2.8 or above.
+ $unlink = version_compare($info['redis_version'], '4.0', '>=') ? 'UNLINK' : 'DEL';
+ $args = $this->redis instanceof \Predis\ClientInterface ? [0, $pattern] : [[$pattern], 0];
+ $cleared = $host->eval("local keys=redis.call('KEYS',ARGV[1]) for i=1,#keys,5000 do redis.call('$unlink',unpack(keys,i,math.min(i+4999,#keys))) end return 1", $args[0], $args[1]) && $cleared;
+ continue;
+ }
+
+ $cursor = null;
+ do {
+ $keys = $host instanceof \Predis\ClientInterface ? $host->scan($cursor ?? 0, 'MATCH', $pattern, 'COUNT', 1000) : $host->scan($cursor, $pattern, 1000);
+ if (isset($keys[1]) && \is_array($keys[1])) {
+ $cursor = $keys[0];
+ $keys = $keys[1];
+ }
+ if ($keys) {
+ if ($prefixLen) {
+ foreach ($keys as $i => $key) {
+ $keys[$i] = substr($key, $prefixLen);
+ }
+ }
+ $this->doDelete($keys);
+ }
+ } while ($cursor);
+ }
+
+ return $cleared;
+ }
+
+ protected function doDelete(array $ids): bool
+ {
+ if (!$ids) {
+ return true;
+ }
+
+ if ($this->redis instanceof \Predis\ClientInterface && ($this->redis->getConnection() instanceof ClusterInterface || $this->redis->getConnection() instanceof Predis2ClusterInterface)) {
+ static $del;
+ $del ??= (class_exists(UNLINK::class) ? 'unlink' : 'del');
+
+ $this->pipeline(function () use ($ids, $del) {
+ foreach ($ids as $id) {
+ yield $del => [$id];
+ }
+ })->rewind();
+ } else {
+ static $unlink = true;
+
+ if ($unlink) {
+ try {
+ $unlink = false !== $this->redis->unlink($ids);
+ } catch (\Throwable) {
+ $unlink = false;
+ }
+ }
+
+ if (!$unlink) {
+ $this->redis->del($ids);
+ }
+ }
+
+ return true;
+ }
+
+ protected function doSave(array $values, int $lifetime): array|bool
+ {
+ if (!$values = $this->marshaller->marshall($values, $failed)) {
+ return $failed;
+ }
+
+ $results = $this->pipeline(function () use ($values, $lifetime) {
+ foreach ($values as $id => $value) {
+ if (0 >= $lifetime) {
+ yield 'set' => [$id, $value];
+ } else {
+ yield 'setEx' => [$id, $lifetime, $value];
+ }
+ }
+ });
+
+ foreach ($results as $id => $result) {
+ if (true !== $result && (!$result instanceof Status || Status::get('OK') !== $result)) {
+ $failed[] = $id;
+ }
+ }
+
+ return $failed;
+ }
+
+ private function pipeline(\Closure $generator, ?object $redis = null): \Generator
+ {
+ $ids = [];
+ $redis ??= $this->redis;
+
+ if ($redis instanceof \RedisCluster || ($redis instanceof \Predis\ClientInterface && ($redis->getConnection() instanceof RedisCluster || $redis->getConnection() instanceof Predis2RedisCluster))) {
+ // phpredis & predis don't support pipelining with RedisCluster
+ // see https://github.com/phpredis/phpredis/blob/develop/cluster.markdown#pipelining
+ // see https://github.com/nrk/predis/issues/267#issuecomment-123781423
+ $results = [];
+ foreach ($generator() as $command => $args) {
+ $results[] = $redis->{$command}(...$args);
+ $ids[] = 'eval' === $command ? ($redis instanceof \Predis\ClientInterface ? $args[2] : $args[1][0]) : $args[0];
+ }
+ } elseif ($redis instanceof \Predis\ClientInterface) {
+ $results = $redis->pipeline(static function ($redis) use ($generator, &$ids) {
+ foreach ($generator() as $command => $args) {
+ $redis->{$command}(...$args);
+ $ids[] = 'eval' === $command ? $args[2] : $args[0];
+ }
+ });
+ } elseif ($redis instanceof \RedisArray) {
+ $connections = $results = $ids = [];
+ foreach ($generator() as $command => $args) {
+ $id = 'eval' === $command ? $args[1][0] : $args[0];
+ if (!isset($connections[$h = $redis->_target($id)])) {
+ $connections[$h] = [$redis->_instance($h), -1];
+ $connections[$h][0]->multi(\Redis::PIPELINE);
+ }
+ $connections[$h][0]->{$command}(...$args);
+ $results[] = [$h, ++$connections[$h][1]];
+ $ids[] = $id;
+ }
+ foreach ($connections as $h => $c) {
+ $connections[$h] = $c[0]->exec();
+ }
+ foreach ($results as $k => [$h, $c]) {
+ $results[$k] = $connections[$h][$c];
+ }
+ } else {
+ $redis->multi($redis instanceof Relay ? Relay::PIPELINE : \Redis::PIPELINE);
+ foreach ($generator() as $command => $args) {
+ $redis->{$command}(...$args);
+ $ids[] = 'eval' === $command ? $args[1][0] : $args[0];
+ }
+ $results = $redis->exec();
+ }
+
+ if (!$redis instanceof \Predis\ClientInterface && 'eval' === $command && $redis->getLastError()) {
+ $e = $redis instanceof Relay ? new \Relay\Exception($redis->getLastError()) : new \RedisException($redis->getLastError());
+ $results = array_map(fn ($v) => false === $v ? $e : $v, (array) $results);
+ }
+
+ if (\is_bool($results)) {
+ return;
+ }
+
+ foreach ($ids as $k => $id) {
+ yield $id => $results[$k];
+ }
+ }
+
+ private function getHosts(): array
+ {
+ $hosts = [$this->redis];
+ if ($this->redis instanceof \Predis\ClientInterface) {
+ $connection = $this->redis->getConnection();
+ if (($connection instanceof ClusterInterface || $connection instanceof Predis2ClusterInterface) && $connection instanceof \Traversable) {
+ $hosts = [];
+ foreach ($connection as $c) {
+ $hosts[] = new \Predis\Client($c);
+ }
+ }
+ } elseif ($this->redis instanceof \RedisArray) {
+ $hosts = [];
+ foreach ($this->redis->_hosts() as $host) {
+ $hosts[] = $this->redis->_instance($host);
+ }
+ } elseif ($this->redis instanceof \RedisCluster) {
+ $hosts = [];
+ foreach ($this->redis->_masters() as $host) {
+ $hosts[] = new RedisClusterNodeProxy($host, $this->redis);
+ }
+ }
+
+ return $hosts;
+ }
+}
diff --git a/symfony/cache/Traits/Relay/BgsaveTrait.php b/symfony/cache/Traits/Relay/BgsaveTrait.php
new file mode 100644
index 0000000000000000000000000000000000000000..367f82f7bb2b61b6c386a916d036c60c2ef18d7c
--- /dev/null
+++ b/symfony/cache/Traits/Relay/BgsaveTrait.php
@@ -0,0 +1,36 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Traits\Relay;
+
+if (version_compare(phpversion('relay'), '0.11', '>=')) {
+ /**
+ * @internal
+ */
+ trait BgsaveTrait
+ {
+ public function bgsave($arg = null): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->bgsave(...\func_get_args());
+ }
+ }
+} else {
+ /**
+ * @internal
+ */
+ trait BgsaveTrait
+ {
+ public function bgsave($schedule = false): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->bgsave(...\func_get_args());
+ }
+ }
+}
diff --git a/symfony/cache/Traits/Relay/CopyTrait.php b/symfony/cache/Traits/Relay/CopyTrait.php
new file mode 100644
index 0000000000000000000000000000000000000000..a271a9d1039a36821fd2d068ef0a4a179b039a08
--- /dev/null
+++ b/symfony/cache/Traits/Relay/CopyTrait.php
@@ -0,0 +1,36 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Traits\Relay;
+
+if (version_compare(phpversion('relay'), '0.8.1', '>=')) {
+ /**
+ * @internal
+ */
+ trait CopyTrait
+ {
+ public function copy($src, $dst, $options = null): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->copy(...\func_get_args());
+ }
+ }
+} else {
+ /**
+ * @internal
+ */
+ trait CopyTrait
+ {
+ public function copy($src, $dst, $options = null): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->copy(...\func_get_args());
+ }
+ }
+}
diff --git a/symfony/cache/Traits/Relay/FtTrait.php b/symfony/cache/Traits/Relay/FtTrait.php
new file mode 100644
index 0000000000000000000000000000000000000000..1abf0455bf1a07eecaf0afeb0c466f588660c046
--- /dev/null
+++ b/symfony/cache/Traits/Relay/FtTrait.php
@@ -0,0 +1,132 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Traits\Relay;
+
+if (version_compare(phpversion('relay'), '0.9.0', '>=')) {
+ /**
+ * @internal
+ */
+ trait FtTrait
+ {
+ public function ftAggregate($index, $query, $options = null): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftAggregate(...\func_get_args());
+ }
+
+ public function ftAliasAdd($index, $alias): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftAliasAdd(...\func_get_args());
+ }
+
+ public function ftAliasDel($alias): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftAliasDel(...\func_get_args());
+ }
+
+ public function ftAliasUpdate($index, $alias): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftAliasUpdate(...\func_get_args());
+ }
+
+ public function ftAlter($index, $schema, $skipinitialscan = false): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftAlter(...\func_get_args());
+ }
+
+ public function ftConfig($operation, $option, $value = null): \Relay\Relay|array|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftConfig(...\func_get_args());
+ }
+
+ public function ftCreate($index, $schema, $options = null): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftCreate(...\func_get_args());
+ }
+
+ public function ftCursor($operation, $index, $cursor, $options = null): \Relay\Relay|array|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftCursor(...\func_get_args());
+ }
+
+ public function ftDictAdd($dict, $term, ...$other_terms): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftDictAdd(...\func_get_args());
+ }
+
+ public function ftDictDel($dict, $term, ...$other_terms): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftDictDel(...\func_get_args());
+ }
+
+ public function ftDictDump($dict): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftDictDump(...\func_get_args());
+ }
+
+ public function ftDropIndex($index, $dd = false): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftDropIndex(...\func_get_args());
+ }
+
+ public function ftExplain($index, $query, $dialect = 0): \Relay\Relay|false|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftExplain(...\func_get_args());
+ }
+
+ public function ftExplainCli($index, $query, $dialect = 0): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftExplainCli(...\func_get_args());
+ }
+
+ public function ftInfo($index): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftInfo(...\func_get_args());
+ }
+
+ public function ftProfile($index, $command, $query, $limited = false): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftProfile(...\func_get_args());
+ }
+
+ public function ftSearch($index, $query, $options = null): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftSearch(...\func_get_args());
+ }
+
+ public function ftSpellCheck($index, $query, $options = null): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftSpellCheck(...\func_get_args());
+ }
+
+ public function ftSynDump($index): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftSynDump(...\func_get_args());
+ }
+
+ public function ftSynUpdate($index, $synonym, $term_or_terms, $skipinitialscan = false): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftSynUpdate(...\func_get_args());
+ }
+
+ public function ftTagVals($index, $tag): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ftTagVals(...\func_get_args());
+ }
+ }
+} else {
+ /**
+ * @internal
+ */
+ trait FtTrait
+ {
+ }
+}
diff --git a/symfony/cache/Traits/Relay/GeosearchTrait.php b/symfony/cache/Traits/Relay/GeosearchTrait.php
new file mode 100644
index 0000000000000000000000000000000000000000..88ed1e9d30002703165c6af2780c22db1ee6d752
--- /dev/null
+++ b/symfony/cache/Traits/Relay/GeosearchTrait.php
@@ -0,0 +1,36 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Traits\Relay;
+
+if (version_compare(phpversion('relay'), '0.9.0', '>=')) {
+ /**
+ * @internal
+ */
+ trait GeosearchTrait
+ {
+ public function geosearch($key, $position, $shape, $unit, $options = []): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->geosearch(...\func_get_args());
+ }
+ }
+} else {
+ /**
+ * @internal
+ */
+ trait GeosearchTrait
+ {
+ public function geosearch($key, $position, $shape, $unit, $options = []): \Relay\Relay|array
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->geosearch(...\func_get_args());
+ }
+ }
+}
diff --git a/symfony/cache/Traits/Relay/GetWithMetaTrait.php b/symfony/cache/Traits/Relay/GetWithMetaTrait.php
new file mode 100644
index 0000000000000000000000000000000000000000..d0643c339e2cc523e73bbaec7c7fb80c8cf0ea72
--- /dev/null
+++ b/symfony/cache/Traits/Relay/GetWithMetaTrait.php
@@ -0,0 +1,32 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Traits\Relay;
+
+if (version_compare(phpversion('relay'), '0.10.1', '>=')) {
+ /**
+ * @internal
+ */
+ trait GetWithMetaTrait
+ {
+ public function getWithMeta($key): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getWithMeta(...\func_get_args());
+ }
+ }
+} else {
+ /**
+ * @internal
+ */
+ trait GetWithMetaTrait
+ {
+ }
+}
diff --git a/symfony/cache/Traits/Relay/GetrangeTrait.php b/symfony/cache/Traits/Relay/GetrangeTrait.php
new file mode 100644
index 0000000000000000000000000000000000000000..4522d20b5968f1c47efc344e32e23ca1b66f2571
--- /dev/null
+++ b/symfony/cache/Traits/Relay/GetrangeTrait.php
@@ -0,0 +1,36 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Traits\Relay;
+
+if (version_compare(phpversion('relay'), '0.9.0', '>=')) {
+ /**
+ * @internal
+ */
+ trait GetrangeTrait
+ {
+ public function getrange($key, $start, $end): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getrange(...\func_get_args());
+ }
+ }
+} else {
+ /**
+ * @internal
+ */
+ trait GetrangeTrait
+ {
+ public function getrange($key, $start, $end): \Relay\Relay|false|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getrange(...\func_get_args());
+ }
+ }
+}
diff --git a/symfony/cache/Traits/Relay/HsetTrait.php b/symfony/cache/Traits/Relay/HsetTrait.php
new file mode 100644
index 0000000000000000000000000000000000000000..a7cb8fff07a0d6b888d72f690f298972793e7aa2
--- /dev/null
+++ b/symfony/cache/Traits/Relay/HsetTrait.php
@@ -0,0 +1,36 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Traits\Relay;
+
+if (version_compare(phpversion('relay'), '0.9.0', '>=')) {
+ /**
+ * @internal
+ */
+ trait HsetTrait
+ {
+ public function hset($key, ...$keys_and_vals): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hset(...\func_get_args());
+ }
+ }
+} else {
+ /**
+ * @internal
+ */
+ trait HsetTrait
+ {
+ public function hset($key, $mem, $val, ...$kvals): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hset(...\func_get_args());
+ }
+ }
+}
diff --git a/symfony/cache/Traits/Relay/IsTrackedTrait.php b/symfony/cache/Traits/Relay/IsTrackedTrait.php
new file mode 100644
index 0000000000000000000000000000000000000000..8055e2e92c7b7813cc9344e52880f7cddfc4c417
--- /dev/null
+++ b/symfony/cache/Traits/Relay/IsTrackedTrait.php
@@ -0,0 +1,32 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Traits\Relay;
+
+if (version_compare(phpversion('relay'), '0.11.1', '>=')) {
+ /**
+ * @internal
+ */
+ trait IsTrackedTrait
+ {
+ public function isTracked($key): bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->isTracked(...\func_get_args());
+ }
+ }
+} else {
+ /**
+ * @internal
+ */
+ trait IsTrackedTrait
+ {
+ }
+}
diff --git a/symfony/cache/Traits/Relay/MoveTrait.php b/symfony/cache/Traits/Relay/MoveTrait.php
new file mode 100644
index 0000000000000000000000000000000000000000..358e52f6165c8b8362ea250b5bd8f307674d8877
--- /dev/null
+++ b/symfony/cache/Traits/Relay/MoveTrait.php
@@ -0,0 +1,46 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Traits\Relay;
+
+if (version_compare(phpversion('relay'), '0.9.0', '>=')) {
+ /**
+ * @internal
+ */
+ trait MoveTrait
+ {
+ public function blmove($srckey, $dstkey, $srcpos, $dstpos, $timeout): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->blmove(...\func_get_args());
+ }
+
+ public function lmove($srckey, $dstkey, $srcpos, $dstpos): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lmove(...\func_get_args());
+ }
+ }
+} else {
+ /**
+ * @internal
+ */
+ trait MoveTrait
+ {
+ public function blmove($srckey, $dstkey, $srcpos, $dstpos, $timeout): \Relay\Relay|false|string|null
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->blmove(...\func_get_args());
+ }
+
+ public function lmove($srckey, $dstkey, $srcpos, $dstpos): \Relay\Relay|false|string|null
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lmove(...\func_get_args());
+ }
+ }
+}
diff --git a/symfony/cache/Traits/Relay/NullableReturnTrait.php b/symfony/cache/Traits/Relay/NullableReturnTrait.php
new file mode 100644
index 0000000000000000000000000000000000000000..0b7409045db1fabfb7578dd3283f7390f133f309
--- /dev/null
+++ b/symfony/cache/Traits/Relay/NullableReturnTrait.php
@@ -0,0 +1,96 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Traits\Relay;
+
+if (version_compare(phpversion('relay'), '0.9.0', '>=')) {
+ /**
+ * @internal
+ */
+ trait NullableReturnTrait
+ {
+ public function dump($key): \Relay\Relay|false|string|null
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->dump(...\func_get_args());
+ }
+
+ public function geodist($key, $src, $dst, $unit = null): \Relay\Relay|false|float|null
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->geodist(...\func_get_args());
+ }
+
+ public function hrandfield($hash, $options = null): \Relay\Relay|array|false|string|null
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hrandfield(...\func_get_args());
+ }
+
+ public function xadd($key, $id, $values, $maxlen = 0, $approx = false, $nomkstream = false): \Relay\Relay|false|string|null
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xadd(...\func_get_args());
+ }
+
+ public function zrank($key, $rank, $withscore = false): \Relay\Relay|array|false|int|null
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zrank(...\func_get_args());
+ }
+
+ public function zrevrank($key, $rank, $withscore = false): \Relay\Relay|array|false|int|null
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zrevrank(...\func_get_args());
+ }
+
+ public function zscore($key, $member): \Relay\Relay|false|float|null
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zscore(...\func_get_args());
+ }
+ }
+} else {
+ /**
+ * @internal
+ */
+ trait NullableReturnTrait
+ {
+ public function dump($key): \Relay\Relay|false|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->dump(...\func_get_args());
+ }
+
+ public function geodist($key, $src, $dst, $unit = null): \Relay\Relay|false|float
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->geodist(...\func_get_args());
+ }
+
+ public function hrandfield($hash, $options = null): \Relay\Relay|array|false|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hrandfield(...\func_get_args());
+ }
+
+ public function xadd($key, $id, $values, $maxlen = 0, $approx = false, $nomkstream = false): \Relay\Relay|false|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xadd(...\func_get_args());
+ }
+
+ public function zrank($key, $rank, $withscore = false): \Relay\Relay|array|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zrank(...\func_get_args());
+ }
+
+ public function zrevrank($key, $rank, $withscore = false): \Relay\Relay|array|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zrevrank(...\func_get_args());
+ }
+
+ public function zscore($key, $member): \Relay\Relay|false|float
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zscore(...\func_get_args());
+ }
+ }
+}
diff --git a/symfony/cache/Traits/Relay/PfcountTrait.php b/symfony/cache/Traits/Relay/PfcountTrait.php
new file mode 100644
index 0000000000000000000000000000000000000000..340db8af75d6d635c9f837aa5963d513465c25fd
--- /dev/null
+++ b/symfony/cache/Traits/Relay/PfcountTrait.php
@@ -0,0 +1,36 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Traits\Relay;
+
+if (version_compare(phpversion('relay'), '0.9.0', '>=')) {
+ /**
+ * @internal
+ */
+ trait PfcountTrait
+ {
+ public function pfcount($key_or_keys): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->pfcount(...\func_get_args());
+ }
+ }
+} else {
+ /**
+ * @internal
+ */
+ trait PfcountTrait
+ {
+ public function pfcount($key): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->pfcount(...\func_get_args());
+ }
+ }
+}
diff --git a/symfony/cache/Traits/Relay/Relay11Trait.php b/symfony/cache/Traits/Relay/Relay11Trait.php
new file mode 100644
index 0000000000000000000000000000000000000000..289d8faa0778c3d62fcacb50c393c183bceecfd1
--- /dev/null
+++ b/symfony/cache/Traits/Relay/Relay11Trait.php
@@ -0,0 +1,132 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Traits\Relay;
+
+if (version_compare(phpversion('relay'), '0.11.0', '>=')) {
+ /**
+ * @internal
+ */
+ trait Relay11Trait
+ {
+ public function cmsIncrBy($key, $field, $value, ...$fields_and_falues): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->cmsIncrBy(...\func_get_args());
+ }
+
+ public function cmsInfo($key): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->cmsInfo(...\func_get_args());
+ }
+
+ public function cmsInitByDim($key, $width, $depth): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->cmsInitByDim(...\func_get_args());
+ }
+
+ public function cmsInitByProb($key, $error, $probability): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->cmsInitByProb(...\func_get_args());
+ }
+
+ public function cmsMerge($dstkey, $keys, $weights = []): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->cmsMerge(...\func_get_args());
+ }
+
+ public function cmsQuery($key, ...$fields): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->cmsQuery(...\func_get_args());
+ }
+
+ public function commandlog($subcmd, ...$args): \Relay\Relay|array|bool|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->commandlog(...\func_get_args());
+ }
+
+ public function hexpire($hash, $ttl, $fields, $mode = null): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hexpire(...\func_get_args());
+ }
+
+ public function hexpireat($hash, $ttl, $fields, $mode = null): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hexpireat(...\func_get_args());
+ }
+
+ public function hexpiretime($hash, $fields): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hexpiretime(...\func_get_args());
+ }
+
+ public function hgetdel($key, $fields): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hgetdel(...\func_get_args());
+ }
+
+ public function hgetex($hash, $fields, $expiry = null): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hgetex(...\func_get_args());
+ }
+
+ public function hpersist($hash, $fields): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hpersist(...\func_get_args());
+ }
+
+ public function hpexpire($hash, $ttl, $fields, $mode = null): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hpexpire(...\func_get_args());
+ }
+
+ public function hpexpireat($hash, $ttl, $fields, $mode = null): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hpexpireat(...\func_get_args());
+ }
+
+ public function hpexpiretime($hash, $fields): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hpexpiretime(...\func_get_args());
+ }
+
+ public function hpttl($hash, $fields): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hpttl(...\func_get_args());
+ }
+
+ public function hsetex($key, $fields, $expiry = null): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hsetex(...\func_get_args());
+ }
+
+ public function httl($hash, $fields): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->httl(...\func_get_args());
+ }
+
+ public function serverName(): false|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->serverName(...\func_get_args());
+ }
+
+ public function serverVersion(): false|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->serverVersion(...\func_get_args());
+ }
+ }
+} else {
+ /**
+ * @internal
+ */
+ trait Relay11Trait
+ {
+ }
+}
diff --git a/symfony/cache/Traits/Relay/Relay121Trait.php b/symfony/cache/Traits/Relay/Relay121Trait.php
new file mode 100644
index 0000000000000000000000000000000000000000..da222ba8f4323ac5f6da269affc08647b871bd08
--- /dev/null
+++ b/symfony/cache/Traits/Relay/Relay121Trait.php
@@ -0,0 +1,51 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Traits\Relay;
+
+if (version_compare(phpversion('relay'), '0.12.1', '>=')) {
+ /**
+ * @internal
+ */
+ trait Relay121Trait
+ {
+ public function hgetWithMeta($hash, $member): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hgetWithMeta(...\func_get_args());
+ }
+
+ public function select($db): \Relay\Relay|bool|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->select(...\func_get_args());
+ }
+
+ public function watch($key, ...$other_keys): \Relay\Relay|bool|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->watch(...\func_get_args());
+ }
+ }
+} else {
+ /**
+ * @internal
+ */
+ trait Relay121Trait
+ {
+ public function select($db): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->select(...\func_get_args());
+ }
+
+ public function watch($key, ...$other_keys): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->watch(...\func_get_args());
+ }
+ }
+}
diff --git a/symfony/cache/Traits/Relay/Relay12Trait.php b/symfony/cache/Traits/Relay/Relay12Trait.php
new file mode 100644
index 0000000000000000000000000000000000000000..26df3211feaf80cc0be50ffe0189ff349a62c631
--- /dev/null
+++ b/symfony/cache/Traits/Relay/Relay12Trait.php
@@ -0,0 +1,107 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Traits\Relay;
+
+if (version_compare(phpversion('relay'), '0.12.0', '>=')) {
+ /**
+ * @internal
+ */
+ trait Relay12Trait
+ {
+ public function delifeq($key, $value): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->delifeq(...\func_get_args());
+ }
+
+ public function vadd($key, $values, $element, $options = null): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->vadd(...\func_get_args());
+ }
+
+ public function vcard($key): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->vcard(...\func_get_args());
+ }
+
+ public function vdim($key): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->vdim(...\func_get_args());
+ }
+
+ public function vemb($key, $element, $raw = false): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->vemb(...\func_get_args());
+ }
+
+ public function vgetattr($key, $element, $raw = false): \Relay\Relay|array|false|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->vgetattr(...\func_get_args());
+ }
+
+ public function vinfo($key): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->vinfo(...\func_get_args());
+ }
+
+ public function vismember($key, $element): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->vismember(...\func_get_args());
+ }
+
+ public function vlinks($key, $element, $withscores): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->vlinks(...\func_get_args());
+ }
+
+ public function vrandmember($key, $count = 0): \Relay\Relay|array|false|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->vrandmember(...\func_get_args());
+ }
+
+ public function vrange($key, $min, $max, $count = -1): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->vrange(...\func_get_args());
+ }
+
+ public function vrem($key, $element): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->vrem(...\func_get_args());
+ }
+
+ public function vsetattr($key, $element, $attributes): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->vsetattr(...\func_get_args());
+ }
+
+ public function vsim($key, $member, $options = null): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->vsim(...\func_get_args());
+ }
+
+ public function xdelex($key, $ids, $mode = null): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xdelex(...\func_get_args());
+ }
+
+ public function xackdel($key, $group, $ids, $mode = null): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xackdel(...\func_get_args());
+ }
+ }
+} else {
+ /**
+ * @internal
+ */
+ trait Relay12Trait
+ {
+ }
+}
diff --git a/symfony/cache/Traits/Relay/Relay20Trait.php b/symfony/cache/Traits/Relay/Relay20Trait.php
new file mode 100644
index 0000000000000000000000000000000000000000..b062ca9a686a9205ea6b77d25e949e61337998ad
--- /dev/null
+++ b/symfony/cache/Traits/Relay/Relay20Trait.php
@@ -0,0 +1,47 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Traits\Relay;
+
+if (version_compare(phpversion('relay'), '0.20.0', '>=')) {
+ /**
+ * @internal
+ */
+ trait Relay20Trait
+ {
+ public function _digest($value): string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->_digest(...\func_get_args());
+ }
+
+ public function delex($key, $options = null): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->delex(...\func_get_args());
+ }
+
+ public function digest($key): \Relay\Relay|false|null|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->digest(...\func_get_args());
+ }
+
+ public function msetex($kvals, $ttl = null): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->msetx(...\func_get_args());
+ }
+ }
+} else {
+ /**
+ * @internal
+ */
+ trait Relay20Trait
+ {
+ }
+}
diff --git a/symfony/cache/Traits/Relay/SwapdbTrait.php b/symfony/cache/Traits/Relay/SwapdbTrait.php
new file mode 100644
index 0000000000000000000000000000000000000000..8ae0a079d6c6c51fc0c350c608e3d817a06a8db9
--- /dev/null
+++ b/symfony/cache/Traits/Relay/SwapdbTrait.php
@@ -0,0 +1,32 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Traits\Relay;
+
+if (version_compare(phpversion('relay'), '0.9.0', '>=')) {
+ /**
+ * @internal
+ */
+ trait SwapdbTrait
+ {
+ public function swapdb($index1, $index2): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->swapdb(...\func_get_args());
+ }
+ }
+} else {
+ /**
+ * @internal
+ */
+ trait SwapdbTrait
+ {
+ }
+}
diff --git a/symfony/cache/Traits/RelayProxy.php b/symfony/cache/Traits/RelayProxy.php
new file mode 100644
index 0000000000000000000000000000000000000000..8933e93ac7954092bbbd7d49eade848edaf1145c
--- /dev/null
+++ b/symfony/cache/Traits/RelayProxy.php
@@ -0,0 +1,1271 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Traits;
+
+use Symfony\Component\Cache\Traits\Relay\BgsaveTrait;
+use Symfony\Component\Cache\Traits\Relay\CopyTrait;
+use Symfony\Component\Cache\Traits\Relay\FtTrait;
+use Symfony\Component\Cache\Traits\Relay\GeosearchTrait;
+use Symfony\Component\Cache\Traits\Relay\GetrangeTrait;
+use Symfony\Component\Cache\Traits\Relay\GetWithMetaTrait;
+use Symfony\Component\Cache\Traits\Relay\HsetTrait;
+use Symfony\Component\Cache\Traits\Relay\IsTrackedTrait;
+use Symfony\Component\Cache\Traits\Relay\MoveTrait;
+use Symfony\Component\Cache\Traits\Relay\NullableReturnTrait;
+use Symfony\Component\Cache\Traits\Relay\PfcountTrait;
+use Symfony\Component\Cache\Traits\Relay\Relay11Trait;
+use Symfony\Component\Cache\Traits\Relay\Relay121Trait;
+use Symfony\Component\Cache\Traits\Relay\Relay12Trait;
+use Symfony\Component\Cache\Traits\Relay\Relay20Trait;
+use Symfony\Component\Cache\Traits\Relay\SwapdbTrait;
+use Symfony\Component\VarExporter\LazyObjectInterface;
+use Symfony\Component\VarExporter\LazyProxyTrait;
+use Symfony\Contracts\Service\ResetInterface;
+
+// Help opcache.preload discover always-needed symbols
+class_exists(\Symfony\Component\VarExporter\Internal\Hydrator::class);
+class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectRegistry::class);
+class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectState::class);
+
+/**
+ * @internal
+ */
+class RelayProxy extends \Relay\Relay implements ResetInterface, LazyObjectInterface
+{
+ use BgsaveTrait;
+ use CopyTrait;
+ use FtTrait;
+ use GeosearchTrait;
+ use GetrangeTrait;
+ use GetWithMetaTrait;
+ use HsetTrait;
+ use IsTrackedTrait;
+ use LazyProxyTrait {
+ resetLazyObject as reset;
+ }
+ use MoveTrait;
+ use NullableReturnTrait;
+ use PfcountTrait;
+ use RelayProxyTrait;
+ use Relay11Trait;
+ use Relay12Trait;
+ use Relay121Trait;
+ use Relay20Trait;
+ use SwapdbTrait;
+
+ private const LAZY_OBJECT_PROPERTY_SCOPES = [];
+
+ public function __construct($host = null, $port = 6379, $connect_timeout = 0.0, $command_timeout = 0.0, #[\SensitiveParameter] $context = [], $database = 0)
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->__construct(...\func_get_args());
+ }
+
+ public function connect($host, $port = 6379, $timeout = 0.0, $persistent_id = null, $retry_interval = 0, $read_timeout = 0.0, #[\SensitiveParameter] $context = [], $database = 0): bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->connect(...\func_get_args());
+ }
+
+ public function pconnect($host, $port = 6379, $timeout = 0.0, $persistent_id = null, $retry_interval = 0, $read_timeout = 0.0, #[\SensitiveParameter] $context = [], $database = 0): bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->pconnect(...\func_get_args());
+ }
+
+ public function close(): bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->close(...\func_get_args());
+ }
+
+ public function pclose(): bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->pclose(...\func_get_args());
+ }
+
+ public function listen($callback): bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->listen(...\func_get_args());
+ }
+
+ public function onFlushed($callback): bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->onFlushed(...\func_get_args());
+ }
+
+ public function onInvalidated($callback, $pattern = null): bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->onInvalidated(...\func_get_args());
+ }
+
+ public function dispatchEvents(): false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->dispatchEvents(...\func_get_args());
+ }
+
+ public function getOption($option): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getOption(...\func_get_args());
+ }
+
+ public function option($option, $value = null): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->option(...\func_get_args());
+ }
+
+ public function setOption($option, $value): bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->setOption(...\func_get_args());
+ }
+
+ public function addIgnorePatterns(...$pattern): int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->addIgnorePatterns(...\func_get_args());
+ }
+
+ public function addAllowPatterns(...$pattern): int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->addAllowPatterns(...\func_get_args());
+ }
+
+ public function getTimeout(): false|float
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getTimeout(...\func_get_args());
+ }
+
+ public function timeout(): false|float
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->timeout(...\func_get_args());
+ }
+
+ public function getReadTimeout(): false|float
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getReadTimeout(...\func_get_args());
+ }
+
+ public function readTimeout(): false|float
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->readTimeout(...\func_get_args());
+ }
+
+ public function getBytes(): array
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getBytes(...\func_get_args());
+ }
+
+ public function bytes(): array
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->bytes(...\func_get_args());
+ }
+
+ public function getHost(): false|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getHost(...\func_get_args());
+ }
+
+ public function isConnected(): bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->isConnected(...\func_get_args());
+ }
+
+ public function getPort(): false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getPort(...\func_get_args());
+ }
+
+ public function getAuth(): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getAuth(...\func_get_args());
+ }
+
+ public function getDbNum(): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getDbNum(...\func_get_args());
+ }
+
+ public function _serialize($value): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->_serialize(...\func_get_args());
+ }
+
+ public function _unserialize($value): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->_unserialize(...\func_get_args());
+ }
+
+ public function _compress($value): string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->_compress(...\func_get_args());
+ }
+
+ public function _uncompress($value): string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->_uncompress(...\func_get_args());
+ }
+
+ public function _pack($value): string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->_pack(...\func_get_args());
+ }
+
+ public function _unpack($value): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->_unpack(...\func_get_args());
+ }
+
+ public function _prefix($value): string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->_prefix(...\func_get_args());
+ }
+
+ public function getLastError(): ?string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getLastError(...\func_get_args());
+ }
+
+ public function clearLastError(): bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->clearLastError(...\func_get_args());
+ }
+
+ public function endpointId(): false|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->endpointId(...\func_get_args());
+ }
+
+ public function getPersistentID(): false|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getPersistentID(...\func_get_args());
+ }
+
+ public function socketId(): false|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->socketId(...\func_get_args());
+ }
+
+ public function rawCommand($cmd, ...$args): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->rawCommand(...\func_get_args());
+ }
+
+ public function auth(#[\SensitiveParameter] $auth): bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->auth(...\func_get_args());
+ }
+
+ public function info(...$sections): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->info(...\func_get_args());
+ }
+
+ public function flushdb($sync = null): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->flushdb(...\func_get_args());
+ }
+
+ public function flushall($sync = null): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->flushall(...\func_get_args());
+ }
+
+ public function fcall($name, $keys = [], $argv = [], $handler = null): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->fcall(...\func_get_args());
+ }
+
+ public function fcall_ro($name, $keys = [], $argv = [], $handler = null): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->fcall_ro(...\func_get_args());
+ }
+
+ public function function($op, ...$args): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->function(...\func_get_args());
+ }
+
+ public function dbsize(): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->dbsize(...\func_get_args());
+ }
+
+ public function replicaof($host = null, $port = 0): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->replicaof(...\func_get_args());
+ }
+
+ public function waitaof($numlocal, $numremote, $timeout): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->waitaof(...\func_get_args());
+ }
+
+ public function restore($key, $ttl, $value, $options = null): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->restore(...\func_get_args());
+ }
+
+ public function migrate($host, $port, $key, $dstdb, $timeout, $copy = false, $replace = false, #[\SensitiveParameter] $credentials = null): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->migrate(...\func_get_args());
+ }
+
+ public function echo($arg): \Relay\Relay|bool|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->echo(...\func_get_args());
+ }
+
+ public function ping($arg = null): \Relay\Relay|bool|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ping(...\func_get_args());
+ }
+
+ public function idleTime(): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->idleTime(...\func_get_args());
+ }
+
+ public function randomkey(): \Relay\Relay|bool|null|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->randomkey(...\func_get_args());
+ }
+
+ public function time(): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->time(...\func_get_args());
+ }
+
+ public function bgrewriteaof(): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->bgrewriteaof(...\func_get_args());
+ }
+
+ public function lastsave(): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lastsave(...\func_get_args());
+ }
+
+ public function lcs($key1, $key2, $options = null): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lcs(...\func_get_args());
+ }
+
+ public function save(): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->save(...\func_get_args());
+ }
+
+ public function role(): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->role(...\func_get_args());
+ }
+
+ public function ttl($key): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ttl(...\func_get_args());
+ }
+
+ public function pttl($key): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->pttl(...\func_get_args());
+ }
+
+ public function exists(...$keys): \Relay\Relay|bool|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->exists(...\func_get_args());
+ }
+
+ public function eval($script, $args = [], $num_keys = 0): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->eval(...\func_get_args());
+ }
+
+ public function eval_ro($script, $args = [], $num_keys = 0): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->eval_ro(...\func_get_args());
+ }
+
+ public function evalsha($sha, $args = [], $num_keys = 0): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->evalsha(...\func_get_args());
+ }
+
+ public function evalsha_ro($sha, $args = [], $num_keys = 0): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->evalsha_ro(...\func_get_args());
+ }
+
+ public function client($operation, ...$args): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->client(...\func_get_args());
+ }
+
+ public function geoadd($key, $lng, $lat, $member, ...$other_triples_and_options): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->geoadd(...\func_get_args());
+ }
+
+ public function geohash($key, $member, ...$other_members): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->geohash(...\func_get_args());
+ }
+
+ public function georadius($key, $lng, $lat, $radius, $unit, $options = []): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->georadius(...\func_get_args());
+ }
+
+ public function georadiusbymember($key, $member, $radius, $unit, $options = []): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->georadiusbymember(...\func_get_args());
+ }
+
+ public function georadiusbymember_ro($key, $member, $radius, $unit, $options = []): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->georadiusbymember_ro(...\func_get_args());
+ }
+
+ public function georadius_ro($key, $lng, $lat, $radius, $unit, $options = []): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->georadius_ro(...\func_get_args());
+ }
+
+ public function geosearchstore($dst, $src, $position, $shape, $unit, $options = []): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->geosearchstore(...\func_get_args());
+ }
+
+ public function get($key): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->get(...\func_get_args());
+ }
+
+ public function getset($key, $value): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getset(...\func_get_args());
+ }
+
+ public function setrange($key, $start, $value): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->setrange(...\func_get_args());
+ }
+
+ public function getbit($key, $pos): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getbit(...\func_get_args());
+ }
+
+ public function bitcount($key, $start = 0, $end = -1, $by_bit = false): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->bitcount(...\func_get_args());
+ }
+
+ public function bitfield($key, ...$args): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->bitfield(...\func_get_args());
+ }
+
+ public function config($operation, $key = null, $value = null): \Relay\Relay|array|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->config(...\func_get_args());
+ }
+
+ public function command(...$args): \Relay\Relay|array|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->command(...\func_get_args());
+ }
+
+ public function bitop($operation, $dstkey, $srckey, ...$other_keys): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->bitop(...\func_get_args());
+ }
+
+ public function bitpos($key, $bit, $start = null, $end = null, $bybit = false): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->bitpos(...\func_get_args());
+ }
+
+ public function setbit($key, $pos, $val): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->setbit(...\func_get_args());
+ }
+
+ public function acl($cmd, ...$args): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->acl(...\func_get_args());
+ }
+
+ public function append($key, $value): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->append(...\func_get_args());
+ }
+
+ public function set($key, $value, $options = null): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->set(...\func_get_args());
+ }
+
+ public function getex($key, $options = null): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getex(...\func_get_args());
+ }
+
+ public function getdel($key): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getdel(...\func_get_args());
+ }
+
+ public function setex($key, $seconds, $value): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->setex(...\func_get_args());
+ }
+
+ public function pfadd($key, $elements): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->pfadd(...\func_get_args());
+ }
+
+ public function pfmerge($dst, $srckeys): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->pfmerge(...\func_get_args());
+ }
+
+ public function psetex($key, $milliseconds, $value): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->psetex(...\func_get_args());
+ }
+
+ public function publish($channel, $message): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->publish(...\func_get_args());
+ }
+
+ public function pubsub($operation, ...$args): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->pubsub(...\func_get_args());
+ }
+
+ public function spublish($channel, $message): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->spublish(...\func_get_args());
+ }
+
+ public function setnx($key, $value): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->setnx(...\func_get_args());
+ }
+
+ public function mget($keys): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->mget(...\func_get_args());
+ }
+
+ public function move($key, $db): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->move(...\func_get_args());
+ }
+
+ public function mset($kvals): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->mset(...\func_get_args());
+ }
+
+ public function msetnx($kvals): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->msetnx(...\func_get_args());
+ }
+
+ public function rename($key, $newkey): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->rename(...\func_get_args());
+ }
+
+ public function renamenx($key, $newkey): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->renamenx(...\func_get_args());
+ }
+
+ public function del(...$keys): \Relay\Relay|bool|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->del(...\func_get_args());
+ }
+
+ public function unlink(...$keys): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->unlink(...\func_get_args());
+ }
+
+ public function expire($key, $seconds, $mode = null): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->expire(...\func_get_args());
+ }
+
+ public function pexpire($key, $milliseconds): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->pexpire(...\func_get_args());
+ }
+
+ public function expireat($key, $timestamp): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->expireat(...\func_get_args());
+ }
+
+ public function expiretime($key): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->expiretime(...\func_get_args());
+ }
+
+ public function pexpireat($key, $timestamp_ms): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->pexpireat(...\func_get_args());
+ }
+
+ public function pexpiretime($key): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->pexpiretime(...\func_get_args());
+ }
+
+ public function persist($key): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->persist(...\func_get_args());
+ }
+
+ public function type($key): \Relay\Relay|bool|int|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->type(...\func_get_args());
+ }
+
+ public function lrange($key, $start, $stop): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lrange(...\func_get_args());
+ }
+
+ public function lpush($key, $mem, ...$mems): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lpush(...\func_get_args());
+ }
+
+ public function rpush($key, $mem, ...$mems): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->rpush(...\func_get_args());
+ }
+
+ public function lpushx($key, $mem, ...$mems): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lpushx(...\func_get_args());
+ }
+
+ public function rpushx($key, $mem, ...$mems): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->rpushx(...\func_get_args());
+ }
+
+ public function lset($key, $index, $mem): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lset(...\func_get_args());
+ }
+
+ public function lpop($key, $count = 1): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lpop(...\func_get_args());
+ }
+
+ public function lpos($key, $value, $options = null): \Relay\Relay|array|false|int|null
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lpos(...\func_get_args());
+ }
+
+ public function rpop($key, $count = 1): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->rpop(...\func_get_args());
+ }
+
+ public function rpoplpush($source, $dest): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->rpoplpush(...\func_get_args());
+ }
+
+ public function brpoplpush($source, $dest, $timeout): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->brpoplpush(...\func_get_args());
+ }
+
+ public function blpop($key, $timeout_or_key, ...$extra_args): \Relay\Relay|array|false|null
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->blpop(...\func_get_args());
+ }
+
+ public function blmpop($timeout, $keys, $from, $count = 1): \Relay\Relay|array|false|null
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->blmpop(...\func_get_args());
+ }
+
+ public function bzmpop($timeout, $keys, $from, $count = 1): \Relay\Relay|array|false|null
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->bzmpop(...\func_get_args());
+ }
+
+ public function lmpop($keys, $from, $count = 1): \Relay\Relay|array|false|null
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lmpop(...\func_get_args());
+ }
+
+ public function zmpop($keys, $from, $count = 1): \Relay\Relay|array|false|null
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zmpop(...\func_get_args());
+ }
+
+ public function brpop($key, $timeout_or_key, ...$extra_args): \Relay\Relay|array|false|null
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->brpop(...\func_get_args());
+ }
+
+ public function bzpopmax($key, $timeout_or_key, ...$extra_args): \Relay\Relay|array|false|null
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->bzpopmax(...\func_get_args());
+ }
+
+ public function bzpopmin($key, $timeout_or_key, ...$extra_args): \Relay\Relay|array|false|null
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->bzpopmin(...\func_get_args());
+ }
+
+ public function object($op, $key): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->object(...\func_get_args());
+ }
+
+ public function geopos($key, ...$members): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->geopos(...\func_get_args());
+ }
+
+ public function lrem($key, $mem, $count = 0): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lrem(...\func_get_args());
+ }
+
+ public function lindex($key, $index): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->lindex(...\func_get_args());
+ }
+
+ public function linsert($key, $op, $pivot, $element): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->linsert(...\func_get_args());
+ }
+
+ public function ltrim($key, $start, $end): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ltrim(...\func_get_args());
+ }
+
+ public function hget($hash, $member): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hget(...\func_get_args());
+ }
+
+ public function hstrlen($hash, $member): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hstrlen(...\func_get_args());
+ }
+
+ public function hgetall($hash): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hgetall(...\func_get_args());
+ }
+
+ public function hkeys($hash): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hkeys(...\func_get_args());
+ }
+
+ public function hvals($hash): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hvals(...\func_get_args());
+ }
+
+ public function hmget($hash, $members): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hmget(...\func_get_args());
+ }
+
+ public function hmset($hash, $members): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hmset(...\func_get_args());
+ }
+
+ public function hexists($hash, $member): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hexists(...\func_get_args());
+ }
+
+ public function hsetnx($hash, $member, $value): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hsetnx(...\func_get_args());
+ }
+
+ public function hdel($key, $mem, ...$mems): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hdel(...\func_get_args());
+ }
+
+ public function hincrby($key, $mem, $value): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hincrby(...\func_get_args());
+ }
+
+ public function hincrbyfloat($key, $mem, $value): \Relay\Relay|bool|float
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hincrbyfloat(...\func_get_args());
+ }
+
+ public function incr($key, $by = 1): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->incr(...\func_get_args());
+ }
+
+ public function decr($key, $by = 1): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->decr(...\func_get_args());
+ }
+
+ public function incrby($key, $value): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->incrby(...\func_get_args());
+ }
+
+ public function decrby($key, $value): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->decrby(...\func_get_args());
+ }
+
+ public function incrbyfloat($key, $value): \Relay\Relay|false|float
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->incrbyfloat(...\func_get_args());
+ }
+
+ public function sdiff($key, ...$other_keys): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sdiff(...\func_get_args());
+ }
+
+ public function sdiffstore($key, ...$other_keys): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sdiffstore(...\func_get_args());
+ }
+
+ public function sinter($key, ...$other_keys): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sinter(...\func_get_args());
+ }
+
+ public function sintercard($keys, $limit = -1): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sintercard(...\func_get_args());
+ }
+
+ public function sinterstore($key, ...$other_keys): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sinterstore(...\func_get_args());
+ }
+
+ public function sunion($key, ...$other_keys): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sunion(...\func_get_args());
+ }
+
+ public function sunionstore($key, ...$other_keys): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sunionstore(...\func_get_args());
+ }
+
+ public function subscribe($channels, $callback): bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->subscribe(...\func_get_args());
+ }
+
+ public function unsubscribe($channels = []): bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->unsubscribe(...\func_get_args());
+ }
+
+ public function psubscribe($patterns, $callback): bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->psubscribe(...\func_get_args());
+ }
+
+ public function punsubscribe($patterns = []): bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->punsubscribe(...\func_get_args());
+ }
+
+ public function ssubscribe($channels, $callback): bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->ssubscribe(...\func_get_args());
+ }
+
+ public function sunsubscribe($channels = []): bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sunsubscribe(...\func_get_args());
+ }
+
+ public function touch($key_or_array, ...$more_keys): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->touch(...\func_get_args());
+ }
+
+ public function pipeline(): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->pipeline(...\func_get_args());
+ }
+
+ public function multi($mode = 0): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->multi(...\func_get_args());
+ }
+
+ public function exec(): \Relay\Relay|array|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->exec(...\func_get_args());
+ }
+
+ public function wait($replicas, $timeout): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->wait(...\func_get_args());
+ }
+
+ public function unwatch(): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->unwatch(...\func_get_args());
+ }
+
+ public function discard(): bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->discard(...\func_get_args());
+ }
+
+ public function getMode($masked = false): int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getMode(...\func_get_args());
+ }
+
+ public function clearBytes(): void
+ {
+ ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->clearBytes(...\func_get_args());
+ }
+
+ public function scan(&$iterator, $match = null, $count = 0, $type = null): array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->scan($iterator, ...\array_slice(\func_get_args(), 1));
+ }
+
+ public function hscan($key, &$iterator, $match = null, $count = 0): array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hscan($key, $iterator, ...\array_slice(\func_get_args(), 2));
+ }
+
+ public function sscan($key, &$iterator, $match = null, $count = 0): array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sscan($key, $iterator, ...\array_slice(\func_get_args(), 2));
+ }
+
+ public function zscan($key, &$iterator, $match = null, $count = 0): array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zscan($key, $iterator, ...\array_slice(\func_get_args(), 2));
+ }
+
+ public function keys($pattern): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->keys(...\func_get_args());
+ }
+
+ public function slowlog($operation, ...$extra_args): \Relay\Relay|array|bool|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->slowlog(...\func_get_args());
+ }
+
+ public function smembers($set): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->smembers(...\func_get_args());
+ }
+
+ public function sismember($set, $member): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sismember(...\func_get_args());
+ }
+
+ public function smismember($set, ...$members): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->smismember(...\func_get_args());
+ }
+
+ public function srem($set, $member, ...$members): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->srem(...\func_get_args());
+ }
+
+ public function sadd($set, $member, ...$members): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sadd(...\func_get_args());
+ }
+
+ public function sort($key, $options = []): \Relay\Relay|array|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sort(...\func_get_args());
+ }
+
+ public function sort_ro($key, $options = []): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->sort_ro(...\func_get_args());
+ }
+
+ public function smove($srcset, $dstset, $member): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->smove(...\func_get_args());
+ }
+
+ public function spop($set, $count = 1): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->spop(...\func_get_args());
+ }
+
+ public function srandmember($set, $count = 1): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->srandmember(...\func_get_args());
+ }
+
+ public function scard($key): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->scard(...\func_get_args());
+ }
+
+ public function script($command, ...$args): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->script(...\func_get_args());
+ }
+
+ public function strlen($key): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->strlen(...\func_get_args());
+ }
+
+ public function hlen($key): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->hlen(...\func_get_args());
+ }
+
+ public function llen($key): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->llen(...\func_get_args());
+ }
+
+ public function xack($key, $group, $ids): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xack(...\func_get_args());
+ }
+
+ public function xclaim($key, $group, $consumer, $min_idle, $ids, $options): \Relay\Relay|array|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xclaim(...\func_get_args());
+ }
+
+ public function xautoclaim($key, $group, $consumer, $min_idle, $start, $count = -1, $justid = false): \Relay\Relay|array|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xautoclaim(...\func_get_args());
+ }
+
+ public function xlen($key): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xlen(...\func_get_args());
+ }
+
+ public function xgroup($operation, $key = null, $group = null, $id_or_consumer = null, $mkstream = false, $entries_read = -2): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xgroup(...\func_get_args());
+ }
+
+ public function xdel($key, $ids): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xdel(...\func_get_args());
+ }
+
+ public function xinfo($operation, $arg1 = null, $arg2 = null, $count = -1): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xinfo(...\func_get_args());
+ }
+
+ public function xpending($key, $group, $start = null, $end = null, $count = -1, $consumer = null, $idle = 0): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xpending(...\func_get_args());
+ }
+
+ public function xrange($key, $start, $end, $count = -1): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xrange(...\func_get_args());
+ }
+
+ public function xrevrange($key, $end, $start, $count = -1): \Relay\Relay|array|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xrevrange(...\func_get_args());
+ }
+
+ public function xread($streams, $count = -1, $block = -1): \Relay\Relay|array|bool|null
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xread(...\func_get_args());
+ }
+
+ public function xreadgroup($group, $consumer, $streams, $count = 1, $block = 1): \Relay\Relay|array|bool|null
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xreadgroup(...\func_get_args());
+ }
+
+ public function xtrim($key, $threshold, $approx = false, $minid = false, $limit = -1): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->xtrim(...\func_get_args());
+ }
+
+ public function zadd($key, ...$args): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zadd(...\func_get_args());
+ }
+
+ public function zrandmember($key, $options = null): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zrandmember(...\func_get_args());
+ }
+
+ public function zrange($key, $start, $end, $options = null): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zrange(...\func_get_args());
+ }
+
+ public function zrevrange($key, $start, $end, $options = null): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zrevrange(...\func_get_args());
+ }
+
+ public function zrangebyscore($key, $start, $end, $options = null): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zrangebyscore(...\func_get_args());
+ }
+
+ public function zrevrangebyscore($key, $start, $end, $options = null): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zrevrangebyscore(...\func_get_args());
+ }
+
+ public function zrangestore($dst, $src, $start, $end, $options = null): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zrangestore(...\func_get_args());
+ }
+
+ public function zrangebylex($key, $min, $max, $offset = -1, $count = -1): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zrangebylex(...\func_get_args());
+ }
+
+ public function zrevrangebylex($key, $max, $min, $offset = -1, $count = -1): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zrevrangebylex(...\func_get_args());
+ }
+
+ public function zrem($key, ...$args): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zrem(...\func_get_args());
+ }
+
+ public function zremrangebylex($key, $min, $max): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zremrangebylex(...\func_get_args());
+ }
+
+ public function zremrangebyrank($key, $start, $end): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zremrangebyrank(...\func_get_args());
+ }
+
+ public function zremrangebyscore($key, $min, $max): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zremrangebyscore(...\func_get_args());
+ }
+
+ public function zcard($key): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zcard(...\func_get_args());
+ }
+
+ public function zcount($key, $min, $max): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zcount(...\func_get_args());
+ }
+
+ public function zdiff($keys, $options = null): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zdiff(...\func_get_args());
+ }
+
+ public function zdiffstore($dst, $keys): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zdiffstore(...\func_get_args());
+ }
+
+ public function zincrby($key, $score, $mem): \Relay\Relay|false|float
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zincrby(...\func_get_args());
+ }
+
+ public function zlexcount($key, $min, $max): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zlexcount(...\func_get_args());
+ }
+
+ public function zmscore($key, ...$mems): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zmscore(...\func_get_args());
+ }
+
+ public function zinter($keys, $weights = null, $options = null): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zinter(...\func_get_args());
+ }
+
+ public function zintercard($keys, $limit = -1): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zintercard(...\func_get_args());
+ }
+
+ public function zinterstore($dst, $keys, $weights = null, $options = null): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zinterstore(...\func_get_args());
+ }
+
+ public function zunion($keys, $weights = null, $options = null): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zunion(...\func_get_args());
+ }
+
+ public function zunionstore($dst, $keys, $weights = null, $options = null): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zunionstore(...\func_get_args());
+ }
+
+ public function zpopmin($key, $count = 1): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zpopmin(...\func_get_args());
+ }
+
+ public function zpopmax($key, $count = 1): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->zpopmax(...\func_get_args());
+ }
+
+ public function _getKeys()
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->_getKeys(...\func_get_args());
+ }
+}
diff --git a/symfony/cache/Traits/RelayProxyTrait.php b/symfony/cache/Traits/RelayProxyTrait.php
new file mode 100644
index 0000000000000000000000000000000000000000..c35b5fa017cf6e9c54142812b5b4d77a62ae640e
--- /dev/null
+++ b/symfony/cache/Traits/RelayProxyTrait.php
@@ -0,0 +1,147 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Cache\Traits;
+
+if (version_compare(phpversion('relay'), '0.8.1', '>=')) {
+ /**
+ * @internal
+ */
+ trait RelayProxyTrait
+ {
+ public function jsonArrAppend($key, $value_or_array, $path = null): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->jsonArrAppend(...\func_get_args());
+ }
+
+ public function jsonArrIndex($key, $path, $value, $start = 0, $stop = -1): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->jsonArrIndex(...\func_get_args());
+ }
+
+ public function jsonArrInsert($key, $path, $index, $value, ...$other_values): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->jsonArrInsert(...\func_get_args());
+ }
+
+ public function jsonArrLen($key, $path = null): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->jsonArrLen(...\func_get_args());
+ }
+
+ public function jsonArrPop($key, $path = null, $index = -1): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->jsonArrPop(...\func_get_args());
+ }
+
+ public function jsonArrTrim($key, $path, $start, $stop): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->jsonArrTrim(...\func_get_args());
+ }
+
+ public function jsonClear($key, $path = null): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->jsonClear(...\func_get_args());
+ }
+
+ public function jsonDebug($command, $key, $path = null): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->jsonDebug(...\func_get_args());
+ }
+
+ public function jsonDel($key, $path = null): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->jsonDel(...\func_get_args());
+ }
+
+ public function jsonForget($key, $path = null): \Relay\Relay|false|int
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->jsonForget(...\func_get_args());
+ }
+
+ public function jsonGet($key, $options = [], ...$paths): mixed
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->jsonGet(...\func_get_args());
+ }
+
+ public function jsonMerge($key, $path, $value): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->jsonMerge(...\func_get_args());
+ }
+
+ public function jsonMget($key_or_array, $path): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->jsonMget(...\func_get_args());
+ }
+
+ public function jsonMset($key, $path, $value, ...$other_triples): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->jsonMset(...\func_get_args());
+ }
+
+ public function jsonNumIncrBy($key, $path, $value): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->jsonNumIncrBy(...\func_get_args());
+ }
+
+ public function jsonNumMultBy($key, $path, $value): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->jsonNumMultBy(...\func_get_args());
+ }
+
+ public function jsonObjKeys($key, $path = null): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->jsonObjKeys(...\func_get_args());
+ }
+
+ public function jsonObjLen($key, $path = null): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->jsonObjLen(...\func_get_args());
+ }
+
+ public function jsonResp($key, $path = null): \Relay\Relay|array|false|int|string
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->jsonResp(...\func_get_args());
+ }
+
+ public function jsonSet($key, $path, $value, $condition = null): \Relay\Relay|bool
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->jsonSet(...\func_get_args());
+ }
+
+ public function jsonStrAppend($key, $value, $path = null): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->jsonStrAppend(...\func_get_args());
+ }
+
+ public function jsonStrLen($key, $path = null): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->jsonStrLen(...\func_get_args());
+ }
+
+ public function jsonToggle($key, $path): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->jsonToggle(...\func_get_args());
+ }
+
+ public function jsonType($key, $path = null): \Relay\Relay|array|false
+ {
+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->jsonType(...\func_get_args());
+ }
+ }
+} else {
+ /**
+ * @internal
+ */
+ trait RelayProxyTrait
+ {
+ }
+}
diff --git a/symfony/cache/Traits/ValueWrapper.php b/symfony/cache/Traits/ValueWrapper.php
new file mode 100644
index 0000000000000000000000000000000000000000..718a23d391efe6a5c40b24524d17c3aa5cfbcda8
--- /dev/null
+++ b/symfony/cache/Traits/ValueWrapper.php
@@ -0,0 +1,81 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * A short namespace-less class to serialize items with metadata.
+ *
+ * @author Nicolas Grekas
+ *
+ * @internal
+ */
+class ©
+{
+ private const EXPIRY_OFFSET = 1648206727;
+ private const INT32_MAX = 2147483647;
+
+ public readonly mixed $value;
+ public readonly array $metadata;
+
+ public function __construct(mixed $value, array $metadata)
+ {
+ $this->value = $value;
+ $this->metadata = $metadata;
+ }
+
+ public function __serialize(): array
+ {
+ // pack 31-bits ctime into 14bits
+ $c = $this->metadata['ctime'] ?? 0;
+ $c = match (true) {
+ $c > self::INT32_MAX - 2 => self::INT32_MAX,
+ $c > 0 => 1 + $c,
+ default => 1,
+ };
+ $e = 0;
+ while (!(0x40000000 & $c)) {
+ $c <<= 1;
+ ++$e;
+ }
+ $c = (0x7FE0 & ($c >> 16)) | $e;
+
+ $pack = pack('Vn', (int) (0.1 + ($this->metadata['expiry'] ?: self::INT32_MAX + self::EXPIRY_OFFSET) - self::EXPIRY_OFFSET), $c);
+
+ if (isset($this->metadata['tags'])) {
+ $pack[4] = $pack[4] | "\x80";
+ }
+
+ return [$pack => $this->value] + ($this->metadata['tags'] ?? []);
+ }
+
+ public function __unserialize(array $data): void
+ {
+ $pack = array_key_first($data);
+ $this->value = $data[$pack];
+
+ if ($hasTags = "\x80" === ($pack[4] & "\x80")) {
+ unset($data[$pack]);
+ $pack[4] = $pack[4] & "\x7F";
+ }
+
+ $metadata = unpack('Vexpiry/nctime', $pack);
+ $metadata['expiry'] += self::EXPIRY_OFFSET;
+
+ if (!$metadata['ctime'] = ((0x4000 | $metadata['ctime']) << 16 >> (0x1F & $metadata['ctime'])) - 1) {
+ unset($metadata['ctime']);
+ }
+
+ if ($hasTags) {
+ $metadata['tags'] = $data;
+ }
+
+ $this->metadata = $metadata;
+ }
+}
diff --git a/symfony/cache/composer.json b/symfony/cache/composer.json
new file mode 100644
index 0000000000000000000000000000000000000000..af743b4634b919de79e1c514de20cfaa53c1a270
--- /dev/null
+++ b/symfony/cache/composer.json
@@ -0,0 +1,59 @@
+{
+ "name": "symfony/cache",
+ "type": "library",
+ "description": "Provides extended PSR-6, PSR-16 (and tags) implementations",
+ "keywords": ["caching", "psr6"],
+ "homepage": "https://symfony.com",
+ "license": "MIT",
+ "authors": [
+ {
+ "name": "Nicolas Grekas",
+ "email": "p@tchwork.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "provide": {
+ "psr/cache-implementation": "2.0|3.0",
+ "psr/simple-cache-implementation": "1.0|2.0|3.0",
+ "symfony/cache-implementation": "1.1|2.0|3.0"
+ },
+ "require": {
+ "php": ">=8.1",
+ "psr/cache": "^2.0|^3.0",
+ "psr/log": "^1.1|^2|^3",
+ "symfony/cache-contracts": "^2.5|^3",
+ "symfony/service-contracts": "^2.5|^3",
+ "symfony/var-exporter": "^6.3.6|^7.0"
+ },
+ "require-dev": {
+ "cache/integration-tests": "dev-master",
+ "doctrine/dbal": "^2.13.1|^3|^4",
+ "predis/predis": "^1.1|^2.0",
+ "psr/simple-cache": "^1.0|^2.0|^3.0",
+ "symfony/config": "^5.4|^6.0|^7.0",
+ "symfony/dependency-injection": "^5.4|^6.0|^7.0",
+ "symfony/filesystem": "^5.4|^6.0|^7.0",
+ "symfony/http-kernel": "^5.4|^6.0|^7.0",
+ "symfony/messenger": "^5.4|^6.0|^7.0",
+ "symfony/var-dumper": "^5.4|^6.0|^7.0"
+ },
+ "conflict": {
+ "doctrine/dbal": "<2.13.1",
+ "symfony/dependency-injection": "<5.4",
+ "symfony/http-kernel": "<5.4",
+ "symfony/var-dumper": "<5.4"
+ },
+ "autoload": {
+ "psr-4": { "Symfony\\Component\\Cache\\": "" },
+ "classmap": [
+ "Traits/ValueWrapper.php"
+ ],
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
+ },
+ "minimum-stability": "dev"
+}
diff --git a/symfony/config/Builder/ClassBuilder.php b/symfony/config/Builder/ClassBuilder.php
new file mode 100644
index 0000000000000000000000000000000000000000..f633036cdb3cb91943e4b57ff857c75cf6440227
--- /dev/null
+++ b/symfony/config/Builder/ClassBuilder.php
@@ -0,0 +1,178 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Builder;
+
+use Symfony\Component\Config\Definition\NodeInterface;
+
+/**
+ * Build PHP classes to generate config.
+ *
+ * @internal
+ *
+ * @author Tobias Nyholm
+ */
+class ClassBuilder
+{
+ private string $name;
+
+ /** @var Property[] */
+ private array $properties = [];
+
+ /** @var Method[] */
+ private array $methods = [];
+ private array $require = [];
+ private array $use = [];
+ private array $implements = [];
+ private bool $allowExtraKeys = false;
+
+ public function __construct(
+ private string $namespace,
+ string $name,
+ private NodeInterface $node,
+ public readonly bool $isRoot = false,
+ ) {
+ $this->name = ucfirst($this->camelCase($name)).'Config';
+ }
+
+ public function getDirectory(): string
+ {
+ return str_replace('\\', \DIRECTORY_SEPARATOR, $this->namespace);
+ }
+
+ public function getFilename(): string
+ {
+ return $this->name.'.php';
+ }
+
+ public function build(): string
+ {
+ $rootPath = explode(\DIRECTORY_SEPARATOR, $this->getDirectory());
+ $require = '';
+ foreach ($this->require as $class) {
+ // figure out relative path.
+ $path = explode(\DIRECTORY_SEPARATOR, $class->getDirectory());
+ $path[] = $class->getFilename();
+ foreach ($rootPath as $key => $value) {
+ if ($path[$key] !== $value) {
+ break;
+ }
+ unset($path[$key]);
+ }
+ $require .= \sprintf('require_once __DIR__.\DIRECTORY_SEPARATOR.\'%s\';', implode('\'.\DIRECTORY_SEPARATOR.\'', $path))."\n";
+ }
+ $use = $require ? "\n" : '';
+ foreach (array_keys($this->use) as $statement) {
+ $use .= \sprintf('use %s;', $statement)."\n";
+ }
+
+ $implements = $this->implements ? 'implements '.implode(', ', $this->implements) : '';
+ $body = '';
+ foreach ($this->properties as $property) {
+ $body .= ' '.$property->getContent()."\n";
+ }
+ foreach ($this->methods as $method) {
+ $lines = explode("\n", $method->getContent());
+ foreach ($lines as $line) {
+ $body .= ($line ? ' '.$line : '')."\n";
+ }
+ }
+
+ return strtr(' $this->namespace, 'REQUIRE' => $require, 'USE' => $use, 'CLASS' => $this->getName(), 'IMPLEMENTS' => $implements, 'BODY' => $body]);
+ }
+
+ public function addRequire(self $class): void
+ {
+ $this->require[] = $class;
+ }
+
+ public function addUse(string $class): void
+ {
+ $this->use[$class] = true;
+ }
+
+ public function addImplements(string $interface): void
+ {
+ $this->implements[] = '\\'.ltrim($interface, '\\');
+ }
+
+ public function addMethod(string $name, string $body, array $params = []): void
+ {
+ $this->methods[] = new Method(strtr($body, ['NAME' => $this->camelCase($name)] + $params));
+ }
+
+ public function addProperty(string $name, ?string $classType = null, ?string $defaultValue = null): Property
+ {
+ $property = new Property($name, '_' !== $name[0] ? $this->camelCase($name) : $name);
+ if (null !== $classType) {
+ $property->setType($classType);
+ }
+ $this->properties[] = $property;
+ $defaultValue = null !== $defaultValue ? \sprintf(' = %s', $defaultValue) : '';
+ $property->setContent(\sprintf('private $%s%s;', $property->getName(), $defaultValue));
+
+ return $property;
+ }
+
+ public function getProperties(): array
+ {
+ return $this->properties;
+ }
+
+ private function camelCase(string $input): string
+ {
+ $output = lcfirst(str_replace(' ', '', ucwords(str_replace('_', ' ', $input))));
+
+ return preg_replace('#\W#', '', $output);
+ }
+
+ public function getName(): string
+ {
+ return $this->name;
+ }
+
+ public function getNamespace(): string
+ {
+ return $this->namespace;
+ }
+
+ public function getFqcn(): string
+ {
+ return '\\'.$this->namespace.'\\'.$this->name;
+ }
+
+ public function setAllowExtraKeys(bool $allowExtraKeys): void
+ {
+ $this->allowExtraKeys = $allowExtraKeys;
+ }
+
+ public function shouldAllowExtraKeys(): bool
+ {
+ return $this->allowExtraKeys;
+ }
+
+ public function getNode(): NodeInterface
+ {
+ return $this->node;
+ }
+}
diff --git a/symfony/config/Builder/ConfigBuilderGenerator.php b/symfony/config/Builder/ConfigBuilderGenerator.php
new file mode 100644
index 0000000000000000000000000000000000000000..1ef4956087a4f257c991eddd028e82f2f66dc3c9
--- /dev/null
+++ b/symfony/config/Builder/ConfigBuilderGenerator.php
@@ -0,0 +1,632 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Builder;
+
+use Symfony\Component\Config\Definition\ArrayNode;
+use Symfony\Component\Config\Definition\BaseNode;
+use Symfony\Component\Config\Definition\BooleanNode;
+use Symfony\Component\Config\Definition\Builder\ExprBuilder;
+use Symfony\Component\Config\Definition\ConfigurationInterface;
+use Symfony\Component\Config\Definition\EnumNode;
+use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
+use Symfony\Component\Config\Definition\FloatNode;
+use Symfony\Component\Config\Definition\IntegerNode;
+use Symfony\Component\Config\Definition\NodeInterface;
+use Symfony\Component\Config\Definition\PrototypedArrayNode;
+use Symfony\Component\Config\Definition\ScalarNode;
+use Symfony\Component\Config\Definition\VariableNode;
+use Symfony\Component\Config\Loader\ParamConfigurator;
+
+/**
+ * Generate ConfigBuilders to help create valid config.
+ *
+ * @author Tobias Nyholm
+ *
+ * @deprecated since Symfony 7.4
+ */
+class ConfigBuilderGenerator implements ConfigBuilderGeneratorInterface
+{
+ /**
+ * @var ClassBuilder[]
+ */
+ private array $classes = [];
+
+ public function __construct(
+ private string $outputDir,
+ ) {
+ }
+
+ /**
+ * @return \Closure that will return the root config class
+ */
+ public function build(ConfigurationInterface $configuration): \Closure
+ {
+ $this->classes = [];
+
+ $rootNode = $configuration->getConfigTreeBuilder()->buildTree();
+ $rootClass = new ClassBuilder('Symfony\\Config', $rootNode->getName(), $rootNode, true);
+
+ $path = $this->getFullPath($rootClass);
+ if (!is_file($path)) {
+ // Generate the class if the file not exists
+ $this->classes[] = $rootClass;
+ $this->buildNode($rootNode, $rootClass, $this->getSubNamespace($rootClass));
+ $rootClass->addImplements(ConfigBuilderInterface::class);
+ $rootClass->addMethod('getExtensionAlias', '
+public function NAME(): string
+{
+ return \'ALIAS\';
+}', ['ALIAS' => $rootNode->getPath()]);
+
+ $this->writeClasses();
+ }
+
+ return static function () use ($path, $rootClass) {
+ require_once $path;
+ $className = $rootClass->getFqcn();
+
+ return new $className();
+ };
+ }
+
+ private function getFullPath(ClassBuilder $class): string
+ {
+ $directory = $this->outputDir.\DIRECTORY_SEPARATOR.$class->getDirectory();
+ if (!is_dir($directory)) {
+ @mkdir($directory, 0o777, true);
+ }
+
+ return $directory.\DIRECTORY_SEPARATOR.$class->getFilename();
+ }
+
+ private function writeClasses(): void
+ {
+ foreach ($this->classes as $class) {
+ $this->buildConstructor($class, $class->getNode());
+ $this->buildToArray($class);
+ if ($class->getProperties()) {
+ $class->addProperty('_usedProperties', null, '[]');
+ }
+ if ($class->isRoot) {
+ $class->addProperty('_hasDeprecatedCalls', null, 'false');
+ }
+ $this->buildSetExtraKey($class);
+
+ file_put_contents($this->getFullPath($class), $class->build());
+ }
+
+ $this->classes = [];
+ }
+
+ private function buildNode(NodeInterface $node, ClassBuilder $class, string $namespace): void
+ {
+ if (!$node instanceof ArrayNode) {
+ throw new \LogicException('The node was expected to be an ArrayNode. This Configuration includes an edge case not supported yet.');
+ }
+
+ foreach ($node->getChildren() as $child) {
+ match (true) {
+ $child instanceof ScalarNode => $this->handleScalarNode($child, $class),
+ $child instanceof PrototypedArrayNode => $this->handlePrototypedArrayNode($child, $class, $namespace),
+ $child instanceof VariableNode => $this->handleVariableNode($child, $class),
+ $child instanceof ArrayNode => $this->handleArrayNode($child, $class, $namespace),
+ default => throw new \RuntimeException(\sprintf('Unknown node "%s".', get_debug_type($child))),
+ };
+ }
+ }
+
+ private function handleArrayNode(ArrayNode $node, ClassBuilder $class, string $namespace): void
+ {
+ $childClass = new ClassBuilder($namespace, $node->getName(), $node);
+ $childClass->setAllowExtraKeys($node->shouldIgnoreExtraKeys());
+ $class->addRequire($childClass);
+ $this->classes[] = $childClass;
+
+ $nodeTypes = $this->getParameterTypes($node);
+ $paramType = implode('|', $nodeTypes);
+ $acceptScalar = 'array' !== $paramType;
+
+ $comment = $this->getComment($node);
+ if ($acceptScalar) {
+ $comment = \sprintf(" * @template TValue of %s\n * @param TValue \$value\n%s", $paramType, $comment);
+ $comment .= \sprintf(' * @return %s|$this'."\n", $childClass->getFqcn());
+ $comment .= \sprintf(' * @psalm-return (TValue is array ? %s : static)'."\n", $childClass->getFqcn());
+ }
+ if ($class->isRoot) {
+ $comment .= " * @deprecated since Symfony 7.4\n";
+ }
+ if ('' !== $comment) {
+ $comment = "/**\n$comment */\n";
+ }
+
+ $property = $class->addProperty(
+ $node->getName(),
+ $childClass->getFqcn().($acceptScalar ? '|scalar' : '')
+ );
+ $body = $acceptScalar ? '
+COMMENTpublic function NAME(PARAM_TYPE $value = []): CLASS|static
+{DEPRECATED_BODY
+ if (!\is_array($value)) {
+ $this->_usedProperties[\'PROPERTY\'] = true;
+ $this->PROPERTY = $value;
+
+ return $this;
+ }
+
+ if (!$this->PROPERTY instanceof CLASS) {
+ $this->_usedProperties[\'PROPERTY\'] = true;
+ $this->PROPERTY = new CLASS($value);
+ } elseif (0 < \func_num_args()) {
+ throw new InvalidConfigurationException(\'The node created by "NAME()" has already been initialized. You cannot pass values the second time you call NAME().\');
+ }
+
+ return $this->PROPERTY;
+}' : '
+COMMENTpublic function NAME(array $value = []): CLASS
+{DEPRECATED_BODY
+ if (null === $this->PROPERTY) {
+ $this->_usedProperties[\'PROPERTY\'] = true;
+ $this->PROPERTY = new CLASS($value);
+ } elseif (0 < \func_num_args()) {
+ throw new InvalidConfigurationException(\'The node created by "NAME()" has already been initialized. You cannot pass values the second time you call NAME().\');
+ }
+
+ return $this->PROPERTY;
+}';
+ $class->addUse(InvalidConfigurationException::class);
+ $class->addMethod($node->getName(), $body, [
+ 'DEPRECATED_BODY' => $class->isRoot ? "\n \$this->_hasDeprecatedCalls = true;" : '',
+ 'COMMENT' => $comment,
+ 'PROPERTY' => $property->getName(),
+ 'CLASS' => $childClass->getFqcn(),
+ 'PARAM_TYPE' => $paramType,
+ ]);
+
+ $this->buildNode($node, $childClass, $this->getSubNamespace($childClass));
+ }
+
+ private function handleVariableNode(VariableNode $node, ClassBuilder $class): void
+ {
+ $comment = $this->getComment($node);
+ $property = $class->addProperty($node->getName());
+ $class->addUse(ParamConfigurator::class);
+
+ $body = '
+/**
+COMMENT *
+ * @return $this
+ *DEPRECATED_ANNOTATION/
+public function NAME(mixed $valueDEFAULT): static
+{DEPRECATED_BODY
+ $this->_usedProperties[\'PROPERTY\'] = true;
+ $this->PROPERTY = $value;
+
+ return $this;
+}';
+ $class->addMethod($node->getName(), $body, [
+ 'DEPRECATED_BODY' => $class->isRoot ? "\n \$this->_hasDeprecatedCalls = true;" : '',
+ 'DEPRECATED_ANNOTATION' => $class->isRoot ? " @deprecated since Symfony 7.4\n *" : '',
+ 'PROPERTY' => $property->getName(),
+ 'COMMENT' => $comment,
+ 'DEFAULT' => $node->hasDefaultValue() ? ' = '.var_export($node->getDefaultValue(), true) : '',
+ ]);
+ }
+
+ private function handlePrototypedArrayNode(PrototypedArrayNode $node, ClassBuilder $class, string $namespace): void
+ {
+ $name = $this->getSingularName($node);
+ $prototype = $node->getPrototype();
+ $methodName = $name;
+
+ $nodeParameterTypes = $this->getParameterTypes($node);
+ $prototypeParameterTypes = $this->getParameterTypes($prototype);
+ $noKey = null === $key = $node->getKeyAttribute();
+ $acceptScalar = ['array'] !== $nodeParameterTypes || ['array'] !== $prototypeParameterTypes;
+
+ if (!$prototype instanceof ArrayNode || ($prototype instanceof PrototypedArrayNode && $prototype->getPrototype() instanceof ScalarNode)) {
+ $class->addUse(ParamConfigurator::class);
+ $property = $class->addProperty($node->getName());
+ if ($noKey) {
+ // This is an array of values; don't use singular name
+ $nodeTypesWithoutArray = array_diff($nodeParameterTypes, ['array']);
+ $body = '
+/**
+ * @param ParamConfigurator|listEXTRA_TYPE $value
+ *
+ * @return $this
+ *DEPRECATED_ANNOTATION/
+public function NAME(PARAM_TYPE $value): static
+{DEPRECATED_BODY
+ $this->_usedProperties[\'PROPERTY\'] = true;
+ $this->PROPERTY = $value;
+
+ return $this;
+}';
+
+ $class->addMethod($node->getName(), $body, [
+ 'DEPRECATED_BODY' => $class->isRoot ? "\n \$this->_hasDeprecatedCalls = true;" : '',
+ 'DEPRECATED_ANNOTATION' => $class->isRoot ? " @deprecated since Symfony 7.4\n *" : '',
+ 'PROPERTY' => $property->getName(),
+ 'PROTOTYPE_TYPE' => implode('|', $prototypeParameterTypes),
+ 'EXTRA_TYPE' => $nodeTypesWithoutArray ? '|'.implode('|', $nodeTypesWithoutArray) : '',
+ 'PARAM_TYPE' => ['mixed'] !== $nodeParameterTypes ? 'ParamConfigurator|'.implode('|', $nodeParameterTypes) : 'mixed',
+ ]);
+ } else {
+ $body = '
+/**
+ * @return $this
+ *DEPRECATED_ANNOTATION/
+public function NAME(string $VAR, TYPE $VALUE): static
+{DEPRECATED_BODY
+ $this->_usedProperties[\'PROPERTY\'] = true;
+ $this->PROPERTY[$VAR] = $VALUE;
+
+ return $this;
+}';
+
+ $class->addMethod($methodName, $body, [
+ 'DEPRECATED_BODY' => $class->isRoot ? "\n \$this->_hasDeprecatedCalls = true;" : '',
+ 'DEPRECATED_ANNOTATION' => $class->isRoot ? " @deprecated since Symfony 7.4\n *" : '',
+ 'PROPERTY' => $property->getName(),
+ 'TYPE' => ['mixed'] !== $prototypeParameterTypes ? 'ParamConfigurator|'.implode('|', $prototypeParameterTypes) : 'mixed',
+ 'VAR' => '' === $key ? 'key' : $key,
+ 'VALUE' => 'value' === $key ? 'data' : 'value',
+ ]);
+ }
+
+ return;
+ }
+
+ $childClass = new ClassBuilder($namespace, $name, $prototype);
+ if ($prototype instanceof ArrayNode) {
+ $childClass->setAllowExtraKeys($prototype->shouldIgnoreExtraKeys());
+ }
+ $class->addRequire($childClass);
+ $this->classes[] = $childClass;
+
+ $property = $class->addProperty(
+ $node->getName(),
+ $childClass->getFqcn().'[]'.($acceptScalar ? '|scalar' : '')
+ );
+
+ $paramType = implode('|', $noKey ? $nodeParameterTypes : $prototypeParameterTypes);
+ $acceptScalar = 'array' !== $paramType;
+
+ $comment = $this->getComment($node);
+ if ($acceptScalar) {
+ $comment = \sprintf(" * @template TValue of %s\n * @param TValue \$value\n%s", $paramType, $comment);
+ $comment .= \sprintf(' * @return %s|$this'."\n", $childClass->getFqcn());
+ $comment .= \sprintf(' * @psalm-return (TValue is array ? %s : static)'."\n", $childClass->getFqcn());
+ }
+ if ($class->isRoot) {
+ $comment .= " * @deprecated since Symfony 7.4\n";
+ }
+ if ('' !== $comment) {
+ $comment = "/**\n$comment */\n";
+ }
+
+ if ($noKey) {
+ $body = $acceptScalar ? '
+COMMENTpublic function NAME(PARAM_TYPE $value = []): CLASS|static
+{DEPRECATED_BODY
+ $this->_usedProperties[\'PROPERTY\'] = true;
+ if (!\is_array($value)) {
+ $this->PROPERTY[] = $value;
+
+ return $this;
+ }
+
+ return $this->PROPERTY[] = new CLASS($value);
+}' : '
+COMMENTpublic function NAME(array $value = []): CLASS
+{DEPRECATED_BODY
+ $this->_usedProperties[\'PROPERTY\'] = true;
+
+ return $this->PROPERTY[] = new CLASS($value);
+}';
+ $class->addMethod($methodName, $body, [
+ 'DEPRECATED_BODY' => $class->isRoot ? "\n \$this->_hasDeprecatedCalls = true;" : '',
+ 'COMMENT' => $comment,
+ 'PROPERTY' => $property->getName(),
+ 'CLASS' => $childClass->getFqcn(),
+ 'PARAM_TYPE' => $paramType,
+ ]);
+ } else {
+ $body = $acceptScalar ? '
+COMMENTpublic function NAME(string $VAR, PARAM_TYPE $VALUE = []): CLASS|static
+{DEPRECATED_BODY
+ if (!\is_array($VALUE)) {
+ $this->_usedProperties[\'PROPERTY\'] = true;
+ $this->PROPERTY[$VAR] = $VALUE;
+
+ return $this;
+ }
+
+ if (!isset($this->PROPERTY[$VAR]) || !$this->PROPERTY[$VAR] instanceof CLASS) {
+ $this->_usedProperties[\'PROPERTY\'] = true;
+ $this->PROPERTY[$VAR] = new CLASS($VALUE);
+ } elseif (1 < \func_num_args()) {
+ throw new InvalidConfigurationException(\'The node created by "NAME()" has already been initialized. You cannot pass values the second time you call NAME().\');
+ }
+
+ return $this->PROPERTY[$VAR];
+}' : '
+COMMENTpublic function NAME(string $VAR, array $VALUE = []): CLASS
+{DEPRECATED_BODY
+ if (!isset($this->PROPERTY[$VAR])) {
+ $this->_usedProperties[\'PROPERTY\'] = true;
+ $this->PROPERTY[$VAR] = new CLASS($VALUE);
+ } elseif (1 < \func_num_args()) {
+ throw new InvalidConfigurationException(\'The node created by "NAME()" has already been initialized. You cannot pass values the second time you call NAME().\');
+ }
+
+ return $this->PROPERTY[$VAR];
+}';
+ $class->addUse(InvalidConfigurationException::class);
+ $class->addMethod($methodName, str_replace('$value', '$VAR', $body), [
+ 'DEPRECATED_BODY' => $class->isRoot ? "\n \$this->_hasDeprecatedCalls = true;" : '',
+ 'COMMENT' => $comment,
+ 'PROPERTY' => $property->getName(),
+ 'CLASS' => $childClass->getFqcn(),
+ 'VAR' => '' === $key ? 'key' : $key,
+ 'VALUE' => 'value' === $key ? 'data' : 'value',
+ 'PARAM_TYPE' => $paramType,
+ ]);
+ }
+
+ $this->buildNode($prototype, $childClass, $namespace.'\\'.$childClass->getName());
+ }
+
+ private function handleScalarNode(ScalarNode $node, ClassBuilder $class): void
+ {
+ $comment = $this->getComment($node);
+ $property = $class->addProperty($node->getName());
+ $class->addUse(ParamConfigurator::class);
+
+ $body = '
+/**
+COMMENT * @return $this
+ *DEPRECATED_ANNOTATION/
+public function NAME($value): static
+{DEPRECATED_BODY
+ $this->_usedProperties[\'PROPERTY\'] = true;
+ $this->PROPERTY = $value;
+
+ return $this;
+}';
+
+ $class->addMethod($node->getName(), $body, [
+ 'DEPRECATED_BODY' => $class->isRoot ? "\n \$this->_hasDeprecatedCalls = true;" : '',
+ 'DEPRECATED_ANNOTATION' => $class->isRoot ? " @deprecated since Symfony 7.4\n *" : '',
+ 'PROPERTY' => $property->getName(),
+ 'COMMENT' => $comment,
+ ]);
+ }
+
+ private function getParameterTypes(NodeInterface $node): array
+ {
+ $paramTypes = [];
+ if ($node instanceof BaseNode) {
+ foreach ($node->getNormalizedTypes() as $type) {
+ if (ExprBuilder::TYPE_ANY === $type) {
+ return ['mixed'];
+ }
+
+ $paramTypes[] = match ($type) {
+ ExprBuilder::TYPE_STRING => 'string',
+ ExprBuilder::TYPE_NULL => 'null',
+ ExprBuilder::TYPE_ARRAY => 'array',
+ ExprBuilder::TYPE_BOOL => 'bool',
+ ExprBuilder::TYPE_BACKED_ENUM => '\BackedEnum',
+ ExprBuilder::TYPE_INT => 'int',
+ };
+ }
+ }
+
+ if ($node instanceof BooleanNode) {
+ $paramTypes[] = 'bool';
+ } elseif ($node instanceof IntegerNode) {
+ $paramTypes[] = 'int';
+ } elseif ($node instanceof FloatNode) {
+ $paramTypes[] = 'float';
+ } elseif ($node instanceof ArrayNode) {
+ $paramTypes[] = 'array';
+ } else {
+ return ['mixed'];
+ }
+
+ return array_unique($paramTypes);
+ }
+
+ private function getComment(BaseNode $node): string
+ {
+ $comment = '';
+ if ('' !== $info = (string) $node->getInfo()) {
+ $comment .= $info."\n";
+ }
+
+ if (!$node instanceof ArrayNode) {
+ foreach ((array) ($node->getExample() ?? []) as $example) {
+ $comment .= '@example '.$example."\n";
+ }
+
+ if ('' !== $default = $node->getDefaultValue()) {
+ $comment .= '@default '.(null === $default ? 'null' : var_export($default, true))."\n";
+ }
+
+ if ($node instanceof EnumNode) {
+ $comment .= \sprintf('@param ParamConfigurator|%s $value', implode('|', array_unique(array_map(fn ($a) => !$a instanceof \UnitEnum ? var_export($a, true) : '\\'.ltrim(var_export($a, true), '\\'), $node->getValues()))))."\n";
+ } else {
+ $parameterTypes = $this->getParameterTypes($node);
+ $comment .= '@param ParamConfigurator|'.implode('|', $parameterTypes).' $value'."\n";
+ }
+ } else {
+ foreach ((array) ($node->getExample() ?? []) as $example) {
+ $comment .= '@example '.json_encode($example)."\n";
+ }
+
+ if ($node->hasDefaultValue() && [] != $default = $node->getDefaultValue()) {
+ $comment .= '@default '.json_encode($default)."\n";
+ }
+ }
+
+ if ($node->isDeprecated()) {
+ $comment .= '@deprecated '.$node->getDeprecationMessage()."\n";
+ }
+
+ return $comment ? ' * '.str_replace("\n", "\n * ", rtrim($comment, "\n"))."\n" : '';
+ }
+
+ /**
+ * Pick a good singular name.
+ */
+ private function getSingularName(PrototypedArrayNode $node): string
+ {
+ $name = $node->getName();
+ if (!str_ends_with($name, 's')) {
+ return $name;
+ }
+
+ $parent = $node->getParent();
+ $mappings = $parent instanceof ArrayNode ? $parent->getXmlRemappings() : [];
+ foreach ($mappings as $map) {
+ if ($map[1] === $name) {
+ $name = $map[0];
+ break;
+ }
+ }
+
+ return $name;
+ }
+
+ private function buildToArray(ClassBuilder $class): void
+ {
+ $body = '$output = [];';
+ foreach ($class->getProperties() as $p) {
+ $code = '$this->PROPERTY';
+ if (null !== $p->getType()) {
+ if ($p->isArray()) {
+ $code = $p->areScalarsAllowed()
+ ? 'array_map(fn ($v) => $v instanceof CLASS ? $v->toArray() : $v, $this->PROPERTY)'
+ : 'array_map(fn ($v) => $v->toArray(), $this->PROPERTY)'
+ ;
+ } else {
+ $code = $p->areScalarsAllowed()
+ ? '$this->PROPERTY instanceof CLASS ? $this->PROPERTY->toArray() : $this->PROPERTY'
+ : '$this->PROPERTY->toArray()'
+ ;
+ }
+ }
+
+ $body .= strtr('
+ if (isset($this->_usedProperties[\'PROPERTY\'])) {
+ $output[\'ORIG_NAME\'] = '.$code.';
+ }', ['PROPERTY' => $p->getName(), 'ORIG_NAME' => $p->getOriginalName(), 'CLASS' => $p->getType()]);
+ }
+
+ $extraKeys = $class->shouldAllowExtraKeys() ? ' + $this->_extraKeys' : '';
+
+ if ($class->isRoot) {
+ $body .= "
+ if (\$this->_hasDeprecatedCalls) {
+ trigger_deprecation('symfony/config', '7.4', 'Calling any fluent method on \"%s\" is deprecated; pass the configuration to the constructor instead.', \$this::class);
+ }";
+ }
+
+ $class->addMethod('toArray', '
+public function NAME(): array
+{
+ '.$body.'
+
+ return $output'.$extraKeys.';
+}');
+ }
+
+ private function buildConstructor(ClassBuilder $class, NodeInterface $node): void
+ {
+ $body = '';
+ foreach ($class->getProperties() as $p) {
+ $code = '$config[\'ORIG_NAME\']';
+ if (null !== $p->getType()) {
+ if ($p->isArray()) {
+ $code = $p->areScalarsAllowed()
+ ? 'array_map(fn ($v) => \is_array($v) ? new '.$p->getType().'($v) : $v, $config[\'ORIG_NAME\'])'
+ : 'array_map(fn ($v) => new '.$p->getType().'($v), $config[\'ORIG_NAME\'])'
+ ;
+ } else {
+ $code = $p->areScalarsAllowed()
+ ? '\is_array($config[\'ORIG_NAME\']) ? new '.$p->getType().'($config[\'ORIG_NAME\']) : $config[\'ORIG_NAME\']'
+ : 'new '.$p->getType().'($config[\'ORIG_NAME\'])'
+ ;
+ }
+ }
+
+ $body .= strtr('
+ if (array_key_exists(\'ORIG_NAME\', $config)) {
+ $this->_usedProperties[\'PROPERTY\'] = true;
+ $this->PROPERTY = '.$code.';
+ unset($config[\'ORIG_NAME\']);
+ }
+', ['PROPERTY' => $p->getName(), 'ORIG_NAME' => $p->getOriginalName()]);
+ }
+
+ if ($class->shouldAllowExtraKeys()) {
+ $body .= '
+ $this->_extraKeys = $config;
+';
+ } else {
+ $body .= '
+ if ($config) {
+ throw new InvalidConfigurationException(sprintf(\'The following keys are not supported by "%s": \', __CLASS__).implode(\', \', array_keys($config)));
+ }';
+
+ $class->addUse(InvalidConfigurationException::class);
+ }
+
+ $class->addMethod('__construct', '
+public function __construct(array $config = [])
+{'.$body.'
+}');
+ }
+
+ private function buildSetExtraKey(ClassBuilder $class): void
+ {
+ if (!$class->shouldAllowExtraKeys()) {
+ return;
+ }
+
+ $class->addUse(ParamConfigurator::class);
+
+ $class->addProperty('_extraKeys');
+
+ $class->addMethod('set', '
+/**
+ * @param ParamConfigurator|mixed $value
+ *
+ * @return $this
+ *DEPRECATED_ANNOTATION/
+public function NAME(string $key, mixed $value): static
+{DEPRECATED_BODY
+ $this->_extraKeys[$key] = $value;
+
+ return $this;
+}', [
+ 'DEPRECATED_BODY' => $class->isRoot ? "\n \$this->_hasDeprecatedCalls = true;" : '',
+ 'DEPRECATED_ANNOTATION' => $class->isRoot ? " @deprecated since Symfony 7.4\n *" : '',
+ ]);
+ }
+
+ private function getSubNamespace(ClassBuilder $rootClass): string
+ {
+ return \sprintf('%s\\%s', $rootClass->getNamespace(), substr($rootClass->getName(), 0, -6));
+ }
+}
diff --git a/symfony/config/Builder/ConfigBuilderGeneratorInterface.php b/symfony/config/Builder/ConfigBuilderGeneratorInterface.php
new file mode 100644
index 0000000000000000000000000000000000000000..7f395997997b18235a0bc4b6269eeb1fa0336391
--- /dev/null
+++ b/symfony/config/Builder/ConfigBuilderGeneratorInterface.php
@@ -0,0 +1,29 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Builder;
+
+use Symfony\Component\Config\Definition\ConfigurationInterface;
+
+/**
+ * Generates ConfigBuilders to help create valid config.
+ *
+ * @author Tobias Nyholm
+ *
+ * @deprecated since Symfony 7.4
+ */
+interface ConfigBuilderGeneratorInterface
+{
+ /**
+ * @return \Closure that will return the root config class
+ */
+ public function build(ConfigurationInterface $configuration): \Closure;
+}
diff --git a/symfony/config/Builder/ConfigBuilderInterface.php b/symfony/config/Builder/ConfigBuilderInterface.php
new file mode 100644
index 0000000000000000000000000000000000000000..c9642d5654098da34fdbac24efc8fe4890fb3dea
--- /dev/null
+++ b/symfony/config/Builder/ConfigBuilderInterface.php
@@ -0,0 +1,32 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Builder;
+
+/**
+ * A ConfigBuilder provides helper methods to build a large complex array.
+ *
+ * @author Tobias Nyholm
+ *
+ * @deprecated since Symfony 7.4
+ */
+interface ConfigBuilderInterface
+{
+ /**
+ * Gets all configuration represented as an array.
+ */
+ public function toArray(): array;
+
+ /**
+ * Gets the alias for the extension which config we are building.
+ */
+ public function getExtensionAlias(): string;
+}
diff --git a/symfony/config/Builder/Method.php b/symfony/config/Builder/Method.php
new file mode 100644
index 0000000000000000000000000000000000000000..8fba068a95474d40c35580b6c44fd2736051d04b
--- /dev/null
+++ b/symfony/config/Builder/Method.php
@@ -0,0 +1,32 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Builder;
+
+/**
+ * Represents a method when building classes.
+ *
+ * @internal
+ *
+ * @author Tobias Nyholm
+ */
+class Method
+{
+ public function __construct(
+ private string $content,
+ ) {
+ }
+
+ public function getContent(): string
+ {
+ return $this->content;
+ }
+}
diff --git a/symfony/config/Builder/Property.php b/symfony/config/Builder/Property.php
new file mode 100644
index 0000000000000000000000000000000000000000..ede5351c7074c207173a97eec045ba3ab8377298
--- /dev/null
+++ b/symfony/config/Builder/Property.php
@@ -0,0 +1,84 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Builder;
+
+/**
+ * Represents a property when building classes.
+ *
+ * @internal
+ *
+ * @author Tobias Nyholm
+ */
+class Property
+{
+ private bool $array = false;
+ private bool $scalarsAllowed = false;
+ private ?string $type = null;
+ private ?string $content = null;
+
+ public function __construct(
+ private string $originalName,
+ private string $name,
+ ) {
+ }
+
+ public function getName(): string
+ {
+ return $this->name;
+ }
+
+ public function getOriginalName(): string
+ {
+ return $this->originalName;
+ }
+
+ public function setType(string $type): void
+ {
+ $this->array = false;
+ $this->type = $type;
+
+ if (str_ends_with($type, '|scalar')) {
+ $this->scalarsAllowed = true;
+ $this->type = $type = substr($type, 0, -7);
+ }
+
+ if (str_ends_with($type, '[]')) {
+ $this->array = true;
+ $this->type = substr($type, 0, -2);
+ }
+ }
+
+ public function getType(): ?string
+ {
+ return $this->type;
+ }
+
+ public function getContent(): ?string
+ {
+ return $this->content;
+ }
+
+ public function setContent(string $content): void
+ {
+ $this->content = $content;
+ }
+
+ public function isArray(): bool
+ {
+ return $this->array;
+ }
+
+ public function areScalarsAllowed(): bool
+ {
+ return $this->scalarsAllowed;
+ }
+}
diff --git a/symfony/config/CHANGELOG.md b/symfony/config/CHANGELOG.md
new file mode 100644
index 0000000000000000000000000000000000000000..5075ce21ccc054141db3c51c6c4d498e26f89c5b
--- /dev/null
+++ b/symfony/config/CHANGELOG.md
@@ -0,0 +1,195 @@
+CHANGELOG
+=========
+
+7.4
+---
+
+ * Add TagAwareAdapterInterface to NullAdapter
+ * Add argument `$singular` to `NodeBuilder::arrayNode()` to decouple plurals/singulars from XML
+ * Add support for `defaultNull()` on `ArrayNodeDefinition`
+ * Add `ArrayNodeDefinition::acceptAndWrap()` to list alternative types that should be accepted and wrapped in an array
+ * Add array-shapes to generated config builders
+ * Deprecate accessing the internal scope of the loader in PHP config files, use only its public API instead
+ * Deprecate setting a default value to a node that is required, and vice versa
+ * Deprecate fluent config builders, return PHP arrays from your config instead
+
+7.3
+---
+
+ * Add `ExprBuilder::ifFalse()`
+ * Add support for info on `ArrayNodeDefinition::canBeEnabled()` and `ArrayNodeDefinition::canBeDisabled()`
+ * Allow using an enum FQCN with `EnumNode`
+ * Add `NodeDefinition::docUrl()`
+
+7.2
+---
+
+ * Add `#[WhenNot]` attribute to prevent service from being registered in a specific environment
+ * Generate a meta file in JSON format for resource tracking
+ * Add `SkippingResourceChecker`
+ * Add support for `defaultNull()` on `BooleanNodeDefinition`
+ * Add `StringNode` and `StringNodeDefinition`
+ * Add `ArrayNodeDefinition::stringPrototype()` method
+ * Add `NodeBuilder::stringNode()` method
+
+7.1
+---
+
+ * Allow custom meta location in `ResourceCheckerConfigCache`
+ * Allow custom meta location in `ConfigCache`
+
+7.0
+---
+
+ * Require explicit argument when calling `NodeBuilder::setParent()`
+
+6.3
+---
+
+ * Allow enum values in `EnumNode`
+
+6.2
+---
+
+ * Deprecate calling `NodeBuilder::setParent()` without any arguments
+ * Add a more accurate typehint in generated PHP config
+
+6.1
+---
+
+ * Allow using environment variables in `EnumNode`
+ * Add Node's information in generated Config
+ * Add `DefinitionFileLoader` class to load a TreeBuilder definition from an external file
+ * Add `DefinitionConfigurator` helper
+
+6.0
+---
+
+ * Remove `BaseNode::getDeprecationMessage()`
+
+5.3.0
+-----
+
+ * Add support for generating `ConfigBuilder` for extensions
+
+5.1.0
+-----
+
+ * updated the signature of method `NodeDefinition::setDeprecated()` to `NodeDefinition::setDeprecation(string $package, string $version, string $message)`
+ * updated the signature of method `BaseNode::setDeprecated()` to `BaseNode::setDeprecation(string $package, string $version, string $message)`
+ * deprecated passing a null message to `BaseNode::setDeprecated()` to un-deprecate a node
+ * deprecated `BaseNode::getDeprecationMessage()`, use `BaseNode::getDeprecation()` instead
+
+5.0.0
+-----
+
+ * Dropped support for constructing a `TreeBuilder` without passing root node information.
+ * Removed the `root()` method in `TreeBuilder`, pass the root node information to the constructor instead
+ * Added method `getChildNodeDefinitions()` to ParentNodeDefinitionInterface
+ * Removed `FileLoaderLoadException`, use `LoaderLoadException` instead
+
+4.4.0
+-----
+
+ * added a way to exclude patterns of resources from being imported by the `import()` method
+
+4.3.0
+-----
+
+ * deprecated using environment variables with `cannotBeEmpty()` if the value is validated with `validate()`
+ * made `Resource\*` classes final and not implement `Serializable` anymore
+ * deprecated the `root()` method in `TreeBuilder`, pass the root node information to the constructor instead
+
+4.2.0
+-----
+
+ * deprecated constructing a `TreeBuilder` without passing root node information
+ * renamed `FileLoaderLoadException` to `LoaderLoadException`
+
+4.1.0
+-----
+
+ * added `setPathSeparator` method to `NodeBuilder` class
+ * added third `$pathSeparator` constructor argument to `BaseNode`
+ * the `Processor` class has been made final
+
+4.0.0
+-----
+
+ * removed `ConfigCachePass`
+
+3.4.0
+-----
+
+ * added `setDeprecated()` method to indicate a deprecated node
+ * added `XmlUtils::parse()` method to parse an XML string
+ * deprecated `ConfigCachePass`
+
+3.3.0
+-----
+
+ * added `ReflectionClassResource` class
+ * added second `$exists` constructor argument to `ClassExistenceResource`
+ * made `ClassExistenceResource` work with interfaces and traits
+ * added `ConfigCachePass` (originally in FrameworkBundle)
+ * added `castToArray()` helper to turn any config value into an array
+
+3.0.0
+-----
+
+ * removed `ReferenceDumper` class
+ * removed the `ResourceInterface::isFresh()` method
+ * removed `BCResourceInterfaceChecker` class
+ * removed `ResourceInterface::getResource()` method
+
+2.8.0
+-----
+
+The edge case of defining just one value for nodes of type Enum is now allowed:
+
+```php
+$rootNode
+ ->children()
+ ->enumNode('variable')
+ ->values(['value'])
+ ->end()
+ ->end()
+;
+```
+
+Before: `InvalidArgumentException` (variable must contain at least two
+distinct elements).
+After: the code will work as expected and it will restrict the values of the
+`variable` option to just `value`.
+
+ * deprecated the `ResourceInterface::isFresh()` method. If you implement custom resource types and they
+ can be validated that way, make them implement the new `SelfCheckingResourceInterface`.
+ * deprecated the getResource() method in ResourceInterface. You can still call this method
+ on concrete classes implementing the interface, but it does not make sense at the interface
+ level as you need to know about the particular type of resource at hand to understand the
+ semantics of the returned value.
+
+2.7.0
+-----
+
+ * added `ConfigCacheInterface`, `ConfigCacheFactoryInterface` and a basic `ConfigCacheFactory`
+ implementation to delegate creation of ConfigCache instances
+
+2.2.0
+-----
+
+ * added `ArrayNodeDefinition::canBeEnabled()` and `ArrayNodeDefinition::canBeDisabled()`
+ to ease configuration when some sections are respectively disabled / enabled
+ by default.
+ * added a `normalizeKeys()` method for array nodes (to avoid key normalization)
+ * added numerical type handling for config definitions
+ * added convenience methods for optional configuration sections to `ArrayNodeDefinition`
+ * added a utils class for XML manipulations
+
+2.1.0
+-----
+
+ * added a way to add documentation on configuration
+ * implemented `Serializable` on resources
+ * `LoaderResolverInterface` is now used instead of `LoaderResolver` for type
+ hinting
diff --git a/symfony/config/ConfigCache.php b/symfony/config/ConfigCache.php
new file mode 100644
index 0000000000000000000000000000000000000000..cee286f486f560cfe772bee8f7f7d0278f8cb148
--- /dev/null
+++ b/symfony/config/ConfigCache.php
@@ -0,0 +1,67 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config;
+
+use Symfony\Component\Config\Resource\ResourceInterface;
+use Symfony\Component\Config\Resource\SelfCheckingResourceChecker;
+use Symfony\Component\Config\Resource\SkippingResourceChecker;
+
+/**
+ * ConfigCache caches arbitrary content in files on disk.
+ *
+ * When in debug mode, those metadata resources that implement
+ * \Symfony\Component\Config\Resource\SelfCheckingResourceInterface will
+ * be used to check cache freshness.
+ *
+ * @author Fabien Potencier
+ * @author Matthias Pigulla
+ */
+class ConfigCache extends ResourceCheckerConfigCache
+{
+ /**
+ * @param string $file The absolute cache path
+ * @param bool $debug Whether debugging is enabled or not
+ * @param string|null $metaFile The absolute path to the meta file
+ * @param class-string[]|null $skippedResourceTypes
+ */
+ public function __construct(
+ string $file,
+ private bool $debug,
+ ?string $metaFile = null,
+ ?array $skippedResourceTypes = null,
+ ) {
+ $checkers = [];
+ if ($this->debug) {
+ if (null !== $skippedResourceTypes) {
+ $checkers[] = new SkippingResourceChecker($skippedResourceTypes);
+ }
+ $checkers[] = new SelfCheckingResourceChecker();
+ }
+
+ parent::__construct($file, $checkers, $metaFile);
+ }
+
+ /**
+ * Checks if the cache is still fresh.
+ *
+ * This implementation always returns true when debug is off and the
+ * cache file exists.
+ */
+ public function isFresh(): bool
+ {
+ if (!$this->debug && is_file($this->getPath())) {
+ return true;
+ }
+
+ return parent::isFresh();
+ }
+}
diff --git a/symfony/config/ConfigCacheFactory.php b/symfony/config/ConfigCacheFactory.php
new file mode 100644
index 0000000000000000000000000000000000000000..27a18e7518488517f0a3a57f8c2c9b119c8ccbbf
--- /dev/null
+++ b/symfony/config/ConfigCacheFactory.php
@@ -0,0 +1,42 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config;
+
+/**
+ * Basic implementation of ConfigCacheFactoryInterface that
+ * creates an instance of the default ConfigCache.
+ *
+ * This factory and/or cache do not support cache validation
+ * by means of ResourceChecker instances (that is, service-based).
+ *
+ * @author Matthias Pigulla
+ */
+class ConfigCacheFactory implements ConfigCacheFactoryInterface
+{
+ /**
+ * @param bool $debug The debug flag to pass to ConfigCache
+ */
+ public function __construct(
+ private bool $debug,
+ ) {
+ }
+
+ public function cache(string $file, callable $callback): ConfigCacheInterface
+ {
+ $cache = new ConfigCache($file, $this->debug);
+ if (!$cache->isFresh()) {
+ $callback($cache);
+ }
+
+ return $cache;
+ }
+}
diff --git a/symfony/config/ConfigCacheFactoryInterface.php b/symfony/config/ConfigCacheFactoryInterface.php
new file mode 100644
index 0000000000000000000000000000000000000000..01c90d1e30d7f6610d58e4595af234871fffa7dd
--- /dev/null
+++ b/symfony/config/ConfigCacheFactoryInterface.php
@@ -0,0 +1,30 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config;
+
+/**
+ * Interface for a ConfigCache factory. This factory creates
+ * an instance of ConfigCacheInterface and initializes the
+ * cache if necessary.
+ *
+ * @author Matthias Pigulla
+ */
+interface ConfigCacheFactoryInterface
+{
+ /**
+ * Creates a cache instance and (re-)initializes it if necessary.
+ *
+ * @param string $file The absolute cache file path
+ * @param callable $callable The callable to be executed when the cache needs to be filled (i. e. is not fresh). The cache will be passed as the only parameter to this callback
+ */
+ public function cache(string $file, callable $callable): ConfigCacheInterface;
+}
diff --git a/symfony/config/ConfigCacheInterface.php b/symfony/config/ConfigCacheInterface.php
new file mode 100644
index 0000000000000000000000000000000000000000..7b9d388973ba5ae5df8572f6bc082fecc6f9ff16
--- /dev/null
+++ b/symfony/config/ConfigCacheInterface.php
@@ -0,0 +1,45 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config;
+
+use Symfony\Component\Config\Resource\ResourceInterface;
+
+/**
+ * Interface for ConfigCache.
+ *
+ * @author Matthias Pigulla
+ */
+interface ConfigCacheInterface
+{
+ /**
+ * Gets the cache file path.
+ */
+ public function getPath(): string;
+
+ /**
+ * Checks if the cache is still fresh.
+ *
+ * This check should take the metadata passed to the write() method into consideration.
+ */
+ public function isFresh(): bool;
+
+ /**
+ * Writes the given content into the cache file. Metadata will be stored
+ * independently and can be used to check cache freshness at a later time.
+ *
+ * @param string $content The content to write into the cache
+ * @param ResourceInterface[]|null $metadata An array of ResourceInterface instances
+ *
+ * @throws \RuntimeException When the cache file cannot be written
+ */
+ public function write(string $content, ?array $metadata = null): void;
+}
diff --git a/symfony/config/Definition/ArrayNode.php b/symfony/config/Definition/ArrayNode.php
new file mode 100644
index 0000000000000000000000000000000000000000..a199a697d6e5d896aa7cd7a1de616b89a8a8ab4e
--- /dev/null
+++ b/symfony/config/Definition/ArrayNode.php
@@ -0,0 +1,391 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Definition;
+
+use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
+use Symfony\Component\Config\Definition\Exception\InvalidTypeException;
+use Symfony\Component\Config\Definition\Exception\UnsetKeyException;
+
+/**
+ * Represents an Array node in the config tree.
+ *
+ * @author Johannes M. Schmitt
+ */
+class ArrayNode extends BaseNode implements PrototypeNodeInterface
+{
+ protected array $xmlRemappings = [];
+ protected array $children = [];
+ protected bool $allowFalse = false;
+ protected bool $allowNewKeys = true;
+ protected bool $addIfNotSet = false;
+ protected bool $performDeepMerging = true;
+ protected bool $ignoreExtraKeys = false;
+ protected bool $removeExtraKeys = true;
+ protected bool $normalizeKeys = true;
+
+ public function setNormalizeKeys(bool $normalizeKeys): void
+ {
+ $this->normalizeKeys = $normalizeKeys;
+ }
+
+ /**
+ * Namely, you mostly have foo_bar in YAML while you have foo-bar in XML.
+ * After running this method, all keys are normalized to foo_bar.
+ *
+ * If you have a mixed key like foo-bar_moo, it will not be altered.
+ * The key will also not be altered if the target key already exists.
+ */
+ protected function preNormalize(mixed $value): mixed
+ {
+ if (!$this->normalizeKeys || !\is_array($value)) {
+ return $value;
+ }
+
+ $normalized = [];
+
+ foreach ($value as $k => $v) {
+ if (str_contains($k, '-') && !str_contains($k, '_') && !\array_key_exists($normalizedKey = str_replace('-', '_', $k), $value)) {
+ $normalized[$normalizedKey] = $v;
+ } else {
+ $normalized[$k] = $v;
+ }
+ }
+
+ return $normalized;
+ }
+
+ /**
+ * Retrieves the children of this node.
+ *
+ * @return array
+ */
+ public function getChildren(): array
+ {
+ return $this->children;
+ }
+
+ /**
+ * Sets the xml remappings that should be performed.
+ *
+ * @param array $remappings An array of the form [[string, string]]
+ */
+ public function setXmlRemappings(array $remappings): void
+ {
+ $this->xmlRemappings = $remappings;
+ }
+
+ /**
+ * Gets the xml remappings that should be performed.
+ *
+ * @return array an array of the form [[string, string]]
+ */
+ public function getXmlRemappings(): array
+ {
+ return $this->xmlRemappings;
+ }
+
+ /**
+ * Sets whether to add default values for this array if it has not been
+ * defined in any of the configuration files.
+ */
+ public function setAddIfNotSet(bool $boolean): void
+ {
+ $this->addIfNotSet = $boolean;
+ }
+
+ /**
+ * Sets whether false is allowed as value indicating that the array should be unset.
+ */
+ public function setAllowFalse(bool $allow): void
+ {
+ $this->allowFalse = $allow;
+ }
+
+ /**
+ * Sets whether new keys can be defined in subsequent configurations.
+ */
+ public function setAllowNewKeys(bool $allow): void
+ {
+ $this->allowNewKeys = $allow;
+ }
+
+ /**
+ * Sets if deep merging should occur.
+ */
+ public function setPerformDeepMerging(bool $boolean): void
+ {
+ $this->performDeepMerging = $boolean;
+ }
+
+ /**
+ * Whether extra keys should just be ignored without an exception.
+ *
+ * @param bool $boolean To allow extra keys
+ * @param bool $remove To remove extra keys
+ */
+ public function setIgnoreExtraKeys(bool $boolean, bool $remove = true): void
+ {
+ $this->ignoreExtraKeys = $boolean;
+ $this->removeExtraKeys = $this->ignoreExtraKeys && $remove;
+ }
+
+ /**
+ * Returns true when extra keys should be ignored without an exception.
+ */
+ public function shouldIgnoreExtraKeys(): bool
+ {
+ return $this->ignoreExtraKeys;
+ }
+
+ public function setName(string $name): void
+ {
+ $this->name = $name;
+ }
+
+ public function hasDefaultValue(): bool
+ {
+ return $this->addIfNotSet;
+ }
+
+ public function getDefaultValue(): mixed
+ {
+ if (!$this->hasDefaultValue()) {
+ throw new \RuntimeException(\sprintf('The node at path "%s" has no default value.', $this->getPath()));
+ }
+
+ $defaults = [];
+ foreach ($this->children as $name => $child) {
+ if ($child->hasDefaultValue()) {
+ $defaults[$name] = $child->getDefaultValue();
+ }
+ }
+
+ return $defaults;
+ }
+
+ /**
+ * Adds a child node.
+ *
+ * @throws \InvalidArgumentException when the child node has no name
+ * @throws \InvalidArgumentException when the child node's name is not unique
+ */
+ public function addChild(NodeInterface $node): void
+ {
+ $name = $node->getName();
+ if ('' === $name) {
+ throw new \InvalidArgumentException('Child nodes must be named.');
+ }
+ if (isset($this->children[$name])) {
+ throw new \InvalidArgumentException(\sprintf('A child node named "%s" already exists.', $name));
+ }
+
+ $this->children[$name] = $node;
+ }
+
+ /**
+ * @throws UnsetKeyException
+ * @throws InvalidConfigurationException if the node doesn't have enough children
+ */
+ protected function finalizeValue(mixed $value): mixed
+ {
+ if (false === $value) {
+ throw new UnsetKeyException(\sprintf('Unsetting key for path "%s", value: false.', $this->getPath()));
+ }
+
+ foreach ($this->children as $name => $child) {
+ if (!\array_key_exists($name, $value)) {
+ if ($child->isRequired()) {
+ $message = \sprintf('The child config "%s" under "%s" must be configured', $name, $this->getPath());
+ if ($child->getInfo()) {
+ $message .= \sprintf(': %s', $child->getInfo());
+ } else {
+ $message .= '.';
+ }
+ $ex = new InvalidConfigurationException($message);
+ $ex->setPath($this->getPath());
+
+ throw $ex;
+ }
+
+ if ($child->hasDefaultValue()) {
+ $value[$name] = $child->getDefaultValue();
+ }
+
+ continue;
+ }
+
+ if ($child->isDeprecated()) {
+ $deprecation = $child->getDeprecation($name, $this->getPath());
+ trigger_deprecation($deprecation['package'], $deprecation['version'], $deprecation['message']);
+ }
+
+ try {
+ $value[$name] = $child->finalize($value[$name]);
+ } catch (UnsetKeyException) {
+ unset($value[$name]);
+ }
+ }
+
+ return $value;
+ }
+
+ protected function validateType(mixed $value): void
+ {
+ if (!\is_array($value) && (!$this->allowFalse || false !== $value)) {
+ $ex = new InvalidTypeException(\sprintf('Invalid type for path "%s". Expected "array", but got "%s"', $this->getPath(), get_debug_type($value)));
+ if ($hint = $this->getInfo()) {
+ $ex->addHint($hint);
+ }
+ $ex->setPath($this->getPath());
+
+ throw $ex;
+ }
+ }
+
+ /**
+ * @throws InvalidConfigurationException
+ */
+ protected function normalizeValue(mixed $value): mixed
+ {
+ if (false === $value) {
+ return $value;
+ }
+
+ $value = $this->remapXml($value);
+
+ $normalized = [];
+ foreach ($value as $name => $val) {
+ if (isset($this->children[$name])) {
+ try {
+ $normalized[$name] = $this->children[$name]->normalize($val);
+ } catch (UnsetKeyException) {
+ }
+ unset($value[$name]);
+ } elseif (!$this->removeExtraKeys) {
+ $normalized[$name] = $val;
+ }
+ }
+
+ // if extra fields are present, throw exception
+ if (\count($value) && !$this->ignoreExtraKeys) {
+ $proposals = array_keys($this->children);
+ sort($proposals);
+ $guesses = [];
+
+ foreach (array_keys($value) as $subject) {
+ $minScore = \INF;
+ foreach ($proposals as $proposal) {
+ $distance = levenshtein($subject, $proposal);
+ if ($distance <= $minScore && $distance < 3) {
+ $guesses[$proposal] = $distance;
+ $minScore = $distance;
+ }
+ }
+ }
+
+ $msg = \sprintf('Unrecognized option%s "%s" under "%s"', 1 === \count($value) ? '' : 's', implode(', ', array_keys($value)), $this->getPath());
+
+ if (\count($guesses)) {
+ asort($guesses);
+ $msg .= \sprintf('. Did you mean "%s"?', implode('", "', array_keys($guesses)));
+ } else {
+ $msg .= \sprintf('. Available option%s %s "%s".', 1 === \count($proposals) ? '' : 's', 1 === \count($proposals) ? 'is' : 'are', implode('", "', $proposals));
+ }
+
+ $ex = new InvalidConfigurationException($msg);
+ $ex->setPath($this->getPath());
+
+ throw $ex;
+ }
+
+ return $normalized;
+ }
+
+ /**
+ * Remaps multiple singular values to a single plural value.
+ */
+ protected function remapXml(array $value): array
+ {
+ foreach ($this->xmlRemappings as [$singular, $plural]) {
+ if (!isset($value[$singular])) {
+ continue;
+ }
+
+ $value[$plural] = Processor::normalizeConfig($value, $singular, $plural);
+ unset($value[$singular]);
+ }
+
+ return $value;
+ }
+
+ /**
+ * @throws InvalidConfigurationException
+ * @throws \RuntimeException
+ */
+ protected function mergeValues(mixed $leftSide, mixed $rightSide): mixed
+ {
+ if (false === $rightSide) {
+ // if this is still false after the last config has been merged the
+ // finalization pass will take care of removing this key entirely
+ return false;
+ }
+
+ if (false === $leftSide || !$this->performDeepMerging) {
+ return $rightSide;
+ }
+
+ if ($this->getAttribute('auto_enable')
+ && \is_array($leftSide) && \is_array($rightSide)
+ && !\array_key_exists('enabled', $leftSide) && !\array_key_exists('enabled', $rightSide)
+ ) {
+ $rightSide['enabled'] = true;
+ }
+
+ foreach ($rightSide as $k => $v) {
+ // no conflict
+ if (!\array_key_exists($k, $leftSide)) {
+ if (!$this->allowNewKeys) {
+ $ex = new InvalidConfigurationException(\sprintf('You are not allowed to define new elements for path "%s". Please define all elements for this path in one config file. If you are trying to overwrite an element, make sure you redefine it with the same name.', $this->getPath()));
+ $ex->setPath($this->getPath());
+
+ throw $ex;
+ }
+
+ if (\is_array($v) && ($this->children[$k] ?? null) instanceof self) {
+ // Ensure child's merge is called to handle auto_enable recursively
+ $leftSide[$k] = $this->children[$k]->merge([], $v);
+ } else {
+ $leftSide[$k] = $v;
+ }
+ continue;
+ }
+
+ if (!isset($this->children[$k])) {
+ if (!$this->ignoreExtraKeys || $this->removeExtraKeys) {
+ throw new \RuntimeException('merge() expects a normalized config array.');
+ }
+
+ $leftSide[$k] = $v;
+ continue;
+ }
+
+ $leftSide[$k] = $this->children[$k]->merge($leftSide[$k], $v);
+ }
+
+ return $leftSide;
+ }
+
+ protected function allowPlaceholders(): bool
+ {
+ return false;
+ }
+}
diff --git a/symfony/config/Definition/ArrayShapeGenerator.php b/symfony/config/Definition/ArrayShapeGenerator.php
new file mode 100644
index 0000000000000000000000000000000000000000..104bc8343966127b9f3fd8fa2b50da74d88c6933
--- /dev/null
+++ b/symfony/config/Definition/ArrayShapeGenerator.php
@@ -0,0 +1,150 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Definition;
+
+use Symfony\Component\Config\Loader\ParamConfigurator;
+
+/**
+ * @author Alexandre Daubois
+ */
+final class ArrayShapeGenerator
+{
+ public static function generate(NodeInterface $node): string
+ {
+ return str_replace("\n", "\n * ", self::doGeneratePhpDoc($node));
+ }
+
+ private static function doGeneratePhpDoc(NodeInterface $node, int $nestingLevel = 1): string
+ {
+ if (!$node instanceof ArrayNode) {
+ $typeString = match (true) {
+ $node instanceof BooleanNode => $node->hasDefaultValue() && null === $node->getDefaultValue() ? 'bool|null' : 'bool',
+ $node instanceof StringNode => 'string',
+ $node instanceof NumericNode => self::handleNumericNode($node),
+ $node instanceof EnumNode => $node->getPermissibleValues('|', false),
+ $node instanceof ScalarNode => 'scalar|null',
+ default => 'mixed',
+ };
+
+ if ('mixed' === $typeString) {
+ return $typeString;
+ }
+
+ if (str_ends_with($typeString, '|null')) {
+ return substr_replace($typeString, '|\\'.ParamConfigurator::class, -5, 0);
+ }
+
+ return $typeString.'|\\'.ParamConfigurator::class;
+ }
+
+ if ($node instanceof PrototypedArrayNode) {
+ $isHashmap = (bool) $node->getKeyAttribute();
+ $arrayShape = ($isHashmap ? 'arraygetPrototype(), 1 + $nestingLevel).'>';
+
+ return implode('|', [...self::getNormalizedTypes($node, ['array', 'any']), $arrayShape]);
+ }
+
+ if (!($children = $node->getChildren()) && !$node->getParent() instanceof PrototypedArrayNode) {
+ return $node->hasDefaultValue() && null === $node->getDefaultValue() ? 'array|null' : 'array';
+ }
+
+ $arrayShape = \sprintf("array{%s\n", self::generateInlinePhpDocForNode($node));
+
+ foreach ($children as $child) {
+ $arrayShape .= str_repeat(' ', $nestingLevel).self::dumpNodeKey($child).': ';
+
+ if ($child instanceof PrototypedArrayNode) {
+ $isHashmap = (bool) $child->getKeyAttribute();
+ $childArrayType = ($isHashmap ? 'arraygetPrototype(), 1 + $nestingLevel).'>';
+ $arrayShape .= $child->hasDefaultValue() && null === $child->getDefaultValue() ? $childArrayType.'|null' : $childArrayType;
+ } else {
+ $arrayShape .= self::doGeneratePhpDoc($child, 1 + $nestingLevel);
+ }
+
+ $arrayShape .= \sprintf(",%s\n", !$child instanceof ArrayNode ? self::generateInlinePhpDocForNode($child) : '');
+ }
+
+ if ($node->shouldIgnoreExtraKeys()) {
+ $arrayShape .= str_repeat(' ', $nestingLevel)."...\n";
+ }
+
+ $arrayShape = $arrayShape.str_repeat(' ', $nestingLevel - 1).'}';
+
+ return implode('|', [...self::getNormalizedTypes($node, ['array', 'any']), $arrayShape]);
+ }
+
+ private static function dumpNodeKey(NodeInterface $node): string
+ {
+ $name = $node->getName();
+ $quoted = str_starts_with($name, '@')
+ || \in_array(strtolower($name), ['int', 'float', 'bool', 'null', 'scalar'], true)
+ || strpbrk($name, '\'"');
+
+ if ($quoted) {
+ $name = "'".addslashes($name)."'";
+ }
+
+ return $name.($node->isRequired() ? '' : '?');
+ }
+
+ private static function handleNumericNode(NumericNode $node): string
+ {
+ // We could use int<%s, %s> but PhpStorm doesn't support it yet
+ // $min = $node->getMin() ?? 'min';
+ // $max = $node->getMax() ?? 'max';
+
+ if ($node instanceof IntegerNode) {
+ return 'int';
+ }
+ if ($node instanceof FloatNode) {
+ return 'float';
+ }
+
+ return 'int|float';
+ }
+
+ private static function generateInlinePhpDocForNode(BaseNode $node): string
+ {
+ $comment = '';
+ if ($node->isDeprecated()) {
+ $comment .= ' // Deprecated: '.$node->getDeprecation($node->getName(), $node->getPath())['message'];
+ }
+
+ if ($info = $node->getInfo()) {
+ $comment .= ' // '.$info;
+ }
+
+ if ((!$node instanceof ArrayNode || ($node = $node->getParent()) instanceof PrototypedArrayNode) && $node->hasDefaultValue()) {
+ $comment .= ' // Default: '.json_encode($node->getDefaultValue(), \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE | \JSON_PRESERVE_ZERO_FRACTION);
+ }
+
+ return rtrim(preg_replace('/\s+/', ' ', $comment));
+ }
+
+ /**
+ * @return list
+ */
+ private static function getNormalizedTypes(BaseNode $node, array $excluded = []): array
+ {
+ $types = array_diff($node->getNormalizedTypes(), $excluded);
+
+ if ($node->hasDefaultValue() && null === $node->getDefaultValue()) {
+ $types[] = 'null';
+ }
+
+ $types = array_unique($types);
+
+ sort($types);
+
+ return $types;
+ }
+}
diff --git a/symfony/config/Definition/BaseNode.php b/symfony/config/Definition/BaseNode.php
new file mode 100644
index 0000000000000000000000000000000000000000..90a20b627f211300f03e7a6ff14dc60e648be02a
--- /dev/null
+++ b/symfony/config/Definition/BaseNode.php
@@ -0,0 +1,539 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Definition;
+
+use Symfony\Component\Config\Definition\Builder\ExprBuilder;
+use Symfony\Component\Config\Definition\Exception\Exception;
+use Symfony\Component\Config\Definition\Exception\ForbiddenOverwriteException;
+use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
+use Symfony\Component\Config\Definition\Exception\InvalidTypeException;
+use Symfony\Component\Config\Definition\Exception\UnsetKeyException;
+use Symfony\Component\Config\Exception\LogicException;
+
+/**
+ * The base node class.
+ *
+ * @author Johannes M. Schmitt
+ */
+abstract class BaseNode implements NodeInterface
+{
+ public const DEFAULT_PATH_SEPARATOR = '.';
+
+ private static array $placeholderUniquePrefixes = [];
+ private static array $placeholders = [];
+
+ protected string $name;
+ protected array $normalizationClosures = [];
+ protected array $normalizedTypes = [];
+ protected array $finalValidationClosures = [];
+ protected bool $allowOverwrite = true;
+ protected bool $required = false;
+ protected array $deprecation = [];
+ protected array $equivalentValues = [];
+ protected array $attributes = [];
+
+ private mixed $handlingPlaceholder = null;
+
+ /**
+ * @throws \InvalidArgumentException if the name contains a period
+ */
+ public function __construct(
+ ?string $name,
+ protected ?NodeInterface $parent = null,
+ protected string $pathSeparator = self::DEFAULT_PATH_SEPARATOR,
+ ) {
+ if (str_contains($name = (string) $name, $pathSeparator)) {
+ throw new \InvalidArgumentException('The name must not contain ".'.$pathSeparator.'".');
+ }
+
+ $this->name = $name;
+ }
+
+ /**
+ * Register possible (dummy) values for a dynamic placeholder value.
+ *
+ * Matching configuration values will be processed with a provided value, one by one. After a provided value is
+ * successfully processed the configuration value is returned as is, thus preserving the placeholder.
+ *
+ * @internal
+ */
+ public static function setPlaceholder(string $placeholder, array $values): void
+ {
+ if (!$values) {
+ throw new \InvalidArgumentException('At least one value must be provided.');
+ }
+
+ self::$placeholders[$placeholder] = $values;
+ }
+
+ /**
+ * Adds a common prefix for dynamic placeholder values.
+ *
+ * Matching configuration values will be skipped from being processed and are returned as is, thus preserving the
+ * placeholder. An exact match provided by {@see setPlaceholder()} might take precedence.
+ *
+ * @internal
+ */
+ public static function setPlaceholderUniquePrefix(string $prefix): void
+ {
+ self::$placeholderUniquePrefixes[] = $prefix;
+ }
+
+ /**
+ * Resets all current placeholders available.
+ *
+ * @internal
+ */
+ public static function resetPlaceholders(): void
+ {
+ self::$placeholderUniquePrefixes = [];
+ self::$placeholders = [];
+ }
+
+ public function setAttribute(string $key, mixed $value): void
+ {
+ $this->attributes[$key] = $value;
+ }
+
+ public function getAttribute(string $key, mixed $default = null): mixed
+ {
+ return $this->attributes[$key] ?? $default;
+ }
+
+ public function hasAttribute(string $key): bool
+ {
+ return isset($this->attributes[$key]);
+ }
+
+ public function getAttributes(): array
+ {
+ return $this->attributes;
+ }
+
+ public function setAttributes(array $attributes): void
+ {
+ $this->attributes = $attributes;
+ }
+
+ public function removeAttribute(string $key): void
+ {
+ unset($this->attributes[$key]);
+ }
+
+ /**
+ * Sets an info message.
+ */
+ public function setInfo(string $info): void
+ {
+ $this->setAttribute('info', $info);
+ }
+
+ /**
+ * Returns info message.
+ */
+ public function getInfo(): ?string
+ {
+ return $this->getAttribute('info');
+ }
+
+ /**
+ * Sets the example configuration for this node.
+ */
+ public function setExample(string|array $example): void
+ {
+ $this->setAttribute('example', $example);
+ }
+
+ /**
+ * Retrieves the example configuration for this node.
+ */
+ public function getExample(): string|array|null
+ {
+ return $this->getAttribute('example');
+ }
+
+ /**
+ * Adds an equivalent value.
+ */
+ public function addEquivalentValue(mixed $originalValue, mixed $equivalentValue): void
+ {
+ $this->equivalentValues[] = [$originalValue, $equivalentValue];
+ }
+
+ /**
+ * Set this node as required.
+ */
+ public function setRequired(bool $boolean): void
+ {
+ $this->required = $boolean;
+ }
+
+ /**
+ * Sets this node as deprecated.
+ *
+ * You can use %node% and %path% placeholders in your message to display,
+ * respectively, the node name and its complete path.
+ *
+ * @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 deprecation message to use
+ */
+ public function setDeprecated(string $package, string $version, string $message = 'The child node "%node%" at path "%path%" is deprecated.'): void
+ {
+ $this->deprecation = [
+ 'package' => $package,
+ 'version' => $version,
+ 'message' => $message,
+ ];
+ }
+
+ /**
+ * Sets if this node can be overridden.
+ */
+ public function setAllowOverwrite(bool $allow): void
+ {
+ $this->allowOverwrite = $allow;
+ }
+
+ /**
+ * Sets the closures used for normalization.
+ *
+ * @param \Closure[] $closures An array of Closures used for normalization
+ */
+ public function setNormalizationClosures(array $closures): void
+ {
+ $this->normalizationClosures = $closures;
+ }
+
+ /**
+ * Sets the list of types supported by normalization.
+ *
+ * @param list $types
+ */
+ public function setNormalizedTypes(array $types): void
+ {
+ $this->normalizedTypes = $types;
+ }
+
+ /**
+ * Gets the list of types supported by normalization.
+ *
+ * @return list
+ */
+ public function getNormalizedTypes(): array
+ {
+ return $this->normalizedTypes;
+ }
+
+ /**
+ * Sets the closures used for final validation.
+ *
+ * @param \Closure[] $closures An array of Closures used for final validation
+ */
+ public function setFinalValidationClosures(array $closures): void
+ {
+ $this->finalValidationClosures = $closures;
+ }
+
+ public function isRequired(): bool
+ {
+ return $this->required;
+ }
+
+ /**
+ * Checks if this node is deprecated.
+ */
+ public function isDeprecated(): bool
+ {
+ return (bool) $this->deprecation;
+ }
+
+ /**
+ * @param string $node The configuration node name
+ * @param string $path The path of the node
+ *
+ * @return array{package: string, version: string, message: string}
+ */
+ public function getDeprecation(string $node, string $path): array
+ {
+ if (!$this->deprecation) {
+ throw new LogicException(\sprintf('The node "%s" is not deprecated.', $this->getName()));
+ }
+
+ return [
+ 'package' => $this->deprecation['package'],
+ 'version' => $this->deprecation['version'],
+ 'message' => strtr($this->deprecation['message'], ['%node%' => $node, '%path%' => $path]),
+ ];
+ }
+
+ /**
+ * @internal
+ */
+ public function getDeprecationMessage(?NodeInterface $parent = null): string
+ {
+ if (!$this->deprecation) {
+ throw new LogicException(\sprintf('The node "%s" is not deprecated.', $this->getName()));
+ }
+
+ $message = strtr($this->deprecation['message'], ['%node%' => $this->getName(), '%path%' => ($parent ?? $this->parent ?? $this)->getPath()]);
+ if ($this->deprecation['package'] || $this->deprecation['version']) {
+ $message = \sprintf('Since %s %s: ', $this->deprecation['package'], $this->deprecation['version']).$message;
+ }
+
+ return $message;
+ }
+
+ public function getName(): string
+ {
+ return $this->name;
+ }
+
+ public function getPath(): string
+ {
+ if (null !== $this->parent) {
+ return $this->parent->getPath().$this->pathSeparator.$this->name;
+ }
+
+ return $this->name;
+ }
+
+ final public function merge(mixed $leftSide, mixed $rightSide): mixed
+ {
+ // Only enforce cannotBeOverwritten when there's actually something to overwrite.
+ // When leftSide is empty (initial population), this check doesn't apply.
+ if (!$this->allowOverwrite && [] !== $leftSide) {
+ throw new ForbiddenOverwriteException(\sprintf('Configuration path "%s" cannot be overwritten. You have to define all options for this path, and any of its sub-paths in one configuration section.', $this->getPath()));
+ }
+
+ if ($leftSide !== $leftPlaceholders = self::resolvePlaceholderValue($leftSide)) {
+ foreach ($leftPlaceholders as $leftPlaceholder) {
+ $this->handlingPlaceholder = $leftSide;
+ try {
+ $this->merge($leftPlaceholder, $rightSide);
+ } finally {
+ $this->handlingPlaceholder = null;
+ }
+ }
+
+ return $rightSide;
+ }
+
+ if ($rightSide !== $rightPlaceholders = self::resolvePlaceholderValue($rightSide)) {
+ foreach ($rightPlaceholders as $rightPlaceholder) {
+ $this->handlingPlaceholder = $rightSide;
+ try {
+ $this->merge($leftSide, $rightPlaceholder);
+ } finally {
+ $this->handlingPlaceholder = null;
+ }
+ }
+
+ return $rightSide;
+ }
+
+ $this->doValidateType($leftSide);
+ $this->doValidateType($rightSide);
+
+ return $this->mergeValues($leftSide, $rightSide);
+ }
+
+ final public function normalize(mixed $value): mixed
+ {
+ $value = $this->preNormalize($value);
+
+ // run custom normalization closures
+ foreach ($this->normalizationClosures as $closure) {
+ $value = $closure($value);
+ }
+
+ // resolve placeholder value
+ if ($value !== $placeholders = self::resolvePlaceholderValue($value)) {
+ foreach ($placeholders as $placeholder) {
+ $this->handlingPlaceholder = $value;
+ try {
+ $this->normalize($placeholder);
+ } finally {
+ $this->handlingPlaceholder = null;
+ }
+ }
+
+ return $value;
+ }
+
+ // replace value with their equivalent
+ foreach ($this->equivalentValues as $data) {
+ if ($data[0] === $value) {
+ $value = $data[1];
+ }
+ }
+
+ // validate type
+ $this->doValidateType($value);
+
+ // normalize value
+ return $this->normalizeValue($value);
+ }
+
+ /**
+ * Normalizes the value before any other normalization is applied.
+ */
+ protected function preNormalize(mixed $value): mixed
+ {
+ return $value;
+ }
+
+ /**
+ * Returns parent node for this node.
+ */
+ public function getParent(): ?NodeInterface
+ {
+ return $this->parent;
+ }
+
+ final public function finalize(mixed $value): mixed
+ {
+ if ($value !== $placeholders = self::resolvePlaceholderValue($value)) {
+ foreach ($placeholders as $placeholder) {
+ $this->handlingPlaceholder = $value;
+ try {
+ $this->finalize($placeholder);
+ } finally {
+ $this->handlingPlaceholder = null;
+ }
+ }
+
+ return $value;
+ }
+
+ $this->doValidateType($value);
+
+ $value = $this->finalizeValue($value);
+
+ // Perform validation on the final value if a closure has been set.
+ // The closure is also allowed to return another value.
+ foreach ($this->finalValidationClosures as $closure) {
+ try {
+ $value = $closure($value);
+ } catch (Exception $e) {
+ if ($e instanceof UnsetKeyException && null !== $this->handlingPlaceholder) {
+ continue;
+ }
+
+ throw $e;
+ } catch (\Exception $e) {
+ throw new InvalidConfigurationException(\sprintf('Invalid configuration for path "%s": ', $this->getPath()).$e->getMessage(), $e->getCode(), $e);
+ }
+ }
+
+ return $value;
+ }
+
+ /**
+ * Validates the type of a Node.
+ *
+ * @throws InvalidTypeException when the value is invalid
+ */
+ abstract protected function validateType(mixed $value): void;
+
+ /**
+ * Normalizes the value.
+ */
+ abstract protected function normalizeValue(mixed $value): mixed;
+
+ /**
+ * Merges two values together.
+ */
+ abstract protected function mergeValues(mixed $leftSide, mixed $rightSide): mixed;
+
+ /**
+ * Finalizes a value.
+ */
+ abstract protected function finalizeValue(mixed $value): mixed;
+
+ /**
+ * Tests if placeholder values are allowed for this node.
+ */
+ protected function allowPlaceholders(): bool
+ {
+ return true;
+ }
+
+ /**
+ * Tests if a placeholder is being handled currently.
+ */
+ protected function isHandlingPlaceholder(): bool
+ {
+ return null !== $this->handlingPlaceholder;
+ }
+
+ /**
+ * Gets allowed dynamic types for this node.
+ */
+ protected function getValidPlaceholderTypes(): array
+ {
+ return [];
+ }
+
+ private static function resolvePlaceholderValue(mixed $value): mixed
+ {
+ if (\is_string($value)) {
+ if (isset(self::$placeholders[$value])) {
+ return self::$placeholders[$value];
+ }
+
+ foreach (self::$placeholderUniquePrefixes as $placeholderUniquePrefix) {
+ if (str_starts_with($value, $placeholderUniquePrefix)) {
+ return [];
+ }
+ }
+ }
+
+ return $value;
+ }
+
+ private function doValidateType(mixed $value): void
+ {
+ if (null !== $this->handlingPlaceholder && !$this->allowPlaceholders()) {
+ $e = new InvalidTypeException(\sprintf('A dynamic value is not compatible with a "%s" node type at path "%s".', static::class, $this->getPath()));
+ $e->setPath($this->getPath());
+
+ throw $e;
+ }
+
+ if (null === $this->handlingPlaceholder || null === $value) {
+ $this->validateType($value);
+
+ return;
+ }
+
+ $knownTypes = array_keys(self::$placeholders[$this->handlingPlaceholder]);
+ $validTypes = $this->getValidPlaceholderTypes();
+
+ if ($validTypes && array_diff($knownTypes, $validTypes)) {
+ $e = new InvalidTypeException(\sprintf(
+ 'Invalid type for path "%s". Expected %s, but got %s.',
+ $this->getPath(),
+ 1 === \count($validTypes) ? '"'.reset($validTypes).'"' : 'one of "'.implode('", "', $validTypes).'"',
+ 1 === \count($knownTypes) ? '"'.reset($knownTypes).'"' : 'one of "'.implode('", "', $knownTypes).'"'
+ ));
+ if ($hint = $this->getInfo()) {
+ $e->addHint($hint);
+ }
+ $e->setPath($this->getPath());
+
+ throw $e;
+ }
+
+ $this->validateType($value);
+ }
+}
diff --git a/symfony/config/Definition/BooleanNode.php b/symfony/config/Definition/BooleanNode.php
new file mode 100644
index 0000000000000000000000000000000000000000..b4ed0f0eb10f93fb62b76514992323e291fd28d6
--- /dev/null
+++ b/symfony/config/Definition/BooleanNode.php
@@ -0,0 +1,59 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Definition;
+
+use Symfony\Component\Config\Definition\Exception\InvalidTypeException;
+
+/**
+ * This node represents a Boolean value in the config tree.
+ *
+ * @author Johannes M. Schmitt
+ */
+class BooleanNode extends ScalarNode
+{
+ public function __construct(
+ ?string $name,
+ ?NodeInterface $parent = null,
+ string $pathSeparator = self::DEFAULT_PATH_SEPARATOR,
+ private bool $nullable = false,
+ ) {
+ parent::__construct($name, $parent, $pathSeparator);
+ }
+
+ protected function validateType(mixed $value): void
+ {
+ if (!\is_bool($value)) {
+ if (null === $value && $this->nullable) {
+ return;
+ }
+
+ $ex = new InvalidTypeException(\sprintf('Invalid type for path "%s". Expected "bool%s", but got "%s".', $this->getPath(), $this->nullable ? '" or "null' : '', get_debug_type($value)));
+ if ($hint = $this->getInfo()) {
+ $ex->addHint($hint);
+ }
+ $ex->setPath($this->getPath());
+
+ throw $ex;
+ }
+ }
+
+ protected function isValueEmpty(mixed $value): bool
+ {
+ // a boolean value cannot be empty
+ return false;
+ }
+
+ protected function getValidPlaceholderTypes(): array
+ {
+ return ['bool'];
+ }
+}
diff --git a/symfony/config/Definition/Builder/ArrayNodeDefinition.php b/symfony/config/Definition/Builder/ArrayNodeDefinition.php
new file mode 100644
index 0000000000000000000000000000000000000000..ca745e799d8e2aec0559ff19a6bd4cf0b0c64a07
--- /dev/null
+++ b/symfony/config/Definition/Builder/ArrayNodeDefinition.php
@@ -0,0 +1,648 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Definition\Builder;
+
+use Symfony\Component\Config\Definition\ArrayNode;
+use Symfony\Component\Config\Definition\Exception\InvalidDefinitionException;
+use Symfony\Component\Config\Definition\NodeInterface;
+use Symfony\Component\Config\Definition\PrototypedArrayNode;
+
+/**
+ * This class provides a fluent interface for defining an array node.
+ *
+ * @template TParent of NodeParentInterface|null = null
+ *
+ * @extends NodeDefinition
+ *
+ * @author Johannes M. Schmitt
+ */
+class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinitionInterface
+{
+ protected bool $performDeepMerging = true;
+ protected bool $ignoreExtraKeys = false;
+ protected bool $removeExtraKeys = true;
+ /**
+ * @var NodeDefinition<$this>[]
+ */
+ protected array $children = [];
+ /**
+ * @var NodeDefinition<$this>
+ */
+ protected NodeDefinition $prototype;
+ protected bool $atLeastOne = false;
+ protected bool $allowNewKeys = true;
+ protected ?string $key = null;
+ protected bool $removeKeyItem = false;
+ protected bool $addDefaults = false;
+ protected int|string|array|false|null $addDefaultChildren = false;
+ /**
+ * @var NodeBuilder
+ */
+ protected NodeBuilder $nodeBuilder;
+ protected bool $normalizeKeys = true;
+
+ /**
+ * @var list|null
+ */
+ protected ?array $allowedTypes = null;
+
+ /**
+ * @param TParent $parent
+ */
+ public function __construct(?string $name, ?NodeParentInterface $parent = null)
+ {
+ parent::__construct($name, $parent);
+
+ $this->nullEquivalent = [];
+ $this->trueEquivalent = [];
+ }
+
+ /**
+ * @return $this
+ */
+ public function defaultValue(mixed $value): static
+ {
+ $this->nullEquivalent = null === $value ? null : [];
+
+ return parent::defaultValue($value);
+ }
+
+ /**
+ * @param NodeBuilder $builder
+ */
+ public function setBuilder(NodeBuilder $builder): void
+ {
+ $this->nodeBuilder = $builder;
+ }
+
+ /**
+ * Allows alternative types and wraps them into arrays.
+ *
+ * @param list $allowedTypes
+ * @param string|null $key The key to wrap the value in
+ *
+ * @return $this
+ */
+ public function acceptAndWrap(array $allowedTypes, ?string $key = null): static
+ {
+ $this->allowedTypes = $allowedTypes;
+
+ foreach ($allowedTypes as $type) {
+ $this->beforeNormalization()->ifTrue(match ($type) {
+ ExprBuilder::TYPE_INT => is_int(...),
+ ExprBuilder::TYPE_STRING => is_string(...),
+ ExprBuilder::TYPE_BOOL => is_bool(...),
+ ExprBuilder::TYPE_NULL => is_null(...),
+ ExprBuilder::TYPE_BACKED_ENUM => static fn ($v) => $v instanceof \BackedEnum,
+ })->then(static fn ($v) => [$key ?? 0 => $v]);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @return NodeBuilder
+ */
+ public function children(): NodeBuilder
+ {
+ return $this->getNodeBuilder();
+ }
+
+ /**
+ * Sets a prototype for child nodes.
+ *
+ * @template T of 'array'|'variable'|'scalar'|'string'|'boolean'|'integer'|'float'|'enum'
+ *
+ * @param T $type
+ *
+ * @return (
+ * T is 'array' ? ArrayNodeDefinition<$this>
+ * : (T is 'variable' ? VariableNodeDefinition<$this>
+ * : (T is 'scalar' ? ScalarNodeDefinition<$this>
+ * : (T is 'string' ? StringNodeDefinition<$this>
+ * : (T is 'boolean' ? BooleanNodeDefinition<$this>
+ * : (T is 'integer' ? IntegerNodeDefinition<$this>
+ * : (T is 'float' ? FloatNodeDefinition<$this>
+ * : (T is 'enum' ? EnumNodeDefinition<$this>
+ * : NodeDefinition<$this>)))))))
+ * )
+ */
+ public function prototype(string $type): NodeDefinition
+ {
+ return $this->prototype = $this->getNodeBuilder()->node(null, $type)->setParent($this);
+ }
+
+ /**
+ * @return VariableNodeDefinition<$this>
+ */
+ public function variablePrototype(): VariableNodeDefinition
+ {
+ return $this->prototype('variable');
+ }
+
+ /**
+ * @return ScalarNodeDefinition<$this>
+ */
+ public function scalarPrototype(): ScalarNodeDefinition
+ {
+ return $this->prototype('scalar');
+ }
+
+ /**
+ * @return StringNodeDefinition<$this>
+ */
+ public function stringPrototype(): StringNodeDefinition
+ {
+ return $this->prototype('string');
+ }
+
+ /**
+ * @return BooleanNodeDefinition<$this>
+ */
+ public function booleanPrototype(): BooleanNodeDefinition
+ {
+ return $this->prototype('boolean');
+ }
+
+ /**
+ * @return IntegerNodeDefinition<$this>
+ */
+ public function integerPrototype(): IntegerNodeDefinition
+ {
+ return $this->prototype('integer');
+ }
+
+ /**
+ * @return FloatNodeDefinition<$this>
+ */
+ public function floatPrototype(): FloatNodeDefinition
+ {
+ return $this->prototype('float');
+ }
+
+ /**
+ * @return self<$this>
+ */
+ public function arrayPrototype(): self
+ {
+ return $this->prototype('array');
+ }
+
+ /**
+ * @return EnumNodeDefinition<$this>
+ */
+ public function enumPrototype(): EnumNodeDefinition
+ {
+ return $this->prototype('enum');
+ }
+
+ /**
+ * Adds the default value if the node is not set in the configuration.
+ *
+ * This method is applicable to concrete nodes only (not to prototype nodes).
+ * If this function has been called and the node is not set during the finalization
+ * phase, it's default value will be derived from its children default values.
+ *
+ * @return $this
+ */
+ public function addDefaultsIfNotSet(): static
+ {
+ $this->addDefaults = true;
+
+ return $this;
+ }
+
+ /**
+ * Adds children with a default value when none are defined.
+ *
+ * This method is applicable to prototype nodes only.
+ *
+ * @param int|string|array|null $children The number of children|The child name|The children names to be added
+ *
+ * @return $this
+ */
+ public function addDefaultChildrenIfNoneSet(int|string|array|null $children = null): static
+ {
+ $this->addDefaultChildren = $children;
+
+ return $this;
+ }
+
+ /**
+ * Requires the node to have at least one element.
+ *
+ * This method is applicable to prototype nodes only.
+ *
+ * @return $this
+ */
+ public function requiresAtLeastOneElement(): static
+ {
+ $this->atLeastOne = true;
+
+ return $this;
+ }
+
+ /**
+ * Disallows adding news keys in a subsequent configuration.
+ *
+ * If used all keys have to be defined in the same configuration file.
+ *
+ * @return $this
+ */
+ public function disallowNewKeysInSubsequentConfigs(): static
+ {
+ $this->allowNewKeys = false;
+
+ return $this;
+ }
+
+ /**
+ * Sets a normalization rule for XML configurations.
+ *
+ * @param string $singular The key to remap
+ * @param string|null $plural The plural of the key for irregular plurals
+ *
+ * @return $this
+ */
+ public function fixXmlConfig(string $singular, ?string $plural = null): static
+ {
+ $this->normalization()->remap($singular, $plural);
+
+ return $this;
+ }
+
+ /**
+ * Sets the attribute which value is to be used as key.
+ *
+ * This is useful when you have an indexed array that should be an
+ * associative array. You can select an item from within the array
+ * to be the key of the particular item. For example, if "id" is the
+ * "key", then:
+ *
+ * [
+ * ['id' => 'my_name', 'foo' => 'bar'],
+ * ];
+ *
+ * becomes
+ *
+ * [
+ * 'my_name' => ['foo' => 'bar'],
+ * ];
+ *
+ * If you'd like "'id' => 'my_name'" to still be present in the resulting
+ * array, then you can set the second argument of this method to false.
+ *
+ * This method is applicable to prototype nodes only.
+ *
+ * @param string $name The name of the key
+ * @param bool $removeKeyItem Whether or not the key item should be removed
+ *
+ * @return $this
+ */
+ public function useAttributeAsKey(string $name, bool $removeKeyItem = true): static
+ {
+ $this->key = $name;
+ $this->removeKeyItem = $removeKeyItem;
+
+ return $this;
+ }
+
+ /**
+ * Sets whether the node can be unset.
+ *
+ * @return $this
+ */
+ public function canBeUnset(bool $allow = true): static
+ {
+ $this->merge()->allowUnset($allow);
+
+ return $this;
+ }
+
+ /**
+ * Adds an "enabled" boolean to enable the current section.
+ *
+ * By default, the section is disabled. If any configuration is specified then
+ * the node will be automatically enabled:
+ *
+ * enableableArrayNode: {enabled: true, ...} # The config is enabled & default values get overridden
+ * enableableArrayNode: ~ # The config is enabled & use the default values
+ * enableableArrayNode: true # The config is enabled & use the default values
+ * enableableArrayNode: {other: value, ...} # The config is enabled & default values get overridden
+ * enableableArrayNode: {enabled: false, ...} # The config is disabled
+ * enableableArrayNode: false # The config is disabled
+ *
+ * @param string|null $info A description of what happens when the node is enabled or disabled
+ *
+ * @return $this
+ */
+ public function canBeEnabled(/* ?string $info = null */): static
+ {
+ $disabledNode = $this
+ ->attribute('auto_enable', true)
+ ->addDefaultsIfNotSet()
+ ->treatFalseLike(['enabled' => false])
+ ->treatTrueLike(['enabled' => true])
+ ->treatNullLike(['enabled' => true])
+ ->beforeNormalization()
+ ->ifArray()
+ ->then(static function ($v) {
+ $v['enabled'] ??= true;
+
+ return $v;
+ })
+ ->end()
+ ->children()
+ ->booleanNode('enabled')
+ ->defaultFalse()
+ ;
+
+ $info = 1 <= \func_num_args() ? func_get_arg(0) : null;
+ if ($info) {
+ $disabledNode->info($info);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Adds an "enabled" boolean to enable the current section.
+ *
+ * By default, the section is enabled.
+ *
+ * @param string|null $info A description of what happens when the node is enabled or disabled
+ *
+ * @return $this
+ */
+ public function canBeDisabled(/* ?string $info = null */): static
+ {
+ $enabledNode = $this
+ ->attribute('auto_enable', true)
+ ->addDefaultsIfNotSet()
+ ->treatFalseLike(['enabled' => false])
+ ->treatTrueLike(['enabled' => true])
+ ->treatNullLike(['enabled' => true])
+ ->children()
+ ->booleanNode('enabled')
+ ->defaultTrue()
+ ;
+
+ $info = 1 <= \func_num_args() ? func_get_arg(0) : null;
+ if ($info) {
+ $enabledNode->info($info);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Disables the deep merging of the node.
+ *
+ * @return $this
+ */
+ public function performNoDeepMerging(): static
+ {
+ $this->performDeepMerging = false;
+
+ return $this;
+ }
+
+ /**
+ * Allows extra config keys to be specified under an array without
+ * throwing an exception.
+ *
+ * Those config values are ignored and removed from the resulting
+ * array. This should be used only in special cases where you want
+ * to send an entire configuration array through a special tree that
+ * processes only part of the array.
+ *
+ * @param bool $remove Whether to remove the extra keys
+ *
+ * @return $this
+ */
+ public function ignoreExtraKeys(bool $remove = true): static
+ {
+ $this->ignoreExtraKeys = true;
+ $this->removeExtraKeys = $remove;
+
+ return $this;
+ }
+
+ /**
+ * Sets whether to enable key normalization.
+ *
+ * @return $this
+ */
+ public function normalizeKeys(bool $bool): static
+ {
+ $this->normalizeKeys = $bool;
+
+ return $this;
+ }
+
+ public function append(NodeDefinition $node): static
+ {
+ $this->children[$node->name ?? ''] = $node->setParent($this);
+
+ return $this;
+ }
+
+ /**
+ * Returns a node builder to be used to add children and prototype.
+ *
+ * @return NodeBuilder
+ */
+ protected function getNodeBuilder(): NodeBuilder
+ {
+ $this->nodeBuilder ??= new NodeBuilder();
+
+ return $this->nodeBuilder->setParent($this);
+ }
+
+ protected function createNode(): NodeInterface
+ {
+ if (!isset($this->prototype)) {
+ $node = new ArrayNode($this->name, $this->parent, $this->pathSeparator);
+
+ $this->validateConcreteNode($node);
+
+ $node->setAddIfNotSet($this->addDefaults);
+
+ foreach ($this->children as $child) {
+ $child->parent = $node;
+ $node->addChild($child->getNode());
+ }
+ } else {
+ $node = new PrototypedArrayNode($this->name, $this->parent, $this->pathSeparator);
+
+ $this->validatePrototypeNode($node);
+
+ if (null !== $this->key) {
+ $node->setKeyAttribute($this->key, $this->removeKeyItem);
+ }
+
+ if (true === $this->atLeastOne || false === $this->allowEmptyValue) {
+ $node->setMinNumberOfElements(1);
+ }
+
+ if ($this->default) {
+ if (null === $this->defaultValue) {
+ $node->setNullAsDefault();
+ } elseif (!\is_array($this->defaultValue)) {
+ throw new \InvalidArgumentException(\sprintf('%s: the default value of an array node has to be an array or null.', $node->getPath()));
+ } else {
+ $node->setDefaultValue($this->defaultValue);
+ }
+ }
+
+ if (false !== $this->addDefaultChildren) {
+ $node->setAddChildrenIfNoneSet($this->addDefaultChildren);
+ if ($this->prototype instanceof self && !isset($this->prototype->prototype)) {
+ $this->prototype->addDefaultsIfNotSet();
+ }
+ }
+
+ $this->prototype->parent = $node;
+ $node->setPrototype($this->prototype->getNode());
+ }
+
+ $node->setAllowNewKeys($this->allowNewKeys);
+ $node->addEquivalentValue(null, $this->nullEquivalent);
+ $node->addEquivalentValue(true, $this->trueEquivalent);
+ $node->addEquivalentValue(false, $this->falseEquivalent);
+ $node->setPerformDeepMerging($this->performDeepMerging);
+ $node->setRequired($this->required);
+ $node->setIgnoreExtraKeys($this->ignoreExtraKeys, $this->removeExtraKeys);
+ $node->setNormalizeKeys($this->normalizeKeys);
+
+ if ($this->deprecation) {
+ $node->setDeprecated($this->deprecation['package'], $this->deprecation['version'], $this->deprecation['message']);
+ }
+
+ $normalizedTypes = $this->allowedTypes ?? [];
+
+ if (isset($this->normalization)) {
+ $normalizedTypes = $normalizedTypes ?: $this->normalization->declaredTypes;
+ $node->setNormalizationClosures($this->normalization->before);
+ $node->setXmlRemappings($this->normalization->remappings);
+ }
+
+ $normalizedTypes[] = ExprBuilder::TYPE_ARRAY;
+
+ foreach ([$this->trueEquivalent, $this->falseEquivalent] as $equivalent) {
+ if (\is_array($equivalent) && $equivalent) {
+ $normalizedTypes[] = ExprBuilder::TYPE_BOOL;
+ }
+ }
+
+ $node->setNormalizedTypes(array_values(array_unique($normalizedTypes)));
+
+ if (isset($this->merge)) {
+ $node->setAllowOverwrite($this->merge->allowOverwrite);
+ $node->setAllowFalse($this->merge->allowFalse);
+ }
+
+ if (isset($this->validation)) {
+ $node->setFinalValidationClosures($this->validation->rules);
+ }
+
+ return $node;
+ }
+
+ /**
+ * Validate the configuration of a concrete node.
+ *
+ * @throws InvalidDefinitionException
+ */
+ protected function validateConcreteNode(ArrayNode $node): void
+ {
+ $path = $node->getPath();
+
+ if (null !== $this->key) {
+ throw new InvalidDefinitionException(\sprintf('->useAttributeAsKey() is not applicable to concrete nodes at path "%s".', $path));
+ }
+
+ if (false === $this->allowEmptyValue) {
+ throw new InvalidDefinitionException(\sprintf('->cannotBeEmpty() is not applicable to concrete nodes at path "%s".', $path));
+ }
+
+ if (true === $this->atLeastOne) {
+ throw new InvalidDefinitionException(\sprintf('->requiresAtLeastOneElement() is not applicable to concrete nodes at path "%s".', $path));
+ }
+
+ if ($this->default) {
+ throw new InvalidDefinitionException(\sprintf('->defaultValue() is not applicable to concrete nodes at path "%s".', $path));
+ }
+
+ if (false !== $this->addDefaultChildren) {
+ throw new InvalidDefinitionException(\sprintf('->addDefaultChildrenIfNoneSet() is not applicable to concrete nodes at path "%s".', $path));
+ }
+ }
+
+ /**
+ * Validate the configuration of a prototype node.
+ *
+ * @throws InvalidDefinitionException
+ */
+ protected function validatePrototypeNode(PrototypedArrayNode $node): void
+ {
+ $path = $node->getPath();
+
+ if ($this->addDefaults) {
+ throw new InvalidDefinitionException(\sprintf('->addDefaultsIfNotSet() is not applicable to prototype nodes at path "%s".', $path));
+ }
+
+ if (false !== $this->addDefaultChildren) {
+ if ($this->default) {
+ throw new InvalidDefinitionException(\sprintf('A default value and default children might not be used together at path "%s".', $path));
+ }
+
+ if (null !== $this->key && (null === $this->addDefaultChildren || \is_int($this->addDefaultChildren) && $this->addDefaultChildren > 0)) {
+ throw new InvalidDefinitionException(\sprintf('->addDefaultChildrenIfNoneSet() should set default children names as ->useAttributeAsKey() is used at path "%s".', $path));
+ }
+
+ if (null === $this->key && (\is_string($this->addDefaultChildren) || \is_array($this->addDefaultChildren))) {
+ throw new InvalidDefinitionException(\sprintf('->addDefaultChildrenIfNoneSet() might not set default children names as ->useAttributeAsKey() is not used at path "%s".', $path));
+ }
+ }
+ }
+
+ /**
+ * @return NodeDefinition<$this>[]
+ */
+ public function getChildNodeDefinitions(): array
+ {
+ return $this->children;
+ }
+
+ /**
+ * Finds a node defined by the given $nodePath.
+ *
+ * @param string $nodePath The path of the node to find. e.g "doctrine.orm.mappings"
+ */
+ public function find(string $nodePath): NodeDefinition
+ {
+ $firstPathSegment = (false === $pathSeparatorPos = strpos($nodePath, $this->pathSeparator))
+ ? $nodePath
+ : substr($nodePath, 0, $pathSeparatorPos);
+
+ if (null === $node = ($this->children[$firstPathSegment] ?? null)) {
+ throw new \RuntimeException(\sprintf('Node with name "%s" does not exist in the current node "%s".', $firstPathSegment, $this->name));
+ }
+
+ if (false === $pathSeparatorPos) {
+ return $node;
+ }
+
+ return $node->find(substr($nodePath, $pathSeparatorPos + \strlen($this->pathSeparator)));
+ }
+}
diff --git a/symfony/config/Definition/Builder/BooleanNodeDefinition.php b/symfony/config/Definition/Builder/BooleanNodeDefinition.php
new file mode 100644
index 0000000000000000000000000000000000000000..db81b2c8526e72a1066042885bbcadf824d5c981
--- /dev/null
+++ b/symfony/config/Definition/Builder/BooleanNodeDefinition.php
@@ -0,0 +1,60 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Definition\Builder;
+
+use Symfony\Component\Config\Definition\BooleanNode;
+use Symfony\Component\Config\Definition\Exception\InvalidDefinitionException;
+
+/**
+ * This class provides a fluent interface for defining a node.
+ *
+ * @template TParent of NodeParentInterface|null
+ *
+ * @extends ScalarNodeDefinition
+ *
+ * @author Johannes M. Schmitt
+ */
+class BooleanNodeDefinition extends ScalarNodeDefinition
+{
+ /**
+ * @param TParent $parent
+ */
+ public function __construct(?string $name, ?NodeParentInterface $parent = null)
+ {
+ parent::__construct($name, $parent);
+
+ $this->nullEquivalent = true;
+ }
+
+ protected function instantiateNode(): BooleanNode
+ {
+ return new BooleanNode($this->name, $this->parent, $this->pathSeparator, null === $this->nullEquivalent);
+ }
+
+ /**
+ * @throws InvalidDefinitionException
+ */
+ public function cannotBeEmpty(): static
+ {
+ throw new InvalidDefinitionException('->cannotBeEmpty() is not applicable to BooleanNodeDefinition.');
+ }
+
+ /**
+ * @return $this
+ */
+ public function defaultValue(mixed $value): static
+ {
+ $this->nullEquivalent = null === $value ? null : true;
+
+ return parent::defaultValue($value);
+ }
+}
diff --git a/symfony/config/Definition/Builder/BuilderAwareInterface.php b/symfony/config/Definition/Builder/BuilderAwareInterface.php
new file mode 100644
index 0000000000000000000000000000000000000000..c3e10b703a1aee35ca728d7bd2c6640e2a1f6785
--- /dev/null
+++ b/symfony/config/Definition/Builder/BuilderAwareInterface.php
@@ -0,0 +1,27 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Definition\Builder;
+
+/**
+ * An interface that can be implemented by nodes which build other nodes.
+ *
+ * @author Roland Franssen
+ */
+interface BuilderAwareInterface
+{
+ /**
+ * Sets a custom children builder.
+ *
+ * @param NodeBuilder $builder
+ */
+ public function setBuilder(NodeBuilder $builder): void;
+}
diff --git a/symfony/config/Definition/Builder/EnumNodeDefinition.php b/symfony/config/Definition/Builder/EnumNodeDefinition.php
new file mode 100644
index 0000000000000000000000000000000000000000..59d0634d597765cd4fcace5e4da92fdc2df4380f
--- /dev/null
+++ b/symfony/config/Definition/Builder/EnumNodeDefinition.php
@@ -0,0 +1,75 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Definition\Builder;
+
+use Symfony\Component\Config\Definition\EnumNode;
+
+/**
+ * Enum Node Definition.
+ *
+ * @template TParent of NodeParentInterface|null
+ *
+ * @extends ScalarNodeDefinition
+ *
+ * @author Johannes M. Schmitt
+ */
+class EnumNodeDefinition extends ScalarNodeDefinition
+{
+ private array $values;
+ private string $enumFqcn;
+
+ /**
+ * @return $this
+ */
+ public function values(array $values): static
+ {
+ if (!$values) {
+ throw new \InvalidArgumentException('->values() must be called with at least one value.');
+ }
+
+ $this->values = $values;
+
+ return $this;
+ }
+
+ /**
+ * @param class-string<\UnitEnum> $enumFqcn
+ *
+ * @return $this
+ */
+ public function enumFqcn(string $enumFqcn): static
+ {
+ if (!enum_exists($enumFqcn)) {
+ throw new \InvalidArgumentException(\sprintf('The enum class "%s" does not exist.', $enumFqcn));
+ }
+
+ $this->enumFqcn = $enumFqcn;
+
+ return $this;
+ }
+
+ /**
+ * @throws \RuntimeException when no values or enumFqcn is set
+ */
+ protected function instantiateNode(): EnumNode
+ {
+ if (!isset($this->values) && !isset($this->enumFqcn)) {
+ throw new \RuntimeException('You must call either ->values() or ->enumFqcn() on enum nodes.');
+ }
+
+ if (isset($this->values) && isset($this->enumFqcn)) {
+ throw new \RuntimeException('You must call either ->values() or ->enumFqcn() on enum nodes but not both.');
+ }
+
+ return new EnumNode($this->name, $this->parent, $this->values ?? [], $this->pathSeparator, $this->enumFqcn ?? null);
+ }
+}
diff --git a/symfony/config/Definition/Builder/ExprBuilder.php b/symfony/config/Definition/Builder/ExprBuilder.php
new file mode 100644
index 0000000000000000000000000000000000000000..97d7d04c1728a7c588993594f239be043e351e87
--- /dev/null
+++ b/symfony/config/Definition/Builder/ExprBuilder.php
@@ -0,0 +1,277 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Definition\Builder;
+
+use Symfony\Component\Config\Definition\Exception\UnsetKeyException;
+
+/**
+ * This class builds an if expression.
+ *
+ * @template T of NodeDefinition
+ *
+ * @author Johannes M. Schmitt
+ * @author Christophe Coevoet
+ */
+class ExprBuilder
+{
+ public const TYPE_ANY = 'any';
+ public const TYPE_STRING = 'string';
+ public const TYPE_NULL = 'null';
+ public const TYPE_ARRAY = 'array';
+ public const TYPE_BOOL = 'bool';
+ public const TYPE_INT = 'int';
+ public const TYPE_BACKED_ENUM = 'backed-enum';
+
+ public string $allowedTypes;
+ public ?\Closure $ifPart = null;
+ public ?\Closure $thenPart = null;
+
+ /**
+ * @param T $node
+ */
+ public function __construct(
+ protected NodeDefinition $node,
+ ) {
+ }
+
+ /**
+ * Marks the expression as being always used.
+ *
+ * @return $this
+ */
+ public function always(?\Closure $then = null): static
+ {
+ $this->ifPart = static fn () => true;
+ $this->allowedTypes = self::TYPE_ANY;
+
+ if (null !== $then) {
+ $this->thenPart = $then;
+ }
+
+ return $this;
+ }
+
+ /**
+ * Sets a closure to use as tests.
+ *
+ * The default one tests if the value is true.
+ *
+ * @return $this
+ */
+ public function ifTrue(?\Closure $closure = null): static
+ {
+ $this->ifPart = $closure ?? static fn ($v) => true === $v;
+ $this->allowedTypes = $closure ? self::TYPE_ANY : self::TYPE_BOOL;
+
+ return $this;
+ }
+
+ /**
+ * Sets a closure to use as tests.
+ *
+ * The default one tests if the value is false.
+ *
+ * @return $this
+ */
+ public function ifFalse(?\Closure $closure = null): static
+ {
+ $this->ifPart = $closure ? static fn ($v) => !$closure($v) : static fn ($v) => false === $v;
+ $this->allowedTypes = $closure ? self::TYPE_ANY : self::TYPE_BOOL;
+
+ return $this;
+ }
+
+ /**
+ * Tests if the value is a string.
+ *
+ * @return $this
+ */
+ public function ifString(): static
+ {
+ $this->ifPart = \is_string(...);
+ $this->allowedTypes = self::TYPE_STRING;
+
+ return $this;
+ }
+
+ /**
+ * Tests if the value is null.
+ *
+ * @return $this
+ */
+ public function ifNull(): static
+ {
+ $this->ifPart = \is_null(...);
+ $this->allowedTypes = self::TYPE_NULL;
+
+ return $this;
+ }
+
+ /**
+ * Tests if the value is empty.
+ *
+ * @return $this
+ */
+ public function ifEmpty(): static
+ {
+ $this->ifPart = static fn ($v) => !$v;
+ $this->allowedTypes = self::TYPE_ANY;
+
+ return $this;
+ }
+
+ /**
+ * Tests if the value is an array.
+ *
+ * @return $this
+ */
+ public function ifArray(): static
+ {
+ $this->ifPart = \is_array(...);
+ $this->allowedTypes = self::TYPE_ARRAY;
+
+ return $this;
+ }
+
+ /**
+ * Tests if the value is in an array.
+ *
+ * @return $this
+ */
+ public function ifInArray(array $array): static
+ {
+ $this->ifPart = static fn ($v) => \in_array($v, $array, true);
+ $this->allowedTypes = self::TYPE_ANY;
+
+ return $this;
+ }
+
+ /**
+ * Tests if the value is not in an array.
+ *
+ * @return $this
+ */
+ public function ifNotInArray(array $array): static
+ {
+ $this->ifPart = static fn ($v) => !\in_array($v, $array, true);
+ $this->allowedTypes = self::TYPE_ANY;
+
+ return $this;
+ }
+
+ /**
+ * Transforms variables of any type into an array.
+ *
+ * @return $this
+ */
+ public function castToArray(): static
+ {
+ $this->ifPart = static fn ($v) => !\is_array($v);
+ $this->allowedTypes = self::TYPE_ANY;
+ $this->thenPart = static fn ($v) => [$v];
+
+ return $this;
+ }
+
+ /**
+ * Sets the closure to run if the test pass.
+ *
+ * @return $this
+ */
+ public function then(\Closure $closure): static
+ {
+ $this->thenPart = $closure;
+
+ return $this;
+ }
+
+ /**
+ * Sets a closure returning an empty array.
+ *
+ * @return $this
+ */
+ public function thenEmptyArray(): static
+ {
+ $this->thenPart = static fn () => [];
+
+ return $this;
+ }
+
+ /**
+ * Sets a closure marking the value as invalid at processing time.
+ *
+ * if you want to add the value of the node in your message just use a %s placeholder.
+ *
+ * @return $this
+ *
+ * @throws \InvalidArgumentException
+ */
+ public function thenInvalid(string $message): static
+ {
+ $this->thenPart = static fn ($v) => throw new \InvalidArgumentException(\sprintf($message, json_encode($v)));
+
+ return $this;
+ }
+
+ /**
+ * Sets a closure unsetting this key of the array at processing time.
+ *
+ * @return $this
+ *
+ * @throws UnsetKeyException
+ */
+ public function thenUnset(): static
+ {
+ $this->thenPart = static fn () => throw new UnsetKeyException('Unsetting key.');
+
+ return $this;
+ }
+
+ /**
+ * Returns the related node.
+ *
+ * @return T
+ *
+ * @throws \RuntimeException
+ */
+ public function end(): NodeDefinition
+ {
+ if (null === $this->ifPart) {
+ throw new \RuntimeException('You must specify an if part.');
+ }
+ if (null === $this->thenPart) {
+ throw new \RuntimeException('You must specify a then part.');
+ }
+
+ return $this->node;
+ }
+
+ /**
+ * Builds the expressions.
+ *
+ * @param (ExprBuilder|\Closure)[] $expressions
+ *
+ * @return \Closure[]
+ */
+ public static function buildExpressions(array $expressions): array
+ {
+ foreach ($expressions as $k => $expr) {
+ if ($expr instanceof self) {
+ $if = $expr->ifPart;
+ $then = $expr->thenPart;
+ $expressions[$k] = static fn ($v) => $if($v) ? $then($v) : $v;
+ }
+ }
+
+ return $expressions;
+ }
+}
diff --git a/symfony/config/Definition/Builder/FloatNodeDefinition.php b/symfony/config/Definition/Builder/FloatNodeDefinition.php
new file mode 100644
index 0000000000000000000000000000000000000000..7fffca787bfc128994c27f46cb1637b747203edd
--- /dev/null
+++ b/symfony/config/Definition/Builder/FloatNodeDefinition.php
@@ -0,0 +1,31 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Definition\Builder;
+
+use Symfony\Component\Config\Definition\FloatNode;
+
+/**
+ * This class provides a fluent interface for defining a float node.
+ *
+ * @template TParent of NodeParentInterface|null = null
+ *
+ * @extends NumericNodeDefinition
+ *
+ * @author Jeanmonod David
+ */
+class FloatNodeDefinition extends NumericNodeDefinition
+{
+ protected function instantiateNode(): FloatNode
+ {
+ return new FloatNode($this->name, $this->parent, $this->min, $this->max, $this->pathSeparator);
+ }
+}
diff --git a/symfony/config/Definition/Builder/IntegerNodeDefinition.php b/symfony/config/Definition/Builder/IntegerNodeDefinition.php
new file mode 100644
index 0000000000000000000000000000000000000000..da28d5a40a22060b4c46abb737c944a3aa0a31d8
--- /dev/null
+++ b/symfony/config/Definition/Builder/IntegerNodeDefinition.php
@@ -0,0 +1,31 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Definition\Builder;
+
+use Symfony\Component\Config\Definition\IntegerNode;
+
+/**
+ * This class provides a fluent interface for defining an integer node.
+ *
+ * @template TParent of NodeParentInterface|null = null
+ *
+ * @extends NumericNodeDefinition
+ *
+ * @author Jeanmonod David
+ */
+class IntegerNodeDefinition extends NumericNodeDefinition
+{
+ protected function instantiateNode(): IntegerNode
+ {
+ return new IntegerNode($this->name, $this->parent, $this->min, $this->max, $this->pathSeparator);
+ }
+}
diff --git a/symfony/config/Definition/Builder/MergeBuilder.php b/symfony/config/Definition/Builder/MergeBuilder.php
new file mode 100644
index 0000000000000000000000000000000000000000..0e26eae858d49ead1fab0fa80debca6a20df22a6
--- /dev/null
+++ b/symfony/config/Definition/Builder/MergeBuilder.php
@@ -0,0 +1,67 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Definition\Builder;
+
+/**
+ * This class builds merge conditions.
+ *
+ * @template T of NodeDefinition
+ *
+ * @author Johannes M. Schmitt
+ */
+class MergeBuilder
+{
+ public bool $allowFalse = false;
+ public bool $allowOverwrite = true;
+
+ /**
+ * @param T $node
+ */
+ public function __construct(
+ protected NodeDefinition $node,
+ ) {
+ }
+
+ /**
+ * Sets whether the node can be unset.
+ *
+ * @return $this
+ */
+ public function allowUnset(bool $allow = true): static
+ {
+ $this->allowFalse = $allow;
+
+ return $this;
+ }
+
+ /**
+ * Sets whether the node can be overwritten.
+ *
+ * @return $this
+ */
+ public function denyOverwrite(bool $deny = true): static
+ {
+ $this->allowOverwrite = !$deny;
+
+ return $this;
+ }
+
+ /**
+ * Returns the related node.
+ *
+ * @return T
+ */
+ public function end(): NodeDefinition
+ {
+ return $this->node;
+ }
+}
diff --git a/symfony/config/Definition/Builder/NodeBuilder.php b/symfony/config/Definition/Builder/NodeBuilder.php
new file mode 100644
index 0000000000000000000000000000000000000000..330df37c87a34f9eb254550a13c977a96868e560
--- /dev/null
+++ b/symfony/config/Definition/Builder/NodeBuilder.php
@@ -0,0 +1,263 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Definition\Builder;
+
+/**
+ * This class provides a fluent interface for building a node.
+ *
+ * @template TParent of (NodeDefinition&ParentNodeDefinitionInterface)|null = null
+ *
+ * @author Johannes M. Schmitt
+ */
+class NodeBuilder implements NodeParentInterface
+{
+ /**
+ * @var TParent
+ */
+ protected (NodeDefinition&ParentNodeDefinitionInterface)|null $parent = null;
+ /**
+ * @var array>
+ */
+ protected array $nodeMapping;
+
+ public function __construct()
+ {
+ // This list should be in sync with generics on method node() below and on TreeBuilder, ArrayNodeDefinition and DefinitionConfigurator
+ $this->nodeMapping = [
+ 'array' => ArrayNodeDefinition::class,
+ 'variable' => VariableNodeDefinition::class,
+ 'scalar' => ScalarNodeDefinition::class,
+ 'string' => StringNodeDefinition::class,
+ 'boolean' => BooleanNodeDefinition::class,
+ 'integer' => IntegerNodeDefinition::class,
+ 'float' => FloatNodeDefinition::class,
+ 'enum' => EnumNodeDefinition::class,
+ ];
+ }
+
+ /**
+ * Set the parent node.
+ *
+ * @template TNewParent of (NodeDefinition&ParentNodeDefinitionInterface)|null
+ *
+ * @psalm-this-out static
+ *
+ * @return $this
+ */
+ public function setParent((NodeDefinition&ParentNodeDefinitionInterface)|null $parent): static
+ {
+ $this->parent = $parent;
+
+ return $this;
+ }
+
+ /**
+ * Creates a child array node.
+ *
+ * @param string|null $singular The singular name of the node when $name is plural
+ *
+ * @return ArrayNodeDefinition<$this>
+ */
+ public function arrayNode(string $name/* , ?string $singular = null */): ArrayNodeDefinition
+ {
+ $singular = 1 < \func_num_args() ? func_get_arg(1) : null;
+ if (null !== $singular) {
+ if (!$this->parent instanceof ArrayNodeDefinition) {
+ throw new \LogicException('The parent node must be an ArrayNodeDefinition when setting the singular name.');
+ }
+ $this->parent->fixXmlConfig($singular, $name);
+ }
+
+ return $this->node($name, 'array');
+ }
+
+ /**
+ * Creates a child scalar node.
+ *
+ * @return ScalarNodeDefinition<$this>
+ */
+ public function scalarNode(string $name): ScalarNodeDefinition
+ {
+ return $this->node($name, 'scalar');
+ }
+
+ /**
+ * Creates a child Boolean node.
+ *
+ * @return BooleanNodeDefinition<$this>
+ */
+ public function booleanNode(string $name): BooleanNodeDefinition
+ {
+ return $this->node($name, 'boolean');
+ }
+
+ /**
+ * Creates a child integer node.
+ *
+ * @return IntegerNodeDefinition<$this>
+ */
+ public function integerNode(string $name): IntegerNodeDefinition
+ {
+ return $this->node($name, 'integer');
+ }
+
+ /**
+ * Creates a child float node.
+ *
+ * @return FloatNodeDefinition<$this>
+ */
+ public function floatNode(string $name): FloatNodeDefinition
+ {
+ return $this->node($name, 'float');
+ }
+
+ /**
+ * Creates a child EnumNode.
+ *
+ * @return EnumNodeDefinition<$this>
+ */
+ public function enumNode(string $name): EnumNodeDefinition
+ {
+ return $this->node($name, 'enum');
+ }
+
+ /**
+ * Creates a child variable node.
+ *
+ * @return VariableNodeDefinition<$this>
+ */
+ public function variableNode(string $name): VariableNodeDefinition
+ {
+ return $this->node($name, 'variable');
+ }
+
+ /**
+ * Creates a child string node.
+ *
+ * @return StringNodeDefinition<$this>
+ */
+ public function stringNode(string $name): StringNodeDefinition
+ {
+ return $this->node($name, 'string');
+ }
+
+ /**
+ * Returns the parent node.
+ *
+ * @return TParent
+ */
+ public function end(): (NodeDefinition&ParentNodeDefinitionInterface)|null
+ {
+ return $this->parent;
+ }
+
+ /**
+ * Creates a child node.
+ *
+ * @template T of 'array'|'variable'|'scalar'|'string'|'boolean'|'integer'|'float'|'enum'
+ *
+ * @return (
+ * T is 'array' ? ArrayNodeDefinition<$this>
+ * : (T is 'variable' ? VariableNodeDefinition<$this>
+ * : (T is 'scalar' ? ScalarNodeDefinition<$this>
+ * : (T is 'string' ? StringNodeDefinition<$this>
+ * : (T is 'boolean' ? BooleanNodeDefinition<$this>
+ * : (T is 'integer' ? IntegerNodeDefinition<$this>
+ * : (T is 'float' ? FloatNodeDefinition<$this>
+ * : (T is 'enum' ? EnumNodeDefinition<$this>
+ * : NodeDefinition<$this>)))))))
+ * )
+ *
+ * @throws \RuntimeException When the node type is not registered
+ * @throws \RuntimeException When the node class is not found
+ */
+ public function node(?string $name, string $type): NodeDefinition
+ {
+ $class = $this->getNodeClass($type);
+
+ $node = new $class($name);
+
+ $this->append($node);
+
+ return $node;
+ }
+
+ /**
+ * Appends a node definition.
+ *
+ * Usage:
+ *
+ * $node = new ArrayNodeDefinition('name')
+ * ->children()
+ * ->scalarNode('foo')->end()
+ * ->scalarNode('baz')->end()
+ * ->append($this->getBarNodeDefinition())
+ * ->end()
+ * ;
+ *
+ * @return $this
+ */
+ public function append(NodeDefinition $node): static
+ {
+ if ($node instanceof BuilderAwareInterface) {
+ $builder = clone $this;
+ $builder->setParent(null);
+ $node->setBuilder($builder);
+ }
+
+ if (null !== $this->parent) {
+ $this->parent->append($node);
+ // Make this builder the node parent to allow for a fluid interface
+ $node->setParent($this);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Adds or overrides a node Type.
+ *
+ * @param string $type The name of the type
+ * @param class-string $class The fully qualified name the node definition class
+ *
+ * @return $this
+ */
+ public function setNodeClass(string $type, string $class): static
+ {
+ $this->nodeMapping[strtolower($type)] = $class;
+
+ return $this;
+ }
+
+ /**
+ * Returns the class name of the node definition.
+ *
+ * @throws \RuntimeException When the node type is not registered
+ * @throws \RuntimeException When the node class is not found
+ */
+ protected function getNodeClass(string $type): string
+ {
+ $type = strtolower($type);
+
+ if (!isset($this->nodeMapping[$type])) {
+ throw new \RuntimeException(\sprintf('The node type "%s" is not registered.', $type));
+ }
+
+ $class = $this->nodeMapping[$type];
+
+ if (!class_exists($class)) {
+ throw new \RuntimeException(\sprintf('The node class "%s" does not exist.', $class));
+ }
+
+ return $class;
+ }
+}
diff --git a/symfony/config/Definition/Builder/NodeDefinition.php b/symfony/config/Definition/Builder/NodeDefinition.php
new file mode 100644
index 0000000000000000000000000000000000000000..52d85a110924ae6b82f00119644c7b4ccb836306
--- /dev/null
+++ b/symfony/config/Definition/Builder/NodeDefinition.php
@@ -0,0 +1,400 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Definition\Builder;
+
+use Composer\InstalledVersions;
+use Symfony\Component\Config\Definition\BaseNode;
+use Symfony\Component\Config\Definition\Exception\InvalidDefinitionException;
+use Symfony\Component\Config\Definition\NodeInterface;
+
+/**
+ * This class provides a fluent interface for defining a node.
+ *
+ * @template TParent of NodeParentInterface|null = null
+ *
+ * @author Johannes M. Schmitt
+ */
+abstract class NodeDefinition implements NodeParentInterface
+{
+ protected ?string $name = null;
+ /**
+ * @var NormalizationBuilder<$this>
+ */
+ protected NormalizationBuilder $normalization;
+ /**
+ * @var ValidationBuilder<$this>
+ */
+ protected ValidationBuilder $validation;
+ protected mixed $defaultValue;
+ protected bool $default = false;
+ protected bool $required = false;
+ protected array $deprecation = [];
+ /**
+ * @var MergeBuilder<$this>
+ */
+ protected MergeBuilder $merge;
+ protected bool $allowEmptyValue = true;
+ protected mixed $nullEquivalent = null;
+ protected mixed $trueEquivalent = true;
+ protected mixed $falseEquivalent = false;
+ protected string $pathSeparator = BaseNode::DEFAULT_PATH_SEPARATOR;
+ /**
+ * @var TParent|NodeInterface
+ */
+ protected NodeParentInterface|NodeInterface|null $parent;
+ protected array $attributes = [];
+
+ /**
+ * @param TParent $parent
+ */
+ public function __construct(?string $name, ?NodeParentInterface $parent = null)
+ {
+ $this->parent = $parent;
+ $this->name = $name;
+ }
+
+ /**
+ * Sets the parent node.
+ *
+ * @template TNewParent of NodeParentInterface
+ *
+ * @psalm-this-out static
+ *
+ * @return $this
+ */
+ public function setParent(NodeParentInterface $parent): static
+ {
+ $this->parent = $parent;
+
+ return $this;
+ }
+
+ /**
+ * Sets info message.
+ *
+ * @return $this
+ */
+ public function info(string $info): static
+ {
+ return $this->attribute('info', $info);
+ }
+
+ /**
+ * Sets example configuration.
+ *
+ * @return $this
+ */
+ public function example(string|array $example): static
+ {
+ return $this->attribute('example', $example);
+ }
+
+ /**
+ * Sets the documentation URI, as usually put in the "@see" tag of a doc block. This
+ * can either be a URL or a file path. You can use the placeholders {package},
+ * {version:major} and {version:minor} in the URI.
+ *
+ * @return $this
+ */
+ public function docUrl(string $uri, ?string $package = null): static
+ {
+ if ($package) {
+ preg_match('/^(\d+)\.(\d+)\.(\d+)/', InstalledVersions::getVersion($package) ?? '', $m);
+ }
+
+ return $this->attribute('docUrl', strtr($uri, [
+ '{package}' => $package ?? '',
+ '{version:major}' => $m[1] ?? '',
+ '{version:minor}' => $m[2] ?? '',
+ ]));
+ }
+
+ /**
+ * Sets an attribute on the node.
+ *
+ * @return $this
+ */
+ public function attribute(string $key, mixed $value): static
+ {
+ $this->attributes[$key] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Returns the parent node.
+ *
+ * @return TParent
+ */
+ public function end(): ?NodeParentInterface
+ {
+ return $this->parent;
+ }
+
+ /**
+ * Creates the node.
+ */
+ public function getNode(bool $forceRootNode = false): NodeInterface
+ {
+ if ($forceRootNode) {
+ $this->parent = null;
+ }
+
+ if (isset($this->normalization)) {
+ $allowedTypes = [];
+ foreach ($this->normalization->before as $expr) {
+ $allowedTypes[] = $expr->allowedTypes;
+ }
+ $allowedTypes = array_unique($allowedTypes);
+ $this->normalization->before = ExprBuilder::buildExpressions($this->normalization->before);
+ $this->normalization->declaredTypes = $allowedTypes;
+ }
+
+ if (isset($this->validation)) {
+ $this->validation->rules = ExprBuilder::buildExpressions($this->validation->rules);
+ }
+
+ $node = $this->createNode();
+ if ($node instanceof BaseNode) {
+ $node->setAttributes($this->attributes);
+ }
+
+ return $node;
+ }
+
+ /**
+ * Sets the default value.
+ *
+ * @return $this
+ */
+ public function defaultValue(mixed $value): static
+ {
+ if ($this->required) {
+ // throw new InvalidDefinitionException(sprintf('The node "%s" cannot be required and have a default value.', $this->name));
+ trigger_deprecation('symfony/config', '7.4', 'Setting a default value to a required node is deprecated. Remove the default value from the node "%s" or make it optional.', $this->name);
+ }
+
+ $this->default = true;
+ $this->defaultValue = $value;
+
+ return $this;
+ }
+
+ /**
+ * Sets the node as required.
+ *
+ * @return $this
+ */
+ public function isRequired(): static
+ {
+ if ($this->default) {
+ // throw new InvalidDefinitionException(sprintf('The node "%s" cannot be required and have a default value.', $this->name));
+ trigger_deprecation('symfony/config', '7.4', 'Flagging a node with a default value as required is deprecated. Remove the default from node "%s" or make it optional.', $this->name);
+ }
+
+ $this->required = true;
+
+ return $this;
+ }
+
+ /**
+ * Sets the node as deprecated.
+ *
+ * @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 deprecation message to use
+ *
+ * You can use %node% and %path% placeholders in your message to display,
+ * respectively, the node name and its complete path
+ *
+ * @return $this
+ */
+ public function setDeprecated(string $package, string $version, string $message = 'The child node "%node%" at path "%path%" is deprecated.'): static
+ {
+ $this->deprecation = [
+ 'package' => $package,
+ 'version' => $version,
+ 'message' => $message,
+ ];
+
+ return $this;
+ }
+
+ /**
+ * Sets the equivalent value used when the node contains null.
+ *
+ * @return $this
+ */
+ public function treatNullLike(mixed $value): static
+ {
+ $this->nullEquivalent = $value;
+
+ return $this;
+ }
+
+ /**
+ * Sets the equivalent value used when the node contains true.
+ *
+ * @return $this
+ */
+ public function treatTrueLike(mixed $value): static
+ {
+ $this->trueEquivalent = $value;
+
+ return $this;
+ }
+
+ /**
+ * Sets the equivalent value used when the node contains false.
+ *
+ * @return $this
+ */
+ public function treatFalseLike(mixed $value): static
+ {
+ $this->falseEquivalent = $value;
+
+ return $this;
+ }
+
+ /**
+ * Sets null as the default value.
+ *
+ * @return $this
+ */
+ public function defaultNull(): static
+ {
+ return $this->defaultValue(null);
+ }
+
+ /**
+ * Sets true as the default value.
+ *
+ * @return $this
+ */
+ public function defaultTrue(): static
+ {
+ return $this->defaultValue(true);
+ }
+
+ /**
+ * Sets false as the default value.
+ *
+ * @return $this
+ */
+ public function defaultFalse(): static
+ {
+ return $this->defaultValue(false);
+ }
+
+ /**
+ * Sets an expression to run before the normalization.
+ *
+ * @return ExprBuilder<$this>
+ */
+ public function beforeNormalization(): ExprBuilder
+ {
+ return $this->normalization()->before();
+ }
+
+ /**
+ * Denies the node value being empty.
+ *
+ * @return $this
+ */
+ public function cannotBeEmpty(): static
+ {
+ $this->allowEmptyValue = false;
+
+ return $this;
+ }
+
+ /**
+ * Sets an expression to run for the validation.
+ *
+ * The expression receives the value of the node and must return it. It can
+ * modify it.
+ * An exception should be thrown when the node is not valid.
+ *
+ * @return ExprBuilder<$this>
+ */
+ public function validate(): ExprBuilder
+ {
+ return $this->validation()->rule();
+ }
+
+ /**
+ * Sets whether the node can be overwritten.
+ *
+ * @return $this
+ */
+ public function cannotBeOverwritten(bool $deny = true): static
+ {
+ $this->merge()->denyOverwrite($deny);
+
+ return $this;
+ }
+
+ /**
+ * Gets the builder for validation rules.
+ *
+ * @return ValidationBuilder<$this>
+ */
+ protected function validation(): ValidationBuilder
+ {
+ return $this->validation ??= new ValidationBuilder($this);
+ }
+
+ /**
+ * Gets the builder for merging rules.
+ *
+ * @return MergeBuilder<$this>
+ */
+ protected function merge(): MergeBuilder
+ {
+ return $this->merge ??= new MergeBuilder($this);
+ }
+
+ /**
+ * Gets the builder for normalization rules.
+ *
+ * @return NormalizationBuilder<$this>
+ */
+ protected function normalization(): NormalizationBuilder
+ {
+ return $this->normalization ??= new NormalizationBuilder($this);
+ }
+
+ /**
+ * Instantiate and configure the node according to this definition.
+ *
+ * @throws InvalidDefinitionException When the definition is invalid
+ */
+ abstract protected function createNode(): NodeInterface;
+
+ /**
+ * Set PathSeparator to use.
+ *
+ * @return $this
+ */
+ public function setPathSeparator(string $separator): static
+ {
+ if ($this instanceof ParentNodeDefinitionInterface) {
+ foreach ($this->getChildNodeDefinitions() as $child) {
+ $child->setPathSeparator($separator);
+ }
+ }
+
+ $this->pathSeparator = $separator;
+
+ return $this;
+ }
+}
diff --git a/symfony/config/Definition/Builder/NodeParentInterface.php b/symfony/config/Definition/Builder/NodeParentInterface.php
new file mode 100644
index 0000000000000000000000000000000000000000..305e993167d351f70b761ab03f2026aafda29914
--- /dev/null
+++ b/symfony/config/Definition/Builder/NodeParentInterface.php
@@ -0,0 +1,21 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Definition\Builder;
+
+/**
+ * An interface that must be implemented by all node parents.
+ *
+ * @author Victor Berchet
+ */
+interface NodeParentInterface
+{
+}
diff --git a/symfony/config/Definition/Builder/NormalizationBuilder.php b/symfony/config/Definition/Builder/NormalizationBuilder.php
new file mode 100644
index 0000000000000000000000000000000000000000..75b7d3d575891c3b56344766e4f9f9f45b077ebf
--- /dev/null
+++ b/symfony/config/Definition/Builder/NormalizationBuilder.php
@@ -0,0 +1,68 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Definition\Builder;
+
+/**
+ * This class builds normalization conditions.
+ *
+ * @template T of NodeDefinition
+ *
+ * @author Johannes M. Schmitt
+ */
+class NormalizationBuilder
+{
+ /**
+ * @var (ExprBuilder|\Closure)[]
+ */
+ public array $before = [];
+ public array $declaredTypes = [];
+ public array $remappings = [];
+
+ /**
+ * @param T $node
+ */
+ public function __construct(
+ protected NodeDefinition $node,
+ ) {
+ }
+
+ /**
+ * Registers a key to remap to its plural form.
+ *
+ * @param string $key The key to remap
+ * @param string|null $plural The plural of the key in case of irregular plural
+ *
+ * @return $this
+ */
+ public function remap(string $key, ?string $plural = null): static
+ {
+ $this->remappings[] = [$key, null === $plural ? $key.'s' : $plural];
+
+ return $this;
+ }
+
+ /**
+ * Registers a closure to run before the normalization or an expression builder to build it if null is provided.
+ *
+ * @return ($closure is \Closure ? $this : ExprBuilder)
+ */
+ public function before(?\Closure $closure = null): ExprBuilder|static
+ {
+ if ($closure) {
+ $this->before[] = $closure;
+
+ return $this;
+ }
+
+ return $this->before[] = new ExprBuilder($this->node);
+ }
+}
diff --git a/symfony/config/Definition/Builder/NumericNodeDefinition.php b/symfony/config/Definition/Builder/NumericNodeDefinition.php
new file mode 100644
index 0000000000000000000000000000000000000000..6a8f5b966ee1d780eac492c7d01156e53c3b400c
--- /dev/null
+++ b/symfony/config/Definition/Builder/NumericNodeDefinition.php
@@ -0,0 +1,71 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Definition\Builder;
+
+use Symfony\Component\Config\Definition\Exception\InvalidDefinitionException;
+
+/**
+ * Abstract class that contains common code of integer and float node definitions.
+ *
+ * @template TParent of NodeParentInterface|null = null
+ *
+ * @extends ScalarNodeDefinition
+ *
+ * @author David Jeanmonod
+ */
+abstract class NumericNodeDefinition extends ScalarNodeDefinition
+{
+ protected int|float|null $min = null;
+ protected int|float|null $max = null;
+
+ /**
+ * Ensures that the value is smaller than the given reference.
+ *
+ * @return $this
+ *
+ * @throws \InvalidArgumentException when the constraint is inconsistent
+ */
+ public function max(int|float $max): static
+ {
+ if (isset($this->min) && $this->min > $max) {
+ throw new \InvalidArgumentException(\sprintf('You cannot define a max(%s) as you already have a min(%s).', $max, $this->min));
+ }
+ $this->max = $max;
+
+ return $this;
+ }
+
+ /**
+ * Ensures that the value is bigger than the given reference.
+ *
+ * @return $this
+ *
+ * @throws \InvalidArgumentException when the constraint is inconsistent
+ */
+ public function min(int|float $min): static
+ {
+ if (isset($this->max) && $this->max < $min) {
+ throw new \InvalidArgumentException(\sprintf('You cannot define a min(%s) as you already have a max(%s).', $min, $this->max));
+ }
+ $this->min = $min;
+
+ return $this;
+ }
+
+ /**
+ * @throws InvalidDefinitionException
+ */
+ public function cannotBeEmpty(): static
+ {
+ throw new InvalidDefinitionException('->cannotBeEmpty() is not applicable to NumericNodeDefinition.');
+ }
+}
diff --git a/symfony/config/Definition/Builder/ParentNodeDefinitionInterface.php b/symfony/config/Definition/Builder/ParentNodeDefinitionInterface.php
new file mode 100644
index 0000000000000000000000000000000000000000..6afea5174705a6b04bdda597101fd95a0fd0e61d
--- /dev/null
+++ b/symfony/config/Definition/Builder/ParentNodeDefinitionInterface.php
@@ -0,0 +1,51 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Definition\Builder;
+
+/**
+ * An interface that must be implemented by nodes which can have children.
+ *
+ * @author Victor Berchet
+ */
+interface ParentNodeDefinitionInterface extends BuilderAwareInterface
+{
+ /**
+ * Returns a builder to add children nodes.
+ *
+ * @return NodeBuilder
+ */
+ public function children(): NodeBuilder;
+
+ /**
+ * Appends a node definition.
+ *
+ * Usage:
+ *
+ * $node = $parentNode
+ * ->children()
+ * ->scalarNode('foo')->end()
+ * ->scalarNode('baz')->end()
+ * ->append($this->getBarNodeDefinition())
+ * ->end()
+ * ;
+ *
+ * @return $this
+ */
+ public function append(NodeDefinition $node): static;
+
+ /**
+ * Gets the child node definitions.
+ *
+ * @return NodeDefinition[]
+ */
+ public function getChildNodeDefinitions(): array;
+}
diff --git a/symfony/config/Definition/Builder/ScalarNodeDefinition.php b/symfony/config/Definition/Builder/ScalarNodeDefinition.php
new file mode 100644
index 0000000000000000000000000000000000000000..6409aa69c544546f731577da655650f4d402e22a
--- /dev/null
+++ b/symfony/config/Definition/Builder/ScalarNodeDefinition.php
@@ -0,0 +1,31 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Definition\Builder;
+
+use Symfony\Component\Config\Definition\ScalarNode;
+
+/**
+ * This class provides a fluent interface for defining a node.
+ *
+ * @template TParent of NodeParentInterface|null = null
+ *
+ * @extends VariableNodeDefinition
+ *
+ * @author Johannes M. Schmitt
+ */
+class ScalarNodeDefinition extends VariableNodeDefinition
+{
+ protected function instantiateNode(): ScalarNode
+ {
+ return new ScalarNode($this->name, $this->parent, $this->pathSeparator);
+ }
+}
diff --git a/symfony/config/Definition/Builder/StringNodeDefinition.php b/symfony/config/Definition/Builder/StringNodeDefinition.php
new file mode 100644
index 0000000000000000000000000000000000000000..e14f352adda2584180c6f5688e83c0fce5c99ee6
--- /dev/null
+++ b/symfony/config/Definition/Builder/StringNodeDefinition.php
@@ -0,0 +1,41 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Definition\Builder;
+
+use Symfony\Component\Config\Definition\StringNode;
+
+/**
+ * This class provides a fluent interface for defining a node.
+ *
+ * @template TParent of NodeParentInterface|null = null
+ *
+ * @extends ScalarNodeDefinition
+ *
+ * @author Raffaele Carelle
+ */
+class StringNodeDefinition extends ScalarNodeDefinition
+{
+ /**
+ * @param TParent $parent
+ */
+ public function __construct(?string $name, ?NodeParentInterface $parent = null)
+ {
+ parent::__construct($name, $parent);
+
+ $this->nullEquivalent = '';
+ }
+
+ protected function instantiateNode(): StringNode
+ {
+ return new StringNode($this->name, $this->parent, $this->pathSeparator);
+ }
+}
diff --git a/symfony/config/Definition/Builder/TreeBuilder.php b/symfony/config/Definition/Builder/TreeBuilder.php
new file mode 100644
index 0000000000000000000000000000000000000000..c4f3173637999778bda81eb39f4c1e07ac624d13
--- /dev/null
+++ b/symfony/config/Definition/Builder/TreeBuilder.php
@@ -0,0 +1,70 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Definition\Builder;
+
+use Symfony\Component\Config\Definition\NodeInterface;
+
+/**
+ * This is the entry class for building a config tree.
+ *
+ * @template T of 'array'|'variable'|'scalar'|'string'|'boolean'|'integer'|'float'|'enum' = 'array'
+ *
+ * @author Johannes M. Schmitt
+ */
+class TreeBuilder implements NodeParentInterface
+{
+ protected ?NodeInterface $tree = null;
+ /**
+ * @var NodeDefinition<$this>|null
+ */
+ protected ?NodeDefinition $root = null;
+
+ /**
+ * @param T $type
+ */
+ public function __construct(string $name, string $type = 'array', ?NodeBuilder $builder = null)
+ {
+ $builder ??= new NodeBuilder();
+ $this->root = $builder->node($name, $type)->setParent($this);
+ }
+
+ /**
+ * @return (
+ * T is 'array' ? ArrayNodeDefinition<$this>
+ * : (T is 'variable' ? VariableNodeDefinition<$this>
+ * : (T is 'scalar' ? ScalarNodeDefinition<$this>
+ * : (T is 'string' ? StringNodeDefinition<$this>
+ * : (T is 'boolean' ? BooleanNodeDefinition<$this>
+ * : (T is 'integer' ? IntegerNodeDefinition<$this>
+ * : (T is 'float' ? FloatNodeDefinition<$this>
+ * : (T is 'enum' ? EnumNodeDefinition<$this>
+ * : NodeDefinition<$this>)))))))
+ * )
+ */
+ public function getRootNode(): NodeDefinition
+ {
+ return $this->root;
+ }
+
+ public function buildTree(): NodeInterface
+ {
+ return $this->tree ??= $this->root->getNode(true);
+ }
+
+ public function setPathSeparator(string $separator): void
+ {
+ // unset last built as changing path separator changes all nodes
+ $this->tree = null;
+
+ $this->root->setPathSeparator($separator);
+ }
+}
diff --git a/symfony/config/Definition/Builder/ValidationBuilder.php b/symfony/config/Definition/Builder/ValidationBuilder.php
new file mode 100644
index 0000000000000000000000000000000000000000..4d3efc7ddf224773c02a2fd1203bbf3133705b37
--- /dev/null
+++ b/symfony/config/Definition/Builder/ValidationBuilder.php
@@ -0,0 +1,51 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Definition\Builder;
+
+/**
+ * This class builds validation conditions.
+ *
+ * @template T of NodeDefinition
+ *
+ * @author Christophe Coevoet
+ */
+class ValidationBuilder
+{
+ /**
+ * @var (ExprBuilder|\Closure)[]
+ */
+ public array $rules = [];
+
+ /**
+ * @param T $node
+ */
+ public function __construct(
+ protected NodeDefinition $node,
+ ) {
+ }
+
+ /**
+ * Registers a closure to run as normalization or an expression builder to build it if null is provided.
+ *
+ * @return ($closure is \Closure ? $this : ExprBuilder)
+ */
+ public function rule(?\Closure $closure = null): ExprBuilder|static
+ {
+ if ($closure) {
+ $this->rules[] = $closure;
+
+ return $this;
+ }
+
+ return $this->rules[] = new ExprBuilder($this->node);
+ }
+}
diff --git a/symfony/config/Definition/Builder/VariableNodeDefinition.php b/symfony/config/Definition/Builder/VariableNodeDefinition.php
new file mode 100644
index 0000000000000000000000000000000000000000..6e6977f6d273b368fc06130daa3d2ecd82609e89
--- /dev/null
+++ b/symfony/config/Definition/Builder/VariableNodeDefinition.php
@@ -0,0 +1,65 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Definition\Builder;
+
+use Symfony\Component\Config\Definition\NodeInterface;
+use Symfony\Component\Config\Definition\VariableNode;
+
+/**
+ * This class provides a fluent interface for defining a node.
+ *
+ * @template TParent of NodeParentInterface|null = null
+ *
+ * @extends NodeDefinition
+ *
+ * @author Johannes M. Schmitt
+ */
+class VariableNodeDefinition extends NodeDefinition
+{
+ protected function instantiateNode(): VariableNode
+ {
+ return new VariableNode($this->name, $this->parent, $this->pathSeparator);
+ }
+
+ protected function createNode(): NodeInterface
+ {
+ $node = $this->instantiateNode();
+
+ if (isset($this->normalization)) {
+ $node->setNormalizationClosures($this->normalization->before);
+ }
+
+ if (isset($this->merge)) {
+ $node->setAllowOverwrite($this->merge->allowOverwrite);
+ }
+
+ if (true === $this->default) {
+ $node->setDefaultValue($this->defaultValue);
+ }
+
+ $node->setAllowEmptyValue($this->allowEmptyValue);
+ $node->addEquivalentValue(null, $this->nullEquivalent);
+ $node->addEquivalentValue(true, $this->trueEquivalent);
+ $node->addEquivalentValue(false, $this->falseEquivalent);
+ $node->setRequired($this->required);
+
+ if ($this->deprecation) {
+ $node->setDeprecated($this->deprecation['package'], $this->deprecation['version'], $this->deprecation['message']);
+ }
+
+ if (isset($this->validation)) {
+ $node->setFinalValidationClosures($this->validation->rules);
+ }
+
+ return $node;
+ }
+}
diff --git a/symfony/config/Definition/ConfigurableInterface.php b/symfony/config/Definition/ConfigurableInterface.php
new file mode 100644
index 0000000000000000000000000000000000000000..cd4646160ab8edfc6f206981ec0662be5a4652d6
--- /dev/null
+++ b/symfony/config/Definition/ConfigurableInterface.php
@@ -0,0 +1,25 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Definition;
+
+use Symfony\Component\Config\Definition\Configurator\DefinitionConfigurator;
+
+/**
+ * @author Yonel Ceruto
+ */
+interface ConfigurableInterface
+{
+ /**
+ * Generates the configuration tree builder.
+ */
+ public function configure(DefinitionConfigurator $definition): void;
+}
diff --git a/symfony/config/Definition/Configuration.php b/symfony/config/Definition/Configuration.php
new file mode 100644
index 0000000000000000000000000000000000000000..c84e9bcca5a67cfa3e2606403a4ddc6cd7a0a4ea
--- /dev/null
+++ b/symfony/config/Definition/Configuration.php
@@ -0,0 +1,48 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Definition;
+
+use Symfony\Component\Config\Definition\Builder\TreeBuilder;
+use Symfony\Component\Config\Definition\Configurator\DefinitionConfigurator;
+use Symfony\Component\Config\Definition\Loader\DefinitionFileLoader;
+use Symfony\Component\Config\FileLocator;
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+
+/**
+ * @author Yonel Ceruto
+ *
+ * @final
+ */
+class Configuration implements ConfigurationInterface
+{
+ public function __construct(
+ private ConfigurableInterface $subject,
+ private ?ContainerBuilder $container,
+ private string $alias,
+ ) {
+ }
+
+ /**
+ * @return TreeBuilder<'array'>
+ */
+ public function getConfigTreeBuilder(): TreeBuilder
+ {
+ $treeBuilder = new TreeBuilder($this->alias, 'array');
+ $file = (new \ReflectionObject($this->subject))->getFileName();
+ $loader = new DefinitionFileLoader($treeBuilder, new FileLocator(\dirname($file)), $this->container);
+ $configurator = new DefinitionConfigurator($treeBuilder, $loader, $file, $file);
+
+ $this->subject->configure($configurator);
+
+ return $treeBuilder;
+ }
+}
diff --git a/symfony/config/Definition/ConfigurationInterface.php b/symfony/config/Definition/ConfigurationInterface.php
new file mode 100644
index 0000000000000000000000000000000000000000..01e2fb862ebcb44e5bf3fcffbef12d29da6381d0
--- /dev/null
+++ b/symfony/config/Definition/ConfigurationInterface.php
@@ -0,0 +1,29 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Definition;
+
+use Symfony\Component\Config\Definition\Builder\TreeBuilder;
+
+/**
+ * Configuration interface.
+ *
+ * @author Victor Berchet
+ */
+interface ConfigurationInterface
+{
+ /**
+ * Generates the configuration tree builder.
+ *
+ * @return TreeBuilder<'array'>
+ */
+ public function getConfigTreeBuilder(): TreeBuilder;
+}
diff --git a/symfony/config/Definition/Configurator/DefinitionConfigurator.php b/symfony/config/Definition/Configurator/DefinitionConfigurator.php
new file mode 100644
index 0000000000000000000000000000000000000000..4878b076d78f2b41b026157a38c0dba88c2293ed
--- /dev/null
+++ b/symfony/config/Definition/Configurator/DefinitionConfigurator.php
@@ -0,0 +1,72 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Definition\Configurator;
+
+use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
+use Symfony\Component\Config\Definition\Builder\BooleanNodeDefinition;
+use Symfony\Component\Config\Definition\Builder\EnumNodeDefinition;
+use Symfony\Component\Config\Definition\Builder\FloatNodeDefinition;
+use Symfony\Component\Config\Definition\Builder\IntegerNodeDefinition;
+use Symfony\Component\Config\Definition\Builder\NodeDefinition;
+use Symfony\Component\Config\Definition\Builder\ScalarNodeDefinition;
+use Symfony\Component\Config\Definition\Builder\StringNodeDefinition;
+use Symfony\Component\Config\Definition\Builder\TreeBuilder;
+use Symfony\Component\Config\Definition\Builder\VariableNodeDefinition;
+use Symfony\Component\Config\Definition\Loader\DefinitionFileLoader;
+
+/**
+ * @template T of 'array'|'variable'|'scalar'|'string'|'boolean'|'integer'|'float'|'enum' = 'array'
+ *
+ * @author Yonel Ceruto
+ */
+class DefinitionConfigurator
+{
+ /**
+ * @param TreeBuilder $treeBuilder
+ */
+ public function __construct(
+ private TreeBuilder $treeBuilder,
+ private DefinitionFileLoader $loader,
+ private string $path,
+ private string $file,
+ ) {
+ }
+
+ public function import(string $resource, ?string $type = null, bool $ignoreErrors = false): void
+ {
+ $this->loader->setCurrentDir(\dirname($this->path));
+ $this->loader->import($resource, $type, $ignoreErrors, $this->file);
+ }
+
+ /**
+ * @return (
+ * T is 'array' ? ArrayNodeDefinition>
+ * : (T is 'variable' ? VariableNodeDefinition>
+ * : (T is 'scalar' ? ScalarNodeDefinition>
+ * : (T is 'string' ? StringNodeDefinition>
+ * : (T is 'boolean' ? BooleanNodeDefinition>
+ * : (T is 'integer' ? IntegerNodeDefinition>
+ * : (T is 'float' ? FloatNodeDefinition>
+ * : (T is 'enum' ? EnumNodeDefinition>
+ * : NodeDefinition>)))))))
+ * )
+ */
+ public function rootNode(): NodeDefinition
+ {
+ return $this->treeBuilder->getRootNode();
+ }
+
+ public function setPathSeparator(string $separator): void
+ {
+ $this->treeBuilder->setPathSeparator($separator);
+ }
+}
diff --git a/symfony/config/Definition/Dumper/XmlReferenceDumper.php b/symfony/config/Definition/Dumper/XmlReferenceDumper.php
new file mode 100644
index 0000000000000000000000000000000000000000..dcfdb9bc800551af3f48d46f239ff1afae70f982
--- /dev/null
+++ b/symfony/config/Definition/Dumper/XmlReferenceDumper.php
@@ -0,0 +1,292 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Definition\Dumper;
+
+use Symfony\Component\Config\Definition\ArrayNode;
+use Symfony\Component\Config\Definition\BaseNode;
+use Symfony\Component\Config\Definition\BooleanNode;
+use Symfony\Component\Config\Definition\ConfigurationInterface;
+use Symfony\Component\Config\Definition\EnumNode;
+use Symfony\Component\Config\Definition\FloatNode;
+use Symfony\Component\Config\Definition\IntegerNode;
+use Symfony\Component\Config\Definition\NodeInterface;
+use Symfony\Component\Config\Definition\PrototypedArrayNode;
+use Symfony\Component\Config\Definition\ScalarNode;
+
+/**
+ * Dumps an XML reference configuration for the given configuration/node instance.
+ *
+ * @author Wouter J
+ */
+class XmlReferenceDumper
+{
+ private ?string $reference = null;
+
+ public function dump(ConfigurationInterface $configuration, ?string $namespace = null): string
+ {
+ return $this->dumpNode($configuration->getConfigTreeBuilder()->buildTree(), $namespace);
+ }
+
+ public function dumpNode(NodeInterface $node, ?string $namespace = null): string
+ {
+ $this->reference = '';
+ $this->writeNode($node, 0, true, $namespace);
+ $ref = $this->reference;
+ $this->reference = null;
+
+ return $ref;
+ }
+
+ private function writeNode(NodeInterface $node, int $depth = 0, bool $root = false, ?string $namespace = null): void
+ {
+ $rootName = ($root ? 'config' : $node->getName());
+ $rootNamespace = ($namespace ?: ($root ? 'http://example.org/schema/dic/'.$node->getName() : null));
+
+ // xml remapping
+ if ($node->getParent()) {
+ $remapping = array_filter($node->getParent()->getXmlRemappings(), fn (array $mapping) => $rootName === $mapping[1]);
+
+ if (\count($remapping)) {
+ [$singular] = current($remapping);
+ $rootName = $singular;
+ }
+ }
+ $rootName = str_replace('_', '-', $rootName);
+
+ $rootAttributes = [];
+ $rootAttributeComments = [];
+ $rootChildren = [];
+ $rootComments = [];
+
+ if ($node instanceof ArrayNode) {
+ $children = $node->getChildren();
+
+ // comments about the root node
+ if ($rootInfo = $node->getInfo()) {
+ $rootComments[] = $rootInfo;
+ }
+
+ if ($rootNamespace) {
+ $rootComments[] = 'Namespace: '.$rootNamespace;
+ }
+
+ // render prototyped nodes
+ if ($node instanceof PrototypedArrayNode) {
+ $prototype = $node->getPrototype();
+
+ $info = 'prototype';
+ if (null !== $prototype->getInfo()) {
+ $info .= ': '.$prototype->getInfo();
+ }
+ array_unshift($rootComments, $info);
+
+ if ($key = $node->getKeyAttribute()) {
+ $rootAttributes[$key] = str_replace('-', ' ', $rootName).' '.$key;
+ }
+
+ if ($prototype instanceof PrototypedArrayNode) {
+ $prototype->setName($key ?? '');
+ $children = [$key => $prototype];
+ } elseif ($prototype instanceof ArrayNode) {
+ $children = $prototype->getChildren();
+ } else {
+ if ($prototype->hasDefaultValue()) {
+ $prototypeValue = $prototype->getDefaultValue();
+ } else {
+ $prototypeValue = match ($prototype::class) {
+ ScalarNode::class => 'scalar value',
+ FloatNode::class,
+ IntegerNode::class => 'numeric value',
+ BooleanNode::class => 'true|false',
+ EnumNode::class => $prototype->getPermissibleValues('|'),
+ default => 'value',
+ };
+ }
+ }
+ }
+
+ // get attributes and elements
+ foreach ($children as $child) {
+ if ($child instanceof ArrayNode) {
+ // get elements
+ $rootChildren[] = $child;
+
+ continue;
+ }
+
+ // get attributes
+
+ // metadata
+ $name = str_replace('_', '-', $child->getName());
+ $value = '%%%%not_defined%%%%'; // use a string which isn't used in the normal world
+
+ // comments
+ $comments = [];
+ if ($child instanceof BaseNode && $info = $child->getInfo()) {
+ $comments[] = $info;
+ }
+
+ if ($child instanceof BaseNode && $example = $child->getExample()) {
+ $comments[] = 'Example: '.(\is_array($example) ? implode(', ', $example) : $example);
+ }
+
+ if ($child->isRequired()) {
+ $comments[] = 'Required';
+ }
+
+ if ($child instanceof BaseNode && $child->isDeprecated()) {
+ $comments[] = \sprintf('Deprecated (%s)', $child->getDeprecationMessage($node));
+ }
+
+ if ($child instanceof EnumNode) {
+ $comments[] = 'One of '.$child->getPermissibleValues('; ');
+ }
+
+ if (\count($comments)) {
+ $rootAttributeComments[$name] = implode(";\n", $comments);
+ }
+
+ // default values
+ if ($child->hasDefaultValue()) {
+ $value = $child->getDefaultValue();
+ }
+
+ // append attribute
+ $rootAttributes[$name] = $value;
+ }
+ }
+
+ // render comments
+
+ // root node comment
+ if (\count($rootComments)) {
+ foreach ($rootComments as $comment) {
+ $this->writeLine('', $depth);
+ }
+ }
+
+ // attribute comments
+ if (\count($rootAttributeComments)) {
+ foreach ($rootAttributeComments as $attrName => $comment) {
+ $commentDepth = $depth + 4 + \strlen($attrName) + 2;
+ $commentLines = explode("\n", $comment);
+ $multiline = (\count($commentLines) > 1);
+ $comment = implode(\PHP_EOL.str_repeat(' ', $commentDepth), $commentLines);
+
+ if ($multiline) {
+ $this->writeLine('', $depth);
+ } else {
+ $this->writeLine('', $depth);
+ }
+ }
+ }
+
+ // render start tag + attributes
+ $rootIsVariablePrototype = isset($prototypeValue);
+ $rootIsEmptyTag = (0 === \count($rootChildren) && !$rootIsVariablePrototype);
+ $rootOpenTag = '<'.$rootName;
+ if (1 >= ($attributesCount = \count($rootAttributes))) {
+ if (1 === $attributesCount) {
+ $rootOpenTag .= \sprintf(' %s="%s"', current(array_keys($rootAttributes)), $this->writeValue(current($rootAttributes)));
+ }
+
+ $rootOpenTag .= $rootIsEmptyTag ? ' />' : '>';
+
+ if ($rootIsVariablePrototype) {
+ $rootOpenTag .= $prototypeValue.''.$rootName.'>';
+ }
+
+ $this->writeLine($rootOpenTag, $depth);
+ } else {
+ $this->writeLine($rootOpenTag, $depth);
+
+ $i = 1;
+
+ foreach ($rootAttributes as $attrName => $attrValue) {
+ $attr = \sprintf('%s="%s"', $attrName, $this->writeValue($attrValue));
+
+ $this->writeLine($attr, $depth + 4);
+
+ if ($attributesCount === $i++) {
+ $this->writeLine($rootIsEmptyTag ? '/>' : '>', $depth);
+
+ if ($rootIsVariablePrototype) {
+ $rootOpenTag .= $prototypeValue.''.$rootName.'>';
+ }
+ }
+ }
+ }
+
+ // render children tags
+ foreach ($rootChildren as $child) {
+ $this->writeLine('');
+ $this->writeNode($child, $depth + 4);
+ }
+
+ // render end tag
+ if (!$rootIsEmptyTag && !$rootIsVariablePrototype) {
+ $this->writeLine('');
+
+ $rootEndTag = ''.$rootName.'>';
+ $this->writeLine($rootEndTag, $depth);
+ }
+ }
+
+ /**
+ * Outputs a single config reference line.
+ */
+ private function writeLine(string $text, int $indent = 0): void
+ {
+ $indent = \strlen($text) + $indent;
+ $format = '%'.$indent.'s';
+
+ $this->reference .= \sprintf($format, $text).\PHP_EOL;
+ }
+
+ /**
+ * Renders the string conversion of the value.
+ */
+ private function writeValue(mixed $value): string
+ {
+ if ('%%%%not_defined%%%%' === $value) {
+ return '';
+ }
+
+ if (\is_string($value) || is_numeric($value)) {
+ return $value;
+ }
+
+ if (false === $value) {
+ return 'false';
+ }
+
+ if (true === $value) {
+ return 'true';
+ }
+
+ if (null === $value) {
+ return 'null';
+ }
+
+ if (!$value) {
+ return '';
+ }
+
+ if (\is_array($value)) {
+ return implode(',', $value);
+ }
+
+ return '';
+ }
+}
diff --git a/symfony/config/Definition/Dumper/YamlReferenceDumper.php b/symfony/config/Definition/Dumper/YamlReferenceDumper.php
new file mode 100644
index 0000000000000000000000000000000000000000..012b12351381340ede1d1789c6b5f640633e2bb8
--- /dev/null
+++ b/symfony/config/Definition/Dumper/YamlReferenceDumper.php
@@ -0,0 +1,244 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Definition\Dumper;
+
+use Symfony\Component\Config\Definition\ArrayNode;
+use Symfony\Component\Config\Definition\BaseNode;
+use Symfony\Component\Config\Definition\ConfigurationInterface;
+use Symfony\Component\Config\Definition\EnumNode;
+use Symfony\Component\Config\Definition\NodeInterface;
+use Symfony\Component\Config\Definition\PrototypedArrayNode;
+use Symfony\Component\Config\Definition\ScalarNode;
+use Symfony\Component\Yaml\Inline;
+
+/**
+ * Dumps a Yaml reference configuration for the given configuration/node instance.
+ *
+ * @author Kevin Bond
+ */
+class YamlReferenceDumper
+{
+ private ?string $reference = null;
+
+ public function dump(ConfigurationInterface $configuration): string
+ {
+ return $this->dumpNode($configuration->getConfigTreeBuilder()->buildTree());
+ }
+
+ public function dumpAtPath(ConfigurationInterface $configuration, string $path): string
+ {
+ $rootNode = $node = $configuration->getConfigTreeBuilder()->buildTree();
+
+ foreach (explode('.', $path) as $step) {
+ if (!$node instanceof ArrayNode) {
+ throw new \UnexpectedValueException(\sprintf('Unable to find node at path "%s.%s".', $rootNode->getName(), $path));
+ }
+
+ /** @var NodeInterface[] $children */
+ $children = $node instanceof PrototypedArrayNode ? $this->getPrototypeChildren($node) : $node->getChildren();
+
+ foreach ($children as $child) {
+ if ($child->getName() === $step) {
+ $node = $child;
+
+ continue 2;
+ }
+ }
+
+ throw new \UnexpectedValueException(\sprintf('Unable to find node at path "%s.%s".', $rootNode->getName(), $path));
+ }
+
+ return $this->dumpNode($node);
+ }
+
+ public function dumpNode(NodeInterface $node): string
+ {
+ $this->reference = '';
+ $this->writeNode($node);
+ $ref = $this->reference;
+ $this->reference = null;
+
+ return $ref;
+ }
+
+ private function writeNode(NodeInterface $node, ?NodeInterface $parentNode = null, int $depth = 0, bool $prototypedArray = false): void
+ {
+ $comments = [];
+ $default = '';
+ $defaultArray = null;
+ $children = null;
+ $example = null;
+ if ($node instanceof BaseNode) {
+ $example = $node->getExample();
+ }
+
+ // defaults
+ if ($node instanceof ArrayNode) {
+ $children = $node->getChildren();
+
+ if ($node instanceof PrototypedArrayNode) {
+ $children = $this->getPrototypeChildren($node);
+ }
+
+ if (!$children && !($node->hasDefaultValue() && $defaultArray = $node->getDefaultValue())) {
+ $default = $node->hasDefaultValue() && null === $defaultArray ? '~' : '[]';
+ }
+ } elseif ($node instanceof EnumNode) {
+ $comments[] = 'One of '.$node->getPermissibleValues('; ');
+ $default = $node->hasDefaultValue() ? Inline::dump($node->getDefaultValue()) : '~';
+ } else {
+ $default = '~';
+
+ if ($node->hasDefaultValue()) {
+ $default = $node->getDefaultValue();
+
+ if (\is_array($default)) {
+ if (\count($defaultArray = $node->getDefaultValue())) {
+ $default = '';
+ } elseif (!\is_array($example)) {
+ $default = '[]';
+ }
+ } else {
+ $default = Inline::dump($default);
+ }
+ }
+ }
+
+ // required?
+ if ($node->isRequired()) {
+ $comments[] = 'Required';
+ }
+
+ // deprecated?
+ if ($node instanceof BaseNode && $node->isDeprecated()) {
+ $comments[] = \sprintf('Deprecated (%s)', $node->getDeprecationMessage($parentNode));
+ }
+
+ // example
+ if ($example && !\is_array($example)) {
+ $comments[] = 'Example: '.Inline::dump($example);
+ }
+
+ $default = '' != (string) $default ? ' '.$default : '';
+ $comments = \count($comments) ? '# '.implode(', ', $comments) : '';
+
+ $key = $prototypedArray ? '-' : $node->getName().':';
+ $text = rtrim(\sprintf('%-21s%s %s', $key, $default, $comments), ' ');
+
+ if ($node instanceof BaseNode && $info = $node->getInfo()) {
+ $this->writeLine('');
+ // indenting multi-line info
+ $info = str_replace("\n", \sprintf("\n%".($depth * 4).'s# ', ' '), $info);
+ $this->writeLine('# '.$info, $depth * 4);
+ }
+
+ $this->writeLine($text, $depth * 4);
+
+ // output defaults
+ if ($defaultArray) {
+ $this->writeLine('');
+
+ $message = \count($defaultArray) > 1 ? 'Defaults' : 'Default';
+
+ $this->writeLine('# '.$message.':', $depth * 4 + 4);
+
+ $this->writeArray($defaultArray, $depth + 1);
+ }
+
+ if (\is_array($example)) {
+ $this->writeLine('');
+
+ $message = \count($example) > 1 ? 'Examples' : 'Example';
+
+ $this->writeLine('# '.$message.':', $depth * 4 + 4);
+
+ $this->writeArray(array_map(Inline::dump(...), $example), $depth + 1, true);
+ }
+
+ if ($children) {
+ foreach ($children as $childNode) {
+ $this->writeNode($childNode, $node, $depth + 1, $node instanceof PrototypedArrayNode && !$node->getKeyAttribute());
+ }
+ }
+ }
+
+ /**
+ * Outputs a single config reference line.
+ */
+ private function writeLine(string $text, int $indent = 0): void
+ {
+ $indent = \strlen($text) + $indent;
+ $format = '%'.$indent.'s';
+
+ $this->reference .= \sprintf($format, $text)."\n";
+ }
+
+ private function writeArray(array $array, int $depth, bool $asComment = false): void
+ {
+ $isIndexed = array_is_list($array);
+
+ foreach ($array as $key => $value) {
+ if (\is_array($value)) {
+ $val = '';
+ } else {
+ $val = $value;
+ }
+
+ $prefix = $asComment ? '# ' : '';
+
+ if ($isIndexed) {
+ $this->writeLine($prefix.'- '.$val, $depth * 4);
+ } else {
+ $this->writeLine(\sprintf('%s%-20s %s', $prefix, $key.':', $val), $depth * 4);
+ }
+
+ if (\is_array($value)) {
+ $this->writeArray($value, $depth + 1, $asComment);
+ }
+ }
+ }
+
+ private function getPrototypeChildren(PrototypedArrayNode $node): array
+ {
+ $prototype = $node->getPrototype();
+ $key = $node->getKeyAttribute();
+
+ // Do not expand prototype if it isn't an array node nor uses attribute as key
+ if (!$key && !$prototype instanceof ArrayNode) {
+ return $node->getChildren();
+ }
+
+ if ($prototype instanceof ArrayNode) {
+ $keyNode = new ArrayNode($key, $node);
+ $children = $prototype->getChildren();
+
+ if ($prototype instanceof PrototypedArrayNode && $prototype->getKeyAttribute()) {
+ $children = $this->getPrototypeChildren($prototype);
+ }
+
+ // add children
+ foreach ($children as $childNode) {
+ $keyNode->addChild($childNode);
+ }
+ } else {
+ $keyNode = new ScalarNode($key, $node);
+ }
+
+ $info = 'Prototype';
+ if (null !== $prototype->getInfo()) {
+ $info .= ': '.$prototype->getInfo();
+ }
+ $keyNode->setInfo($info);
+
+ return [$key ?? '' => $keyNode];
+ }
+}
diff --git a/symfony/config/Definition/EnumNode.php b/symfony/config/Definition/EnumNode.php
new file mode 100644
index 0000000000000000000000000000000000000000..6613538c892a25af47ba24d1d250c2721f4edcc6
--- /dev/null
+++ b/symfony/config/Definition/EnumNode.php
@@ -0,0 +1,168 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Definition;
+
+use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
+
+/**
+ * Node which only allows a finite set of values.
+ *
+ * @author Johannes M. Schmitt
+ */
+class EnumNode extends ScalarNode
+{
+ private array $values;
+ private ?string $enumFqcn = null;
+
+ /**
+ * @param class-string<\UnitEnum>|null $enumFqcn
+ */
+ public function __construct(?string $name, ?NodeInterface $parent = null, array $values = [], string $pathSeparator = BaseNode::DEFAULT_PATH_SEPARATOR, ?string $enumFqcn = null)
+ {
+ if (!$values && !$enumFqcn) {
+ throw new \InvalidArgumentException('$values must contain at least one element.');
+ }
+
+ if ($values && $enumFqcn) {
+ throw new \InvalidArgumentException('$values or $enumFqcn cannot be both set.');
+ }
+
+ if (null !== $enumFqcn) {
+ if (!enum_exists($enumFqcn)) {
+ throw new \InvalidArgumentException(\sprintf('The "%s" enum does not exist.', $enumFqcn));
+ }
+
+ $values = $enumFqcn::cases();
+ $this->enumFqcn = $enumFqcn;
+ }
+
+ foreach ($values as $value) {
+ if (null === $value || \is_scalar($value)) {
+ continue;
+ }
+
+ if (!$value instanceof \UnitEnum) {
+ throw new \InvalidArgumentException(\sprintf('"%s" only supports scalar, enum, or null values, "%s" given.', __CLASS__, get_debug_type($value)));
+ }
+
+ if ($value::class !== ($enumClass ??= $value::class)) {
+ throw new \InvalidArgumentException(\sprintf('"%s" only supports one type of enum, "%s" and "%s" passed.', __CLASS__, $enumClass, $value::class));
+ }
+ }
+
+ parent::__construct($name, $parent, $pathSeparator);
+ $this->values = $values;
+ }
+
+ public function getValues(): array
+ {
+ return $this->values;
+ }
+
+ public function getEnumFqcn(): ?string
+ {
+ return $this->enumFqcn;
+ }
+
+ /**
+ * @internal
+ */
+ public function getPermissibleValues(string $separator, bool $trim = true): string
+ {
+ if (is_subclass_of($this->enumFqcn, \BackedEnum::class)) {
+ if (!$trim) {
+ return 'value-of<\\'.$this->enumFqcn.'>'.$separator.'\\'.$this->enumFqcn;
+ }
+
+ $values = array_column($this->enumFqcn::cases(), 'value');
+
+ return implode($separator, array_map(static fn ($value) => json_encode($value, \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE), $values));
+ }
+
+ return implode($separator, array_unique(array_map(static function ($value) use ($trim) {
+ if (!$value instanceof \UnitEnum) {
+ return json_encode($value, \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE | \JSON_PRESERVE_ZERO_FRACTION);
+ }
+
+ return $trim ? ltrim(var_export($value, true), '\\') : var_export($value, true);
+ }, $this->values)));
+ }
+
+ protected function validateType(mixed $value): void
+ {
+ if ($value instanceof \UnitEnum) {
+ return;
+ }
+
+ parent::validateType($value);
+ }
+
+ protected function finalizeValue(mixed $value): mixed
+ {
+ $value = parent::finalizeValue($value);
+
+ if (null === $value && $this->enumFqcn) {
+ return null;
+ }
+
+ if (!$this->enumFqcn) {
+ if (!\in_array($value, $this->values, true)) {
+ throw $this->createInvalidValueException($value);
+ }
+
+ return $value;
+ }
+
+ if ($value instanceof $this->enumFqcn) {
+ return $value;
+ }
+
+ if (!is_subclass_of($this->enumFqcn, \BackedEnum::class)) {
+ // value is not an instance of the enum, and the enum is not
+ // backed, meaning no cast is possible
+ throw $this->createInvalidValueException($value);
+ }
+
+ if ($value instanceof \UnitEnum && !$value instanceof $this->enumFqcn) {
+ throw new InvalidConfigurationException(\sprintf('The value should be part of the "%s" enum, got a value from the "%s" enum.', $this->enumFqcn, get_debug_type($value)));
+ }
+
+ if (!\is_string($value) && !\is_int($value)) {
+ throw new InvalidConfigurationException(\sprintf('Only strings and integers can be cast to a case of the "%s" enum, got value of type "%s".', $this->enumFqcn, get_debug_type($value)));
+ }
+
+ try {
+ return $this->enumFqcn::from($value);
+ } catch (\TypeError|\ValueError) {
+ throw $this->createInvalidValueException($value);
+ }
+ }
+
+ private function createInvalidValueException(mixed $value): InvalidConfigurationException
+ {
+ $displayValue = match (true) {
+ \is_int($value) => $value,
+ \is_string($value) => \sprintf('"%s"', $value),
+ default => \sprintf('of type "%s"', get_debug_type($value)),
+ };
+
+ $message = \sprintf('The value %s is not allowed for path "%s". Permissible values: %s.', $displayValue, $this->getPath(), $this->getPermissibleValues(', '));
+ if ($this->enumFqcn) {
+ $message = substr_replace($message, \sprintf(' (cases of the "%s" enum)', $this->enumFqcn), -1, 0);
+ }
+
+ $e = new InvalidConfigurationException($message);
+ $e->setPath($this->getPath());
+
+ return $e;
+ }
+}
diff --git a/symfony/config/Definition/Exception/DuplicateKeyException.php b/symfony/config/Definition/Exception/DuplicateKeyException.php
new file mode 100644
index 0000000000000000000000000000000000000000..48dd9325e9062462296e7223e01de3791c119197
--- /dev/null
+++ b/symfony/config/Definition/Exception/DuplicateKeyException.php
@@ -0,0 +1,22 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Definition\Exception;
+
+/**
+ * This exception is thrown whenever the key of an array is not unique. This can
+ * only be the case if the configuration is coming from an XML file.
+ *
+ * @author Johannes M. Schmitt
+ */
+class DuplicateKeyException extends InvalidConfigurationException
+{
+}
diff --git a/symfony/config/Definition/Exception/Exception.php b/symfony/config/Definition/Exception/Exception.php
new file mode 100644
index 0000000000000000000000000000000000000000..8933a49233c32a1ff0a4997ce459164873f8e25f
--- /dev/null
+++ b/symfony/config/Definition/Exception/Exception.php
@@ -0,0 +1,21 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Definition\Exception;
+
+/**
+ * Base exception for all configuration exceptions.
+ *
+ * @author Johannes M. Schmitt
+ */
+class Exception extends \RuntimeException
+{
+}
diff --git a/symfony/config/Definition/Exception/ForbiddenOverwriteException.php b/symfony/config/Definition/Exception/ForbiddenOverwriteException.php
new file mode 100644
index 0000000000000000000000000000000000000000..726c07fb8b6341854de7602d35b79f19517164dc
--- /dev/null
+++ b/symfony/config/Definition/Exception/ForbiddenOverwriteException.php
@@ -0,0 +1,22 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Definition\Exception;
+
+/**
+ * This exception is thrown when a configuration path is overwritten from a
+ * subsequent configuration file, but the entry node specifically forbids this.
+ *
+ * @author Johannes M. Schmitt
+ */
+class ForbiddenOverwriteException extends InvalidConfigurationException
+{
+}
diff --git a/symfony/config/Definition/Exception/InvalidConfigurationException.php b/symfony/config/Definition/Exception/InvalidConfigurationException.php
new file mode 100644
index 0000000000000000000000000000000000000000..e3f29f8e6dfabe92a6728686f392bd247643d710
--- /dev/null
+++ b/symfony/config/Definition/Exception/InvalidConfigurationException.php
@@ -0,0 +1,47 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Definition\Exception;
+
+/**
+ * A very general exception which can be thrown whenever non of the more specific
+ * exceptions is suitable.
+ *
+ * @author Johannes M. Schmitt
+ */
+class InvalidConfigurationException extends Exception
+{
+ private ?string $path = null;
+ private bool $containsHints = false;
+
+ public function setPath(string $path): void
+ {
+ $this->path = $path;
+ }
+
+ public function getPath(): ?string
+ {
+ return $this->path;
+ }
+
+ /**
+ * Adds extra information that is suffixed to the original exception message.
+ */
+ public function addHint(string $hint): void
+ {
+ if (!$this->containsHints) {
+ $this->message .= "\nHint: ".$hint;
+ $this->containsHints = true;
+ } else {
+ $this->message .= ', '.$hint;
+ }
+ }
+}
diff --git a/symfony/config/Definition/Exception/InvalidDefinitionException.php b/symfony/config/Definition/Exception/InvalidDefinitionException.php
new file mode 100644
index 0000000000000000000000000000000000000000..98310dae02a68ac412cce88dd178a115b221410a
--- /dev/null
+++ b/symfony/config/Definition/Exception/InvalidDefinitionException.php
@@ -0,0 +1,21 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Definition\Exception;
+
+/**
+ * Thrown when an error is detected in a node Definition.
+ *
+ * @author Victor Berchet
+ */
+class InvalidDefinitionException extends Exception
+{
+}
diff --git a/symfony/config/Definition/Exception/InvalidTypeException.php b/symfony/config/Definition/Exception/InvalidTypeException.php
new file mode 100644
index 0000000000000000000000000000000000000000..d7ca8c9d0956b38157c45b60c1575825aaa6e40e
--- /dev/null
+++ b/symfony/config/Definition/Exception/InvalidTypeException.php
@@ -0,0 +1,21 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Definition\Exception;
+
+/**
+ * This exception is thrown if an invalid type is encountered.
+ *
+ * @author Johannes M. Schmitt
+ */
+class InvalidTypeException extends InvalidConfigurationException
+{
+}
diff --git a/symfony/config/Definition/Exception/UnsetKeyException.php b/symfony/config/Definition/Exception/UnsetKeyException.php
new file mode 100644
index 0000000000000000000000000000000000000000..863181a33f52ed7af37587e2dba31661833040d7
--- /dev/null
+++ b/symfony/config/Definition/Exception/UnsetKeyException.php
@@ -0,0 +1,22 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Definition\Exception;
+
+/**
+ * This exception is usually not encountered by the end-user, but only used
+ * internally to signal the parent scope to unset a key.
+ *
+ * @author Johannes M. Schmitt
+ */
+class UnsetKeyException extends Exception
+{
+}
diff --git a/symfony/config/Definition/FloatNode.php b/symfony/config/Definition/FloatNode.php
new file mode 100644
index 0000000000000000000000000000000000000000..8b922804bb8202958666f7ed484e537fa7001a23
--- /dev/null
+++ b/symfony/config/Definition/FloatNode.php
@@ -0,0 +1,45 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Definition;
+
+use Symfony\Component\Config\Definition\Exception\InvalidTypeException;
+
+/**
+ * This node represents a float value in the config tree.
+ *
+ * @author Jeanmonod David
+ */
+class FloatNode extends NumericNode
+{
+ protected function validateType(mixed $value): void
+ {
+ // Integers are also accepted, we just cast them
+ if (\is_int($value)) {
+ $value = (float) $value;
+ }
+
+ if (!\is_float($value)) {
+ $ex = new InvalidTypeException(\sprintf('Invalid type for path "%s". Expected "float", but got "%s".', $this->getPath(), get_debug_type($value)));
+ if ($hint = $this->getInfo()) {
+ $ex->addHint($hint);
+ }
+ $ex->setPath($this->getPath());
+
+ throw $ex;
+ }
+ }
+
+ protected function getValidPlaceholderTypes(): array
+ {
+ return ['float'];
+ }
+}
diff --git a/symfony/config/Definition/IntegerNode.php b/symfony/config/Definition/IntegerNode.php
new file mode 100644
index 0000000000000000000000000000000000000000..6fa3e6032505272188f8f6eaa119b4377893d65c
--- /dev/null
+++ b/symfony/config/Definition/IntegerNode.php
@@ -0,0 +1,40 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Definition;
+
+use Symfony\Component\Config\Definition\Exception\InvalidTypeException;
+
+/**
+ * This node represents an integer value in the config tree.
+ *
+ * @author Jeanmonod David
+ */
+class IntegerNode extends NumericNode
+{
+ protected function validateType(mixed $value): void
+ {
+ if (!\is_int($value)) {
+ $ex = new InvalidTypeException(\sprintf('Invalid type for path "%s". Expected "int", but got "%s".', $this->getPath(), get_debug_type($value)));
+ if ($hint = $this->getInfo()) {
+ $ex->addHint($hint);
+ }
+ $ex->setPath($this->getPath());
+
+ throw $ex;
+ }
+ }
+
+ protected function getValidPlaceholderTypes(): array
+ {
+ return ['int'];
+ }
+}
diff --git a/symfony/config/Definition/Loader/DefinitionFileLoader.php b/symfony/config/Definition/Loader/DefinitionFileLoader.php
new file mode 100644
index 0000000000000000000000000000000000000000..26407dc53b8a95e15d2affc2e0cf39b1d0731e09
--- /dev/null
+++ b/symfony/config/Definition/Loader/DefinitionFileLoader.php
@@ -0,0 +1,113 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Definition\Loader;
+
+use Symfony\Component\Config\Definition\Builder\TreeBuilder;
+use Symfony\Component\Config\Definition\Configurator\DefinitionConfigurator;
+use Symfony\Component\Config\FileLocatorInterface;
+use Symfony\Component\Config\Loader\FileLoader;
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+
+/**
+ * DefinitionFileLoader loads config definitions from a PHP file.
+ *
+ * The PHP file is required.
+ *
+ * @author Yonel Ceruto
+ */
+class DefinitionFileLoader extends FileLoader
+{
+ public function __construct(
+ private TreeBuilder $treeBuilder,
+ FileLocatorInterface $locator,
+ private ?ContainerBuilder $container = null,
+ ) {
+ parent::__construct($locator);
+ }
+
+ public function load(mixed $resource, ?string $type = null): mixed
+ {
+ // the loader variable is exposed to the included file below
+ $loader = $this;
+
+ $path = $this->locator->locate($resource);
+ $this->setCurrentDir(\dirname($path));
+ $this->container?->fileExists($path);
+
+ // the closure forbids access to the private scope in the included file
+ $load = \Closure::bind(static function ($file) use ($loader) {
+ return include $file;
+ }, null, null);
+
+ try {
+ $callback = $load($path);
+ } catch (\Error $e) {
+ $load = \Closure::bind(static function ($file) use ($loader) {
+ return include $file;
+ }, null, ProtectedDefinitionFileLoader::class);
+
+ $callback = $load($path);
+
+ trigger_deprecation('symfony/config', '7.4', 'Accessing the internal scope of the loader in config files is deprecated, use only its public API instead in "%s" on line %d.', $e->getFile(), $e->getLine());
+ }
+
+ if (\is_object($callback) && \is_callable($callback)) {
+ $this->callConfigurator($callback, new DefinitionConfigurator($this->treeBuilder, $this, $path, $resource), $path);
+ }
+
+ return null;
+ }
+
+ public function supports(mixed $resource, ?string $type = null): bool
+ {
+ if (!\is_string($resource)) {
+ return false;
+ }
+
+ if (null === $type && 'php' === pathinfo($resource, \PATHINFO_EXTENSION)) {
+ return true;
+ }
+
+ return 'php' === $type;
+ }
+
+ private function callConfigurator(callable $callback, DefinitionConfigurator $configurator, string $path): void
+ {
+ $callback = $callback(...);
+
+ $arguments = [];
+ $r = new \ReflectionFunction($callback);
+
+ foreach ($r->getParameters() as $parameter) {
+ $reflectionType = $parameter->getType();
+
+ if (!$reflectionType instanceof \ReflectionNamedType) {
+ throw new \InvalidArgumentException(\sprintf('Could not resolve argument "$%s" for "%s". You must typehint it (for example with "%s").', $parameter->getName(), $path, DefinitionConfigurator::class));
+ }
+
+ $arguments[] = match ($reflectionType->getName()) {
+ DefinitionConfigurator::class => $configurator,
+ TreeBuilder::class => $this->treeBuilder,
+ FileLoader::class, self::class => $this,
+ };
+ }
+
+ $callback(...$arguments);
+ }
+}
+
+/**
+ * @internal
+ */
+final class ProtectedDefinitionFileLoader extends DefinitionFileLoader
+{
+}
diff --git a/symfony/config/Definition/NodeInterface.php b/symfony/config/Definition/NodeInterface.php
new file mode 100644
index 0000000000000000000000000000000000000000..d1715870ac32382f2ca4da9fde31db6d031b9937
--- /dev/null
+++ b/symfony/config/Definition/NodeInterface.php
@@ -0,0 +1,77 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Definition;
+
+use Symfony\Component\Config\Definition\Exception\ForbiddenOverwriteException;
+use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
+use Symfony\Component\Config\Definition\Exception\InvalidTypeException;
+
+/**
+ * Common Interface among all nodes.
+ *
+ * In most cases, it is better to inherit from BaseNode instead of implementing
+ * this interface yourself.
+ *
+ * @author Johannes M. Schmitt
+ */
+interface NodeInterface
+{
+ /**
+ * Returns the name of the node.
+ */
+ public function getName(): string;
+
+ /**
+ * Returns the path of the node.
+ */
+ public function getPath(): string;
+
+ /**
+ * Returns true when the node is required.
+ */
+ public function isRequired(): bool;
+
+ /**
+ * Returns true when the node has a default value.
+ */
+ public function hasDefaultValue(): bool;
+
+ /**
+ * Returns the default value of the node.
+ *
+ * @throws \RuntimeException if the node has no default value
+ */
+ public function getDefaultValue(): mixed;
+
+ /**
+ * Normalizes a value.
+ *
+ * @throws InvalidTypeException if the value type is invalid
+ */
+ public function normalize(mixed $value): mixed;
+
+ /**
+ * Merges two values together.
+ *
+ * @throws ForbiddenOverwriteException if the configuration path cannot be overwritten
+ * @throws InvalidTypeException if the value type is invalid
+ */
+ public function merge(mixed $leftSide, mixed $rightSide): mixed;
+
+ /**
+ * Finalizes a value.
+ *
+ * @throws InvalidTypeException if the value type is invalid
+ * @throws InvalidConfigurationException if the value is invalid configuration
+ */
+ public function finalize(mixed $value): mixed;
+}
diff --git a/symfony/config/Definition/NumericNode.php b/symfony/config/Definition/NumericNode.php
new file mode 100644
index 0000000000000000000000000000000000000000..eac160cf3de319364953856060dc4aaf902e7abe
--- /dev/null
+++ b/symfony/config/Definition/NumericNode.php
@@ -0,0 +1,68 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Definition;
+
+use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
+
+/**
+ * This node represents a numeric value in the config tree.
+ *
+ * @author David Jeanmonod
+ */
+class NumericNode extends ScalarNode
+{
+ public function __construct(
+ ?string $name,
+ ?NodeInterface $parent = null,
+ protected int|float|null $min = null,
+ protected int|float|null $max = null,
+ string $pathSeparator = BaseNode::DEFAULT_PATH_SEPARATOR,
+ ) {
+ parent::__construct($name, $parent, $pathSeparator);
+ }
+
+ protected function finalizeValue(mixed $value): mixed
+ {
+ $value = parent::finalizeValue($value);
+
+ $errorMsg = null;
+ if (isset($this->min) && $value < $this->min) {
+ $errorMsg = \sprintf('The value %s is too small for path "%s". Should be greater than or equal to %s', $value, $this->getPath(), $this->min);
+ }
+ if (isset($this->max) && $value > $this->max) {
+ $errorMsg = \sprintf('The value %s is too big for path "%s". Should be less than or equal to %s', $value, $this->getPath(), $this->max);
+ }
+ if (isset($errorMsg)) {
+ $ex = new InvalidConfigurationException($errorMsg);
+ $ex->setPath($this->getPath());
+ throw $ex;
+ }
+
+ return $value;
+ }
+
+ public function getMin(): float|int|null
+ {
+ return $this->min;
+ }
+
+ public function getMax(): float|int|null
+ {
+ return $this->max;
+ }
+
+ protected function isValueEmpty(mixed $value): bool
+ {
+ // a numeric value cannot be empty
+ return false;
+ }
+}
diff --git a/symfony/config/Definition/Processor.php b/symfony/config/Definition/Processor.php
new file mode 100644
index 0000000000000000000000000000000000000000..272ddcc4473605d1888e52f5220e59501968d6b1
--- /dev/null
+++ b/symfony/config/Definition/Processor.php
@@ -0,0 +1,89 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Definition;
+
+/**
+ * This class is the entry point for config normalization/merging/finalization.
+ *
+ * @author Johannes M. Schmitt
+ *
+ * @final
+ */
+class Processor
+{
+ /**
+ * Processes an array of configurations.
+ *
+ * @param array $configs An array of configuration items to process
+ */
+ public function process(NodeInterface $configTree, array $configs): array
+ {
+ $currentConfig = [];
+ foreach ($configs as $config) {
+ $config = $configTree->normalize($config);
+ $currentConfig = $configTree->merge($currentConfig, $config);
+ }
+
+ return $configTree->finalize($currentConfig);
+ }
+
+ /**
+ * Processes an array of configurations.
+ *
+ * @param array $configs An array of configuration items to process
+ */
+ public function processConfiguration(ConfigurationInterface $configuration, array $configs): array
+ {
+ return $this->process($configuration->getConfigTreeBuilder()->buildTree(), $configs);
+ }
+
+ /**
+ * Normalizes a configuration entry.
+ *
+ * This method returns a normalize configuration array for a given key
+ * to remove the differences due to the original format (YAML and XML mainly).
+ *
+ * Here is an example.
+ *
+ * The configuration in XML:
+ *
+ * twig.extension.foo
+ * twig.extension.bar
+ *
+ * And the same configuration in YAML:
+ *
+ * extensions: ['twig.extension.foo', 'twig.extension.bar']
+ *
+ * @param array $config A config array
+ * @param string $key The key to normalize
+ * @param string|null $plural The plural form of the key if it is irregular
+ */
+ public static function normalizeConfig(array $config, string $key, ?string $plural = null): array
+ {
+ $plural ??= $key.'s';
+
+ if (isset($config[$plural])) {
+ return $config[$plural];
+ }
+
+ if (isset($config[$key])) {
+ if (\is_string($config[$key]) || !\is_int(key($config[$key]))) {
+ // only one
+ return [$config[$key]];
+ }
+
+ return $config[$key];
+ }
+
+ return [];
+ }
+}
diff --git a/symfony/config/Definition/PrototypeNodeInterface.php b/symfony/config/Definition/PrototypeNodeInterface.php
new file mode 100644
index 0000000000000000000000000000000000000000..109889f37d50d7f740c9b9da3c8fb00df4c67903
--- /dev/null
+++ b/symfony/config/Definition/PrototypeNodeInterface.php
@@ -0,0 +1,25 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Definition;
+
+/**
+ * This interface must be implemented by nodes which can be used as prototypes.
+ *
+ * @author Johannes M. Schmitt
+ */
+interface PrototypeNodeInterface extends NodeInterface
+{
+ /**
+ * Sets the name of the node.
+ */
+ public function setName(string $name): void;
+}
diff --git a/symfony/config/Definition/PrototypedArrayNode.php b/symfony/config/Definition/PrototypedArrayNode.php
new file mode 100644
index 0000000000000000000000000000000000000000..ea38882715f9241c3601b63b2a8e86452c6b3cbc
--- /dev/null
+++ b/symfony/config/Definition/PrototypedArrayNode.php
@@ -0,0 +1,353 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Definition;
+
+use Symfony\Component\Config\Definition\Exception\DuplicateKeyException;
+use Symfony\Component\Config\Definition\Exception\Exception;
+use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
+use Symfony\Component\Config\Definition\Exception\UnsetKeyException;
+
+/**
+ * Represents a prototyped Array node in the config tree.
+ *
+ * @author Johannes M. Schmitt
+ */
+class PrototypedArrayNode extends ArrayNode
+{
+ protected PrototypeNodeInterface $prototype;
+ protected ?string $keyAttribute = null;
+ protected bool $removeKeyAttribute = false;
+ protected int $minNumberOfElements = 0;
+ protected array $defaultValue = [];
+ protected ?array $defaultChildren = null;
+
+ /**
+ * @var NodeInterface[] An array of the prototypes of the simplified value children
+ */
+ private array $valuePrototypes = [];
+ private bool $defaultToNull = false;
+
+ /**
+ * Sets the minimum number of elements that a prototype based node must
+ * contain. By default this is zero, meaning no elements.
+ */
+ public function setMinNumberOfElements(int $number): void
+ {
+ $this->minNumberOfElements = $number;
+ }
+
+ /**
+ * Sets the attribute which value is to be used as key.
+ *
+ * This is useful when you have an indexed array that should be an
+ * associative array. You can select an item from within the array
+ * to be the key of the particular item. For example, if "id" is the
+ * "key", then:
+ *
+ * [
+ * ['id' => 'my_name', 'foo' => 'bar'],
+ * ];
+ *
+ * becomes
+ *
+ * [
+ * 'my_name' => ['foo' => 'bar'],
+ * ];
+ *
+ * If you'd like "'id' => 'my_name'" to still be present in the resulting
+ * array, then you can set the second argument of this method to false.
+ *
+ * @param string $attribute The name of the attribute which value is to be used as a key
+ * @param bool $remove Whether or not to remove the key
+ */
+ public function setKeyAttribute(string $attribute, bool $remove = true): void
+ {
+ $this->keyAttribute = $attribute;
+ $this->removeKeyAttribute = $remove;
+ }
+
+ /**
+ * Retrieves the name of the attribute which value should be used as key.
+ */
+ public function getKeyAttribute(): ?string
+ {
+ return $this->keyAttribute;
+ }
+
+ /**
+ * Sets the default value of this node.
+ */
+ public function setDefaultValue(array $value): void
+ {
+ $this->defaultValue = $value;
+ $this->defaultToNull = false;
+ }
+
+ public function setNullAsDefault(): void
+ {
+ $this->defaultValue = [];
+ $this->defaultToNull = true;
+ }
+
+ public function hasDefaultValue(): bool
+ {
+ return true;
+ }
+
+ /**
+ * Adds default children when none are set.
+ *
+ * @param int|string|array|null $children The number of children|The child name|The children names to be added
+ */
+ public function setAddChildrenIfNoneSet(int|string|array|null $children = ['defaults']): void
+ {
+ if (null === $children) {
+ $this->defaultChildren = ['defaults'];
+ } else {
+ $this->defaultChildren = \is_int($children) && $children > 0 ? range(1, $children) : (array) $children;
+ }
+ $this->defaultToNull = false;
+ }
+
+ /**
+ * The default value could be either explicit or derived from the prototype
+ * default value.
+ */
+ public function getDefaultValue(): mixed
+ {
+ if ($this->defaultToNull) {
+ return null;
+ }
+
+ if (null !== $this->defaultChildren) {
+ $default = $this->prototype->hasDefaultValue() ? $this->prototype->getDefaultValue() : [];
+ $defaults = [];
+ foreach (array_values($this->defaultChildren) as $i => $name) {
+ $defaults[null === $this->keyAttribute ? $i : $name] = $default;
+ }
+
+ return $defaults;
+ }
+
+ return $this->defaultValue;
+ }
+
+ /**
+ * Sets the node prototype.
+ */
+ public function setPrototype(PrototypeNodeInterface $node): void
+ {
+ $this->prototype = $node;
+ }
+
+ /**
+ * Retrieves the prototype.
+ */
+ public function getPrototype(): PrototypeNodeInterface
+ {
+ return $this->prototype;
+ }
+
+ /**
+ * Disable adding concrete children for prototyped nodes.
+ *
+ * @throws Exception
+ */
+ public function addChild(NodeInterface $node): never
+ {
+ throw new Exception('A prototyped array node cannot have concrete children.');
+ }
+
+ protected function finalizeValue(mixed $value): mixed
+ {
+ if (false === $value) {
+ throw new UnsetKeyException(\sprintf('Unsetting key for path "%s", value: false.', $this->getPath()));
+ }
+
+ foreach ($value as $k => $v) {
+ $prototype = $this->getPrototypeForChild($k);
+ try {
+ $value[$k] = $prototype->finalize($v);
+ } catch (UnsetKeyException) {
+ unset($value[$k]);
+ }
+ }
+
+ if (\count($value) < $this->minNumberOfElements) {
+ $ex = new InvalidConfigurationException(\sprintf('The path "%s" should have at least %d element(s) defined.', $this->getPath(), $this->minNumberOfElements));
+ $ex->setPath($this->getPath());
+
+ throw $ex;
+ }
+
+ return $value;
+ }
+
+ /**
+ * @throws DuplicateKeyException
+ */
+ protected function normalizeValue(mixed $value): mixed
+ {
+ if (false === $value) {
+ return $value;
+ }
+
+ $value = $this->remapXml($value);
+
+ $isList = array_is_list($value);
+ $normalized = [];
+ foreach ($value as $k => $v) {
+ if (null !== $this->keyAttribute && \is_array($v)) {
+ if (!isset($v[$this->keyAttribute]) && \is_int($k) && $isList) {
+ $ex = new InvalidConfigurationException(\sprintf('The attribute "%s" must be set for path "%s".', $this->keyAttribute, $this->getPath()));
+ $ex->setPath($this->getPath());
+
+ throw $ex;
+ } elseif (isset($v[$this->keyAttribute])) {
+ $k = $v[$this->keyAttribute];
+
+ if (\is_float($k)) {
+ $k = var_export($k, true);
+ }
+
+ // remove the key attribute when required
+ if ($this->removeKeyAttribute) {
+ unset($v[$this->keyAttribute]);
+ }
+
+ // if only "value" is left
+ if (array_keys($v) === ['value']) {
+ $v = $v['value'];
+ if ($this->prototype instanceof ArrayNode && ($children = $this->prototype->getChildren()) && \array_key_exists('value', $children)) {
+ $valuePrototype = current($this->valuePrototypes) ?: clone $children['value'];
+ $valuePrototype->parent = $this;
+ $originalClosures = $this->prototype->normalizationClosures;
+ $valuePrototypeClosures = $valuePrototype->normalizationClosures;
+ $valuePrototype->normalizationClosures = array_merge($originalClosures, $valuePrototypeClosures);
+ $this->valuePrototypes[$k] = $valuePrototype;
+ }
+ }
+ }
+
+ if (\array_key_exists($k, $normalized)) {
+ $ex = new DuplicateKeyException(\sprintf('Duplicate key "%s" for path "%s".', $k, $this->getPath()));
+ $ex->setPath($this->getPath());
+
+ throw $ex;
+ }
+ }
+
+ $prototype = $this->getPrototypeForChild($k);
+ if (null !== $this->keyAttribute || !$isList) {
+ $normalized[$k] = $prototype->normalize($v);
+ } else {
+ $normalized[] = $prototype->normalize($v);
+ }
+ }
+
+ return $normalized;
+ }
+
+ protected function mergeValues(mixed $leftSide, mixed $rightSide): mixed
+ {
+ if (false === $rightSide) {
+ // if this is still false after the last config has been merged the
+ // finalization pass will take care of removing this key entirely
+ return false;
+ }
+
+ if (false === $leftSide || !$this->performDeepMerging) {
+ return $rightSide;
+ }
+
+ // Track if this is initial population (leftSide is empty) - allowNewKeys
+ // should only be enforced when merging additional configs, not when
+ // initially populating from the first config
+ $isInitialPopulation = [] === $leftSide;
+
+ $isList = array_is_list($rightSide);
+ foreach ($rightSide as $k => $v) {
+ // prototype, and key is irrelevant there are no named keys, append the element
+ if (null === $this->keyAttribute && $isList) {
+ $leftSide[] = $v;
+ continue;
+ }
+
+ // no conflict
+ if (!\array_key_exists($k, $leftSide)) {
+ if (!$this->allowNewKeys && !$isInitialPopulation) {
+ $ex = new InvalidConfigurationException(\sprintf('You are not allowed to define new elements for path "%s". Please define all elements for this path in one config file.', $this->getPath()));
+ $ex->setPath($this->getPath());
+
+ throw $ex;
+ }
+
+ if (\is_array($v) && ($prototype = $this->getPrototypeForChild($k)) instanceof ArrayNode) {
+ // Ensure prototype's merge is called to handle auto_enable recursively
+ $leftSide[$k] = $prototype->merge([], $v);
+ } else {
+ $leftSide[$k] = $v;
+ }
+ continue;
+ }
+
+ $prototype = $this->getPrototypeForChild($k);
+ $leftSide[$k] = $prototype->merge($leftSide[$k], $v);
+ }
+
+ return $leftSide;
+ }
+
+ /**
+ * Returns a prototype for the child node that is associated to $key in the value array.
+ * For general child nodes, this will be $this->prototype.
+ * But if $this->removeKeyAttribute is true and there are only two keys in the child node:
+ * one is same as this->keyAttribute and the other is 'value', then the prototype will be different.
+ *
+ * For example, assume $this->keyAttribute is 'name' and the value array is as follows:
+ *
+ * [
+ * [
+ * 'name' => 'name001',
+ * 'value' => 'value001'
+ * ]
+ * ]
+ *
+ * Now, the key is 0 and the child node is:
+ *
+ * [
+ * 'name' => 'name001',
+ * 'value' => 'value001'
+ * ]
+ *
+ * When normalizing the value array, the 'name' element will removed from the child node
+ * and its value becomes the new key of the child node:
+ *
+ * [
+ * 'name001' => ['value' => 'value001']
+ * ]
+ *
+ * Now only 'value' element is left in the child node which can be further simplified into a string:
+ *
+ * ['name001' => 'value001']
+ *
+ * Now, the key becomes 'name001' and the child node becomes 'value001' and
+ * the prototype of child node 'name001' should be a ScalarNode instead of an ArrayNode instance.
+ */
+ private function getPrototypeForChild(string $key): mixed
+ {
+ $prototype = $this->valuePrototypes[$key] ?? $this->prototype;
+ $prototype->setName($key);
+
+ return $prototype;
+ }
+}
diff --git a/symfony/config/Definition/ScalarNode.php b/symfony/config/Definition/ScalarNode.php
new file mode 100644
index 0000000000000000000000000000000000000000..341769249a78d84b8f5f30e710bc012bcd088d80
--- /dev/null
+++ b/symfony/config/Definition/ScalarNode.php
@@ -0,0 +1,58 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Definition;
+
+use Symfony\Component\Config\Definition\Exception\InvalidTypeException;
+
+/**
+ * This node represents a scalar value in the config tree.
+ *
+ * The following values are considered scalars:
+ * * booleans
+ * * strings
+ * * null
+ * * integers
+ * * floats
+ *
+ * @author Johannes M. Schmitt
+ */
+class ScalarNode extends VariableNode
+{
+ protected function validateType(mixed $value): void
+ {
+ if (!\is_scalar($value) && null !== $value) {
+ $ex = new InvalidTypeException(\sprintf('Invalid type for path "%s". Expected "scalar", but got "%s".', $this->getPath(), get_debug_type($value)));
+ if ($hint = $this->getInfo()) {
+ $ex->addHint($hint);
+ }
+ $ex->setPath($this->getPath());
+
+ throw $ex;
+ }
+ }
+
+ protected function isValueEmpty(mixed $value): bool
+ {
+ // assume environment variables are never empty (which in practice is likely to be true during runtime)
+ // not doing so breaks many configs that are valid today
+ if ($this->isHandlingPlaceholder()) {
+ return false;
+ }
+
+ return null === $value || '' === $value;
+ }
+
+ protected function getValidPlaceholderTypes(): array
+ {
+ return ['bool', 'int', 'float', 'string'];
+ }
+}
diff --git a/symfony/config/Definition/StringNode.php b/symfony/config/Definition/StringNode.php
new file mode 100644
index 0000000000000000000000000000000000000000..6687b8825be1baa9263279fa0c1b3d41673f5d92
--- /dev/null
+++ b/symfony/config/Definition/StringNode.php
@@ -0,0 +1,40 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Definition;
+
+use Symfony\Component\Config\Definition\Exception\InvalidTypeException;
+
+/**
+ * This node represents a String value in the config tree.
+ *
+ * @author Raffaele Carelle
+ */
+class StringNode extends ScalarNode
+{
+ protected function validateType(mixed $value): void
+ {
+ if (!\is_string($value)) {
+ $ex = new InvalidTypeException(\sprintf('Invalid type for path "%s". Expected "string", but got "%s".', $this->getPath(), get_debug_type($value)));
+ if ($hint = $this->getInfo()) {
+ $ex->addHint($hint);
+ }
+ $ex->setPath($this->getPath());
+
+ throw $ex;
+ }
+ }
+
+ protected function getValidPlaceholderTypes(): array
+ {
+ return ['string'];
+ }
+}
diff --git a/symfony/config/Definition/VariableNode.php b/symfony/config/Definition/VariableNode.php
new file mode 100644
index 0000000000000000000000000000000000000000..ed1b903a1976116f5a1cde1291c5869bb1b9eea8
--- /dev/null
+++ b/symfony/config/Definition/VariableNode.php
@@ -0,0 +1,117 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Definition;
+
+use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
+
+/**
+ * This node represents a value of variable type in the config tree.
+ *
+ * This node is intended for values of arbitrary type.
+ * Any PHP type is accepted as a value.
+ *
+ * @author Jeremy Mikola
+ */
+class VariableNode extends BaseNode implements PrototypeNodeInterface
+{
+ protected bool $defaultValueSet = false;
+ protected mixed $defaultValue = null;
+ protected bool $allowEmptyValue = true;
+
+ public function setDefaultValue(mixed $value): void
+ {
+ $this->defaultValueSet = true;
+ $this->defaultValue = $value;
+ }
+
+ public function hasDefaultValue(): bool
+ {
+ return $this->defaultValueSet;
+ }
+
+ public function getDefaultValue(): mixed
+ {
+ $v = $this->defaultValue;
+
+ return $v instanceof \Closure ? $v() : $v;
+ }
+
+ /**
+ * Sets if this node is allowed to have an empty value.
+ *
+ * @param bool $boolean True if this entity will accept empty values
+ */
+ public function setAllowEmptyValue(bool $boolean): void
+ {
+ $this->allowEmptyValue = $boolean;
+ }
+
+ public function setName(string $name): void
+ {
+ $this->name = $name;
+ }
+
+ protected function validateType(mixed $value): void
+ {
+ }
+
+ protected function finalizeValue(mixed $value): mixed
+ {
+ // deny environment variables only when using custom validators
+ // this avoids ever passing an empty value to final validation closures
+ if (!$this->allowEmptyValue && $this->isHandlingPlaceholder() && $this->finalValidationClosures) {
+ $e = new InvalidConfigurationException(\sprintf('The path "%s" cannot contain an environment variable when empty values are not allowed by definition and are validated.', $this->getPath()));
+ if ($hint = $this->getInfo()) {
+ $e->addHint($hint);
+ }
+ $e->setPath($this->getPath());
+
+ throw $e;
+ }
+
+ if (!$this->allowEmptyValue && $this->isValueEmpty($value)) {
+ $ex = new InvalidConfigurationException(\sprintf('The path "%s" cannot contain an empty value, but got %s.', $this->getPath(), json_encode($value)));
+ if ($hint = $this->getInfo()) {
+ $ex->addHint($hint);
+ }
+ $ex->setPath($this->getPath());
+
+ throw $ex;
+ }
+
+ return $value;
+ }
+
+ protected function normalizeValue(mixed $value): mixed
+ {
+ return $value;
+ }
+
+ protected function mergeValues(mixed $leftSide, mixed $rightSide): mixed
+ {
+ return $rightSide;
+ }
+
+ /**
+ * Evaluates if the given value is to be treated as empty.
+ *
+ * By default, PHP's empty() function is used to test for emptiness. This
+ * method may be overridden by subtypes to better match their understanding
+ * of empty data.
+ *
+ * @see finalizeValue()
+ */
+ protected function isValueEmpty(mixed $value): bool
+ {
+ return !$value;
+ }
+}
diff --git a/symfony/config/Exception/FileLoaderImportCircularReferenceException.php b/symfony/config/Exception/FileLoaderImportCircularReferenceException.php
new file mode 100644
index 0000000000000000000000000000000000000000..d39bde046fff30f2c3f579ed484bfdd079051e88
--- /dev/null
+++ b/symfony/config/Exception/FileLoaderImportCircularReferenceException.php
@@ -0,0 +1,27 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Exception;
+
+/**
+ * Exception class for when a circular reference is detected when importing resources.
+ *
+ * @author Fabien Potencier
+ */
+class FileLoaderImportCircularReferenceException extends LoaderLoadException
+{
+ public function __construct(array $resources, int $code = 0, ?\Throwable $previous = null)
+ {
+ $message = \sprintf('Circular reference detected in "%s" ("%s" > "%s").', $this->varToString($resources[0]), implode('" > "', $resources), $resources[0]);
+
+ \Exception::__construct($message, $code, $previous);
+ }
+}
diff --git a/symfony/config/Exception/FileLocatorFileNotFoundException.php b/symfony/config/Exception/FileLocatorFileNotFoundException.php
new file mode 100644
index 0000000000000000000000000000000000000000..d9e5b4f36f3eca9c2df22a9263f31694766d2eed
--- /dev/null
+++ b/symfony/config/Exception/FileLocatorFileNotFoundException.php
@@ -0,0 +1,34 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Exception;
+
+/**
+ * File locator exception if a file does not exist.
+ *
+ * @author Leo Feyer
+ */
+class FileLocatorFileNotFoundException extends \InvalidArgumentException
+{
+ public function __construct(
+ string $message = '',
+ int $code = 0,
+ ?\Throwable $previous = null,
+ private array $paths = [],
+ ) {
+ parent::__construct($message, $code, $previous);
+ }
+
+ public function getPaths(): array
+ {
+ return $this->paths;
+ }
+}
diff --git a/symfony/config/Exception/LoaderLoadException.php b/symfony/config/Exception/LoaderLoadException.php
new file mode 100644
index 0000000000000000000000000000000000000000..ce486a35fa6c223032c0dbed88c5bc21928b94fe
--- /dev/null
+++ b/symfony/config/Exception/LoaderLoadException.php
@@ -0,0 +1,112 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Exception;
+
+/**
+ * Exception class for when a resource cannot be loaded or imported.
+ *
+ * @author Ryan Weaver
+ */
+class LoaderLoadException extends \Exception
+{
+ /**
+ * @param mixed $resource The resource that could not be imported
+ * @param string|null $sourceResource The original resource importing the new resource
+ * @param int $code The error code
+ * @param \Throwable|null $previous A previous exception
+ * @param string|null $type The type of resource
+ */
+ public function __construct(mixed $resource, ?string $sourceResource = null, int $code = 0, ?\Throwable $previous = null, ?string $type = null)
+ {
+ if (!\is_string($resource)) {
+ try {
+ $resource = json_encode($resource, \JSON_THROW_ON_ERROR);
+ } catch (\JsonException) {
+ $resource = \sprintf('resource of type "%s"', get_debug_type($resource));
+ }
+ }
+
+ $message = '';
+ if ($previous) {
+ // Include the previous exception, to help the user see what might be the underlying cause
+
+ // Trim the trailing period of the previous message. We only want 1 period remove so no rtrim...
+ if (str_ends_with($previous->getMessage(), '.')) {
+ $trimmedMessage = substr($previous->getMessage(), 0, -1);
+ $message .= \sprintf('%s', $trimmedMessage).' in ';
+ } else {
+ $message .= \sprintf('%s', $previous->getMessage()).' in ';
+ }
+ $message .= $resource.' ';
+
+ // show tweaked trace to complete the human readable sentence
+ if (null === $sourceResource) {
+ $message .= \sprintf('(which is loaded in resource "%s")', $resource);
+ } else {
+ $message .= \sprintf('(which is being imported from "%s")', $sourceResource);
+ }
+ $message .= '.';
+
+ // if there's no previous message, present it the default way
+ } elseif (null === $sourceResource) {
+ $message .= \sprintf('Cannot load resource "%s".', $resource);
+ } else {
+ $message .= \sprintf('Cannot import resource "%s" from "%s".', $resource, $sourceResource);
+ }
+
+ // Is the resource located inside a bundle?
+ if ('@' === $resource[0]) {
+ $parts = explode(\DIRECTORY_SEPARATOR, $resource);
+ $bundle = substr($parts[0], 1);
+ $message .= \sprintf(' Make sure the "%s" bundle is correctly registered and loaded in the application kernel class.', $bundle);
+ $message .= \sprintf(' If the bundle is registered, make sure the bundle path "%s" is not empty.', $resource);
+ } elseif (null !== $type) {
+ $message .= \sprintf(' Make sure there is a loader supporting the "%s" type.', $type);
+ }
+
+ parent::__construct($message, $code, $previous);
+ }
+
+ protected function varToString(mixed $var): string
+ {
+ if (\is_object($var)) {
+ return \sprintf('Object(%s)', $var::class);
+ }
+
+ if (\is_array($var)) {
+ $a = [];
+ foreach ($var as $k => $v) {
+ $a[] = \sprintf('%s => %s', $k, $this->varToString($v));
+ }
+
+ return \sprintf('Array(%s)', implode(', ', $a));
+ }
+
+ if (\is_resource($var)) {
+ return \sprintf('Resource(%s)', get_resource_type($var));
+ }
+
+ if (null === $var) {
+ return 'null';
+ }
+
+ if (false === $var) {
+ return 'false';
+ }
+
+ if (true === $var) {
+ return 'true';
+ }
+
+ return (string) $var;
+ }
+}
diff --git a/symfony/config/Exception/LogicException.php b/symfony/config/Exception/LogicException.php
new file mode 100644
index 0000000000000000000000000000000000000000..d227aece4b3b28ccf9fb5e9700268319c65f9980
--- /dev/null
+++ b/symfony/config/Exception/LogicException.php
@@ -0,0 +1,16 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Exception;
+
+class LogicException extends \LogicException
+{
+}
diff --git a/symfony/config/FileLocator.php b/symfony/config/FileLocator.php
new file mode 100644
index 0000000000000000000000000000000000000000..3a5064edc5fed820247ff2602d944668d1b84262
--- /dev/null
+++ b/symfony/config/FileLocator.php
@@ -0,0 +1,97 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config;
+
+use Symfony\Component\Config\Exception\FileLocatorFileNotFoundException;
+
+/**
+ * FileLocator uses an array of pre-defined paths to find files.
+ *
+ * @author Fabien Potencier
+ */
+class FileLocator implements FileLocatorInterface
+{
+ protected array $paths;
+
+ /**
+ * @param string|string[] $paths A path or an array of paths where to look for resources
+ */
+ public function __construct(string|array $paths = [])
+ {
+ $this->paths = (array) $paths;
+ }
+
+ /**
+ * @return string|string[]
+ *
+ * @psalm-return ($first is true ? string : string[])
+ */
+ public function locate(string $name, ?string $currentPath = null, bool $first = true): string|array
+ {
+ if ('' === $name) {
+ throw new \InvalidArgumentException('An empty file name is not valid to be located.');
+ }
+
+ if ($this->isAbsolutePath($name)) {
+ if (!file_exists($name)) {
+ throw new FileLocatorFileNotFoundException(\sprintf('The file "%s" does not exist.', $name), 0, null, [$name]);
+ }
+
+ return $name;
+ }
+
+ $paths = $this->paths;
+
+ if (null !== $currentPath) {
+ array_unshift($paths, $currentPath);
+ }
+
+ $paths = array_unique($paths);
+ $filepaths = $notfound = [];
+
+ foreach ($paths as $path) {
+ if (@file_exists($file = $path.\DIRECTORY_SEPARATOR.$name)) {
+ if (true === $first) {
+ return $file;
+ }
+ $filepaths[] = $file;
+ } else {
+ $notfound[] = $file;
+ }
+ }
+
+ if (!$filepaths) {
+ throw new FileLocatorFileNotFoundException(\sprintf('The file "%s" does not exist (in: "%s").', $name, implode('", "', $paths)), 0, null, $notfound);
+ }
+
+ return $filepaths;
+ }
+
+ /**
+ * Returns whether the file path is an absolute path.
+ */
+ private function isAbsolutePath(string $file): bool
+ {
+ if ('/' === $file[0] || '\\' === $file[0]
+ || (\strlen($file) > 3 && ctype_alpha($file[0])
+ && ':' === $file[1]
+ && ('\\' === $file[2] || '/' === $file[2])
+ )
+ || parse_url($file, \PHP_URL_SCHEME)
+ || str_starts_with($file, 'phar:///') // "parse_url()" doesn't handle absolute phar path, despite being valid
+ ) {
+ return true;
+ }
+
+ return false;
+ }
+}
diff --git a/symfony/config/FileLocatorInterface.php b/symfony/config/FileLocatorInterface.php
new file mode 100644
index 0000000000000000000000000000000000000000..24bc70964a510c1dc5a3e34313b0495b3b1e8a62
--- /dev/null
+++ b/symfony/config/FileLocatorInterface.php
@@ -0,0 +1,36 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config;
+
+use Symfony\Component\Config\Exception\FileLocatorFileNotFoundException;
+
+/**
+ * @author Fabien Potencier
+ */
+interface FileLocatorInterface
+{
+ /**
+ * Returns a full path for a given file name.
+ *
+ * @param string $name The file name to locate
+ * @param string|null $currentPath The current path
+ * @param bool $first Whether to return the first occurrence or an array of filenames
+ *
+ * @return string|string[] The full path to the file or an array of file paths
+ *
+ * @psalm-return ($first is true ? string : string[])
+ *
+ * @throws \InvalidArgumentException If $name is empty
+ * @throws FileLocatorFileNotFoundException If a file is not found
+ */
+ public function locate(string $name, ?string $currentPath = null, bool $first = true): string|array;
+}
diff --git a/symfony/config/LICENSE b/symfony/config/LICENSE
new file mode 100644
index 0000000000000000000000000000000000000000..0138f8f0713513e6452a5b7a428b9cf555bb1377
--- /dev/null
+++ b/symfony/config/LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2004-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.
diff --git a/symfony/config/Loader/DelegatingLoader.php b/symfony/config/Loader/DelegatingLoader.php
new file mode 100644
index 0000000000000000000000000000000000000000..045a559e2bad08ae0c4baa38e558280949ca67e9
--- /dev/null
+++ b/symfony/config/Loader/DelegatingLoader.php
@@ -0,0 +1,44 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Loader;
+
+use Symfony\Component\Config\Exception\LoaderLoadException;
+
+/**
+ * DelegatingLoader delegates loading to other loaders using a loader resolver.
+ *
+ * This loader acts as an array of LoaderInterface objects - each having
+ * a chance to load a given resource (handled by the resolver)
+ *
+ * @author Fabien Potencier
+ */
+class DelegatingLoader extends Loader
+{
+ public function __construct(LoaderResolverInterface $resolver)
+ {
+ $this->resolver = $resolver;
+ }
+
+ public function load(mixed $resource, ?string $type = null): mixed
+ {
+ if (false === $loader = $this->resolver->resolve($resource, $type)) {
+ throw new LoaderLoadException($resource, null, 0, null, $type);
+ }
+
+ return $loader->load($resource, $type);
+ }
+
+ public function supports(mixed $resource, ?string $type = null): bool
+ {
+ return false !== $this->resolver->resolve($resource, $type);
+ }
+}
diff --git a/symfony/config/Loader/DirectoryAwareLoaderInterface.php b/symfony/config/Loader/DirectoryAwareLoaderInterface.php
new file mode 100644
index 0000000000000000000000000000000000000000..87559cba90c4b831f3849707872abb98fd1b997e
--- /dev/null
+++ b/symfony/config/Loader/DirectoryAwareLoaderInterface.php
@@ -0,0 +1,22 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Loader;
+
+/**
+ * A loader that can be scoped to a given filesystem directory.
+ *
+ * @author Alexander M. Turek
+ */
+interface DirectoryAwareLoaderInterface
+{
+ public function forDirectory(string $currentDirectory): static;
+}
diff --git a/symfony/config/Loader/FileLoader.php b/symfony/config/Loader/FileLoader.php
new file mode 100644
index 0000000000000000000000000000000000000000..8d9d8462713156599bd3f228b857506c2b43d56a
--- /dev/null
+++ b/symfony/config/Loader/FileLoader.php
@@ -0,0 +1,183 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Loader;
+
+use Symfony\Component\Config\Exception\FileLoaderImportCircularReferenceException;
+use Symfony\Component\Config\Exception\FileLocatorFileNotFoundException;
+use Symfony\Component\Config\Exception\LoaderLoadException;
+use Symfony\Component\Config\FileLocatorInterface;
+use Symfony\Component\Config\Resource\FileExistenceResource;
+use Symfony\Component\Config\Resource\GlobResource;
+
+/**
+ * FileLoader is the abstract class used by all built-in loaders that are file based.
+ *
+ * @author Fabien Potencier
+ */
+abstract class FileLoader extends Loader
+{
+ protected static array $loading = [];
+
+ private ?string $currentDir = null;
+
+ public function __construct(
+ protected FileLocatorInterface $locator,
+ ?string $env = null,
+ ) {
+ parent::__construct($env);
+ }
+
+ /**
+ * Sets the current directory.
+ */
+ public function setCurrentDir(string $dir): void
+ {
+ $this->currentDir = $dir;
+ }
+
+ /**
+ * Returns the file locator used by this loader.
+ */
+ public function getLocator(): FileLocatorInterface
+ {
+ return $this->locator;
+ }
+
+ /**
+ * Imports a resource.
+ *
+ * @param mixed $resource A Resource
+ * @param string|null $type The resource type or null if unknown
+ * @param bool $ignoreErrors Whether to ignore import errors or not
+ * @param string|null $sourceResource The original resource importing the new resource
+ * @param string|string[]|null $exclude Glob patterns to exclude from the import
+ *
+ * @throws LoaderLoadException
+ * @throws FileLoaderImportCircularReferenceException
+ * @throws FileLocatorFileNotFoundException
+ */
+ public function import(mixed $resource, ?string $type = null, bool $ignoreErrors = false, ?string $sourceResource = null, string|array|null $exclude = null): mixed
+ {
+ if (\is_string($resource) && \strlen($resource) !== ($i = strcspn($resource, '*?{[')) && !str_contains($resource, "\n")) {
+ $excluded = [];
+ foreach ((array) $exclude as $pattern) {
+ foreach ($this->glob($pattern, true, $_, false, true) as $path => $info) {
+ // normalize Windows slashes and remove trailing slashes
+ $excluded[rtrim(str_replace('\\', '/', $path), '/')] = true;
+ }
+ }
+
+ $ret = [];
+ $isSubpath = 0 !== $i && str_contains(substr($resource, 0, $i), '/');
+ foreach ($this->glob($resource, false, $_, $ignoreErrors || !$isSubpath, false, $excluded) as $path => $info) {
+ if (null !== $res = $this->doImport($path, 'glob' === $type ? null : $type, $ignoreErrors, $sourceResource)) {
+ $ret[] = $res;
+ }
+ $isSubpath = true;
+ }
+
+ if ($isSubpath) {
+ return isset($ret[1]) ? $ret : ($ret[0] ?? null);
+ }
+ }
+
+ return $this->doImport($resource, $type, $ignoreErrors, $sourceResource);
+ }
+
+ /**
+ * @internal
+ */
+ protected function glob(string $pattern, bool $recursive, array|GlobResource|null &$resource = null, bool $ignoreErrors = false, bool $forExclusion = false, array $excluded = []): iterable
+ {
+ if (\strlen($pattern) === $i = strcspn($pattern, '*?{[')) {
+ $prefix = $pattern;
+ $pattern = '';
+ } elseif (0 === $i || !str_contains(substr($pattern, 0, $i), '/')) {
+ $prefix = '.';
+ $pattern = '/'.$pattern;
+ } else {
+ $prefix = \dirname(substr($pattern, 0, 1 + $i));
+ $pattern = substr($pattern, \strlen($prefix));
+ }
+
+ try {
+ $prefix = $this->locator->locate($prefix, $this->currentDir, true);
+ } catch (FileLocatorFileNotFoundException $e) {
+ if (!$ignoreErrors) {
+ throw $e;
+ }
+
+ $resource = [];
+ foreach ($e->getPaths() as $path) {
+ $resource[] = new FileExistenceResource($path);
+ }
+
+ return;
+ }
+ $resource = new GlobResource($prefix, $pattern, $recursive, $forExclusion, $excluded);
+
+ yield from $resource;
+ }
+
+ private function doImport(mixed $resource, ?string $type = null, bool $ignoreErrors = false, ?string $sourceResource = null): mixed
+ {
+ try {
+ $loader = $this->resolve($resource, $type);
+
+ if ($loader instanceof DirectoryAwareLoaderInterface) {
+ $loader = $loader->forDirectory($this->currentDir);
+ }
+
+ if (!$loader instanceof self) {
+ return $loader->load($resource, $type);
+ }
+
+ if (null !== $this->currentDir) {
+ $resource = $loader->getLocator()->locate($resource, $this->currentDir, false);
+ }
+
+ $resources = \is_array($resource) ? $resource : [$resource];
+ for ($i = 0; $i < $resourcesCount = \count($resources); ++$i) {
+ if (isset(self::$loading[$resources[$i]])) {
+ if ($i == $resourcesCount - 1) {
+ throw new FileLoaderImportCircularReferenceException(array_keys(self::$loading));
+ }
+ } else {
+ $resource = $resources[$i];
+ break;
+ }
+ }
+ self::$loading[$resource] = true;
+
+ try {
+ $ret = $loader->load($resource, $type);
+ } finally {
+ unset(self::$loading[$resource]);
+ }
+
+ return $ret;
+ } catch (FileLoaderImportCircularReferenceException $e) {
+ throw $e;
+ } catch (\Exception $e) {
+ if (!$ignoreErrors) {
+ // prevent embedded imports from nesting multiple exceptions
+ if ($e instanceof LoaderLoadException) {
+ throw $e;
+ }
+
+ throw new LoaderLoadException($resource, $sourceResource, 0, $e, $type);
+ }
+ }
+
+ return null;
+ }
+}
diff --git a/symfony/config/Loader/GlobFileLoader.php b/symfony/config/Loader/GlobFileLoader.php
new file mode 100644
index 0000000000000000000000000000000000000000..31eebf69d8b159eb3a4694af2476d2c28fc0b7f8
--- /dev/null
+++ b/symfony/config/Loader/GlobFileLoader.php
@@ -0,0 +1,30 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Loader;
+
+/**
+ * GlobFileLoader loads files from a glob pattern.
+ *
+ * @author Fabien Potencier
+ */
+class GlobFileLoader extends FileLoader
+{
+ public function load(mixed $resource, ?string $type = null): mixed
+ {
+ return $this->import($resource);
+ }
+
+ public function supports(mixed $resource, ?string $type = null): bool
+ {
+ return 'glob' === $type;
+ }
+}
diff --git a/symfony/config/Loader/Loader.php b/symfony/config/Loader/Loader.php
new file mode 100644
index 0000000000000000000000000000000000000000..28e5877bf22f093168ba10e02136411353a8a288
--- /dev/null
+++ b/symfony/config/Loader/Loader.php
@@ -0,0 +1,72 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Loader;
+
+use Symfony\Component\Config\Exception\LoaderLoadException;
+use Symfony\Component\Config\Exception\LogicException;
+
+/**
+ * Loader is the abstract class used by all built-in loaders.
+ *
+ * @author Fabien Potencier
+ */
+abstract class Loader implements LoaderInterface
+{
+ protected ?LoaderResolverInterface $resolver = null;
+
+ public function __construct(
+ protected ?string $env = null,
+ ) {
+ }
+
+ public function getResolver(): LoaderResolverInterface
+ {
+ if (null === $this->resolver) {
+ throw new LogicException('Cannot get a resolver if none was set.');
+ }
+
+ return $this->resolver;
+ }
+
+ public function setResolver(LoaderResolverInterface $resolver): void
+ {
+ $this->resolver = $resolver;
+ }
+
+ /**
+ * Imports a resource.
+ */
+ public function import(mixed $resource, ?string $type = null): mixed
+ {
+ return $this->resolve($resource, $type)->load($resource, $type);
+ }
+
+ /**
+ * Finds a loader able to load an imported resource.
+ *
+ * @throws LoaderLoadException If no loader is found
+ */
+ public function resolve(mixed $resource, ?string $type = null): LoaderInterface
+ {
+ if ($this->supports($resource, $type)) {
+ return $this;
+ }
+
+ $loader = null === $this->resolver ? false : $this->resolver->resolve($resource, $type);
+
+ if (false === $loader) {
+ throw new LoaderLoadException($resource, null, 0, null, $type);
+ }
+
+ return $loader;
+ }
+}
diff --git a/symfony/config/Loader/LoaderInterface.php b/symfony/config/Loader/LoaderInterface.php
new file mode 100644
index 0000000000000000000000000000000000000000..6ed1893a53ae4b5d6d530a928e67033693078abb
--- /dev/null
+++ b/symfony/config/Loader/LoaderInterface.php
@@ -0,0 +1,44 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Loader;
+
+/**
+ * LoaderInterface is the interface implemented by all loader classes.
+ *
+ * @author Fabien Potencier
+ */
+interface LoaderInterface
+{
+ /**
+ * Loads a resource.
+ *
+ * @throws \Exception If something went wrong
+ */
+ public function load(mixed $resource, ?string $type = null): mixed;
+
+ /**
+ * Returns whether this class supports the given resource.
+ *
+ * @param mixed $resource A resource
+ */
+ public function supports(mixed $resource, ?string $type = null): bool;
+
+ /**
+ * Gets the loader resolver.
+ */
+ public function getResolver(): LoaderResolverInterface;
+
+ /**
+ * Sets the loader resolver.
+ */
+ public function setResolver(LoaderResolverInterface $resolver): void;
+}
diff --git a/symfony/config/Loader/LoaderResolver.php b/symfony/config/Loader/LoaderResolver.php
new file mode 100644
index 0000000000000000000000000000000000000000..8308d7e895c0b3815ac0cb09c6a48800b810719c
--- /dev/null
+++ b/symfony/config/Loader/LoaderResolver.php
@@ -0,0 +1,65 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Loader;
+
+/**
+ * LoaderResolver selects a loader for a given resource.
+ *
+ * A resource can be anything (e.g. a full path to a config file or a Closure).
+ * Each loader determines whether it can load a resource and how.
+ *
+ * @author Fabien Potencier
+ */
+class LoaderResolver implements LoaderResolverInterface
+{
+ /**
+ * @var LoaderInterface[] An array of LoaderInterface objects
+ */
+ private array $loaders = [];
+
+ /**
+ * @param LoaderInterface[] $loaders An array of loaders
+ */
+ public function __construct(array $loaders = [])
+ {
+ foreach ($loaders as $loader) {
+ $this->addLoader($loader);
+ }
+ }
+
+ public function resolve(mixed $resource, ?string $type = null): LoaderInterface|false
+ {
+ foreach ($this->loaders as $loader) {
+ if ($loader->supports($resource, $type)) {
+ return $loader;
+ }
+ }
+
+ return false;
+ }
+
+ public function addLoader(LoaderInterface $loader): void
+ {
+ $this->loaders[] = $loader;
+ $loader->setResolver($this);
+ }
+
+ /**
+ * Returns the registered loaders.
+ *
+ * @return LoaderInterface[]
+ */
+ public function getLoaders(): array
+ {
+ return $this->loaders;
+ }
+}
diff --git a/symfony/config/Loader/LoaderResolverInterface.php b/symfony/config/Loader/LoaderResolverInterface.php
new file mode 100644
index 0000000000000000000000000000000000000000..a8bb3a43766f4546349096d7f1172c6d08fd534b
--- /dev/null
+++ b/symfony/config/Loader/LoaderResolverInterface.php
@@ -0,0 +1,27 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Loader;
+
+/**
+ * LoaderResolverInterface selects a loader for a given resource.
+ *
+ * @author Fabien Potencier
+ */
+interface LoaderResolverInterface
+{
+ /**
+ * Returns a loader able to load the resource.
+ *
+ * @param string|null $type The resource type or null if unknown
+ */
+ public function resolve(mixed $resource, ?string $type = null): LoaderInterface|false;
+}
diff --git a/symfony/config/Loader/ParamConfigurator.php b/symfony/config/Loader/ParamConfigurator.php
new file mode 100644
index 0000000000000000000000000000000000000000..ed1045270f724591b088273aafcf545fab79b891
--- /dev/null
+++ b/symfony/config/Loader/ParamConfigurator.php
@@ -0,0 +1,30 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Loader;
+
+/**
+ * Placeholder for a parameter.
+ *
+ * @author Tobias Nyholm
+ */
+class ParamConfigurator
+{
+ public function __construct(
+ private string $name,
+ ) {
+ }
+
+ public function __toString(): string
+ {
+ return '%'.$this->name.'%';
+ }
+}
diff --git a/symfony/config/README.md b/symfony/config/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..10c2ddd05831b1213371ef35c3c83621b5ec1979
--- /dev/null
+++ b/symfony/config/README.md
@@ -0,0 +1,15 @@
+Config Component
+================
+
+The Config component helps find, load, combine, autofill and validate
+configuration values of any kind, whatever their source may be (YAML, XML, INI
+files, or for instance a database).
+
+Resources
+---------
+
+ * [Documentation](https://symfony.com/doc/current/components/config.html)
+ * [Contributing](https://symfony.com/doc/current/contributing/index.html)
+ * [Report issues](https://github.com/symfony/symfony/issues) and
+ [send Pull Requests](https://github.com/symfony/symfony/pulls)
+ in the [main Symfony repository](https://github.com/symfony/symfony)
diff --git a/symfony/config/Resource/ClassExistenceResource.php b/symfony/config/Resource/ClassExistenceResource.php
new file mode 100644
index 0000000000000000000000000000000000000000..6973220f087b85e2b0a639ab2e53762169dd78a2
--- /dev/null
+++ b/symfony/config/Resource/ClassExistenceResource.php
@@ -0,0 +1,227 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Resource;
+
+/**
+ * ClassExistenceResource represents a class existence.
+ * Freshness is only evaluated against resource existence.
+ *
+ * The resource must be a fully-qualified class name.
+ *
+ * @author Fabien Potencier
+ *
+ * @final
+ */
+class ClassExistenceResource implements SelfCheckingResourceInterface
+{
+ private ?array $exists = null;
+
+ private static int $autoloadLevel = 0;
+ private static ?string $autoloadedClass = null;
+ private static array $existsCache = [];
+
+ /**
+ * @param string $resource The fully-qualified class name
+ * @param bool|null $exists Boolean when the existence check has already been done
+ */
+ public function __construct(
+ private string $resource,
+ ?bool $exists = null,
+ ) {
+ if (null !== $exists) {
+ $this->exists = [$exists, null];
+ }
+ }
+
+ public function __toString(): string
+ {
+ return $this->resource;
+ }
+
+ public function getResource(): string
+ {
+ return $this->resource;
+ }
+
+ /**
+ * @throws \ReflectionException when a parent class/interface/trait is not found
+ */
+ public function isFresh(int $timestamp): bool
+ {
+ $loaded = class_exists($this->resource, false) || interface_exists($this->resource, false) || trait_exists($this->resource, false);
+
+ if (null !== $exists = &self::$existsCache[$this->resource]) {
+ if ($loaded) {
+ $exists = [true, null];
+ } elseif (0 >= $timestamp && !$exists[0] && null !== $exists[1]) {
+ throw new \ReflectionException($exists[1]);
+ }
+ } elseif ([false, null] === $exists = [$loaded, null]) {
+ if (!self::$autoloadLevel++) {
+ spl_autoload_register(__CLASS__.'::throwOnRequiredClass');
+ }
+ $autoloadedClass = self::$autoloadedClass;
+ self::$autoloadedClass = ltrim($this->resource, '\\');
+
+ try {
+ $exists[0] = class_exists($this->resource) || interface_exists($this->resource, false) || trait_exists($this->resource, false);
+ } catch (\Exception $e) {
+ $exists[1] = $e->getMessage();
+
+ try {
+ self::throwOnRequiredClass($this->resource, $e);
+ } catch (\ReflectionException $e) {
+ if (0 >= $timestamp) {
+ throw $e;
+ }
+ }
+ } catch (\Throwable $e) {
+ $exists[1] = $e->getMessage();
+
+ throw $e;
+ } finally {
+ self::$autoloadedClass = $autoloadedClass;
+ if (!--self::$autoloadLevel) {
+ spl_autoload_unregister(__CLASS__.'::throwOnRequiredClass');
+ }
+ }
+ }
+
+ $this->exists ??= $exists;
+
+ return $this->exists[0] xor !$exists[0];
+ }
+
+ public function __serialize(): array
+ {
+ if (null === $this->exists) {
+ $this->isFresh(0);
+ }
+
+ return [
+ 'resource' => $this->resource,
+ 'exists' => $this->exists,
+ ];
+ }
+
+ public function __unserialize(array $data): void
+ {
+ $this->resource = array_shift($data);
+ $this->exists = array_shift($data);
+
+ if (\is_bool($this->exists)) {
+ $this->exists = [$this->exists, null];
+ }
+ }
+
+ /**
+ * Throws a reflection exception when the passed class does not exist but is required.
+ *
+ * A class is considered "not required" when it's loaded as part of a "class_exists" or similar check.
+ *
+ * This function can be used as an autoload function to throw a reflection
+ * exception if the class was not found by previous autoload functions.
+ *
+ * A previous exception can be passed. In this case, the class is considered as being
+ * required totally, so if it doesn't exist, a reflection exception is always thrown.
+ * If it exists, the previous exception is rethrown.
+ *
+ * @throws \ReflectionException
+ *
+ * @internal
+ */
+ public static function throwOnRequiredClass(string $class, ?\Exception $previous = null): void
+ {
+ // If the passed class is the resource being checked, we shouldn't throw.
+ if (null === $previous && self::$autoloadedClass === $class) {
+ return;
+ }
+
+ if (class_exists($class, false) || interface_exists($class, false) || trait_exists($class, false)) {
+ if (null !== $previous) {
+ throw $previous;
+ }
+
+ return;
+ }
+
+ if ($previous instanceof \ReflectionException) {
+ throw $previous;
+ }
+
+ $message = \sprintf('Class "%s" not found.', $class);
+
+ if ($class !== (self::$autoloadedClass ?? $class)) {
+ $message = substr_replace($message, \sprintf(' while loading "%s"', self::$autoloadedClass), -1, 0);
+ }
+
+ if (null !== $previous) {
+ $message = $previous->getMessage();
+ }
+
+ $e = new \ReflectionException($message, 0, $previous);
+
+ if (null !== $previous) {
+ throw $e;
+ }
+
+ $trace = debug_backtrace();
+ $autoloadFrame = [
+ 'function' => 'spl_autoload_call',
+ 'args' => [$class],
+ ];
+
+ if (isset($trace[1])) {
+ $callerFrame = $trace[1];
+ $i = 2;
+ } elseif (false !== $i = array_search($autoloadFrame, $trace, true)) {
+ $callerFrame = $trace[++$i];
+ } else {
+ throw $e;
+ }
+
+ if (isset($callerFrame['function']) && !isset($callerFrame['class'])) {
+ switch ($callerFrame['function']) {
+ case 'get_class_methods':
+ case 'get_class_vars':
+ case 'get_parent_class':
+ case 'is_a':
+ case 'is_subclass_of':
+ case 'class_exists':
+ case 'class_implements':
+ case 'class_parents':
+ case 'trait_exists':
+ case 'defined':
+ case 'interface_exists':
+ case 'method_exists':
+ case 'property_exists':
+ case 'is_callable':
+ return;
+ }
+
+ $props = [
+ 'file' => $callerFrame['file'] ?? null,
+ 'line' => $callerFrame['line'] ?? null,
+ 'trace' => \array_slice($trace, 1 + $i),
+ ];
+
+ foreach ($props as $p => $v) {
+ if (null !== $v) {
+ $r = new \ReflectionProperty(\Exception::class, $p);
+ $r->setValue($e, $v);
+ }
+ }
+ }
+
+ throw $e;
+ }
+}
diff --git a/symfony/config/Resource/ComposerResource.php b/symfony/config/Resource/ComposerResource.php
new file mode 100644
index 0000000000000000000000000000000000000000..4979f8d9e6c97d109057f02dda6bd8877f1e0c89
--- /dev/null
+++ b/symfony/config/Resource/ComposerResource.php
@@ -0,0 +1,71 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Resource;
+
+/**
+ * ComposerResource tracks the PHP version and Composer dependencies.
+ *
+ * @author Nicolas Grekas
+ *
+ * @final
+ */
+class ComposerResource implements SelfCheckingResourceInterface
+{
+ private array $vendors;
+
+ private static array $runtimeVendors;
+
+ public function __construct()
+ {
+ self::refresh();
+ $this->vendors = self::$runtimeVendors;
+ }
+
+ public function getVendors(): array
+ {
+ return array_keys($this->vendors);
+ }
+
+ public function __toString(): string
+ {
+ return __CLASS__;
+ }
+
+ public function isFresh(int $timestamp): bool
+ {
+ self::refresh();
+
+ return array_values(self::$runtimeVendors) === array_values($this->vendors);
+ }
+
+ public function __serialize(): array
+ {
+ return [
+ 'vendors' => $this->vendors,
+ ];
+ }
+
+ private static function refresh(): void
+ {
+ self::$runtimeVendors = [];
+
+ foreach (get_declared_classes() as $class) {
+ if ('C' === $class[0] && str_starts_with($class, 'ComposerAutoloaderInit')) {
+ $r = new \ReflectionClass($class);
+ $v = \dirname($r->getFileName(), 2);
+ if (is_file($v.'/composer/installed.json')) {
+ self::$runtimeVendors[$v] = @filemtime($v.'/composer/installed.json');
+ }
+ }
+ }
+ }
+}
diff --git a/symfony/config/Resource/DirectoryResource.php b/symfony/config/Resource/DirectoryResource.php
new file mode 100644
index 0000000000000000000000000000000000000000..3451ca4805ea316da4390e3cb1c3479c7eeff919
--- /dev/null
+++ b/symfony/config/Resource/DirectoryResource.php
@@ -0,0 +1,104 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Resource;
+
+/**
+ * DirectoryResource represents a resources stored in a subdirectory tree.
+ *
+ * @author Fabien Potencier
+ *
+ * @final
+ */
+class DirectoryResource implements SelfCheckingResourceInterface
+{
+ private string $resource;
+
+ /**
+ * @param string $resource The file path to the resource
+ * @param string|null $pattern A pattern to restrict monitored files
+ *
+ * @throws \InvalidArgumentException
+ */
+ public function __construct(
+ string $resource,
+ private ?string $pattern = null,
+ ) {
+ $resolvedResource = realpath($resource) ?: (file_exists($resource) ? $resource : false);
+
+ if (false === $resolvedResource || !is_dir($resolvedResource)) {
+ throw new \InvalidArgumentException(\sprintf('The directory "%s" does not exist.', $resource));
+ }
+
+ $this->resource = $resolvedResource;
+ }
+
+ public function __toString(): string
+ {
+ return hash('xxh128', serialize([$this->resource, $this->pattern]));
+ }
+
+ public function getResource(): string
+ {
+ return $this->resource;
+ }
+
+ public function getPattern(): ?string
+ {
+ return $this->pattern;
+ }
+
+ public function isFresh(int $timestamp): bool
+ {
+ if (!is_dir($this->resource)) {
+ return false;
+ }
+
+ if ($timestamp < filemtime($this->resource)) {
+ return false;
+ }
+
+ foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->resource), \RecursiveIteratorIterator::SELF_FIRST) as $file) {
+ // if regex filtering is enabled only check matching files
+ if ($this->pattern && $file->isFile() && !preg_match($this->pattern, $file->getBasename())) {
+ continue;
+ }
+
+ // always monitor directories for changes, except the .. entries
+ // (otherwise deleted files wouldn't get detected)
+ if ($file->isDir() && str_ends_with($file, '/..')) {
+ continue;
+ }
+
+ // for broken links
+ try {
+ $fileMTime = $file->getMTime();
+ } catch (\RuntimeException) {
+ continue;
+ }
+
+ // early return if a file's mtime exceeds the passed timestamp
+ if ($timestamp < $fileMTime) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ public function __serialize(): array
+ {
+ return [
+ 'resource' => $this->resource,
+ 'pattern' => $this->pattern,
+ ];
+ }
+}
diff --git a/symfony/config/Resource/FileExistenceResource.php b/symfony/config/Resource/FileExistenceResource.php
new file mode 100644
index 0000000000000000000000000000000000000000..5eadb54be7a573c8da72ef209fe0aff0150ca039
--- /dev/null
+++ b/symfony/config/Resource/FileExistenceResource.php
@@ -0,0 +1,59 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Resource;
+
+/**
+ * FileExistenceResource represents a resource stored on the filesystem.
+ * Freshness is only evaluated against resource creation or deletion.
+ *
+ * The resource can be a file or a directory.
+ *
+ * @author Charles-Henri Bruyand
+ *
+ * @final
+ */
+class FileExistenceResource implements SelfCheckingResourceInterface
+{
+ private bool $exists;
+
+ /**
+ * @param string $resource The file path to the resource
+ */
+ public function __construct(
+ private string $resource,
+ ) {
+ $this->exists = file_exists($resource);
+ }
+
+ public function __toString(): string
+ {
+ return 'existence.'.$this->resource;
+ }
+
+ public function getResource(): string
+ {
+ return $this->resource;
+ }
+
+ public function isFresh(int $timestamp): bool
+ {
+ return file_exists($this->resource) === $this->exists;
+ }
+
+ public function __serialize(): array
+ {
+ return [
+ 'resource' => $this->resource,
+ 'exists' => $this->exists,
+ ];
+ }
+}
diff --git a/symfony/config/Resource/FileResource.php b/symfony/config/Resource/FileResource.php
new file mode 100644
index 0000000000000000000000000000000000000000..08619536d3c915874b3f1df8c7366362ffd99e03
--- /dev/null
+++ b/symfony/config/Resource/FileResource.php
@@ -0,0 +1,67 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Resource;
+
+/**
+ * FileResource represents a resource stored on the filesystem.
+ *
+ * The resource can be a file or a directory.
+ *
+ * @author Fabien Potencier
+ *
+ * @final
+ */
+class FileResource implements SelfCheckingResourceInterface
+{
+ private string $resource;
+
+ /**
+ * @param string $resource The file path to the resource
+ *
+ * @throws \InvalidArgumentException
+ */
+ public function __construct(string $resource)
+ {
+ $resolvedResource = realpath($resource) ?: (file_exists($resource) ? $resource : false);
+
+ if (false === $resolvedResource) {
+ throw new \InvalidArgumentException(\sprintf('The file "%s" does not exist.', $resource));
+ }
+
+ $this->resource = $resolvedResource;
+ }
+
+ public function __toString(): string
+ {
+ return $this->resource;
+ }
+
+ /**
+ * Returns the canonicalized, absolute path to the resource.
+ */
+ public function getResource(): string
+ {
+ return $this->resource;
+ }
+
+ public function isFresh(int $timestamp): bool
+ {
+ return false !== ($filemtime = @filemtime($this->resource)) && $filemtime <= $timestamp;
+ }
+
+ public function __serialize(): array
+ {
+ return [
+ 'resource' => $this->resource,
+ ];
+ }
+}
diff --git a/symfony/config/Resource/GlobResource.php b/symfony/config/Resource/GlobResource.php
new file mode 100644
index 0000000000000000000000000000000000000000..f94c1cb1721b8c27d5678dcccdd5ed8f0ef94759
--- /dev/null
+++ b/symfony/config/Resource/GlobResource.php
@@ -0,0 +1,255 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Resource;
+
+use Symfony\Component\Finder\Finder;
+use Symfony\Component\Finder\Glob;
+
+/**
+ * GlobResource represents a set of resources stored on the filesystem.
+ *
+ * Only existence/removal is tracked (not mtimes.)
+ *
+ * @author Nicolas Grekas
+ *
+ * @final
+ *
+ * @implements \IteratorAggregate
+ */
+class GlobResource implements \IteratorAggregate, SelfCheckingResourceInterface
+{
+ private string $prefix;
+ private string $hash;
+ private array $excludedPrefixes;
+ private int $globBrace;
+
+ /**
+ * @param string $prefix A directory prefix
+ * @param string $pattern A glob pattern
+ * @param bool $recursive Whether directories should be scanned recursively or not
+ *
+ * @throws \InvalidArgumentException
+ */
+ public function __construct(
+ string $prefix,
+ private string $pattern,
+ private bool $recursive,
+ private bool $forExclusion = false,
+ array $excludedPrefixes = [],
+ ) {
+ ksort($excludedPrefixes);
+ $resolvedPrefix = realpath($prefix) ?: (file_exists($prefix) ? $prefix : false);
+ $this->excludedPrefixes = $excludedPrefixes;
+ $this->globBrace = \defined('GLOB_BRACE') ? \GLOB_BRACE : 0;
+
+ if (false === $resolvedPrefix) {
+ throw new \InvalidArgumentException(\sprintf('The path "%s" does not exist.', $prefix));
+ }
+
+ $this->prefix = $resolvedPrefix;
+ }
+
+ public function getPrefix(): string
+ {
+ return $this->prefix;
+ }
+
+ public function __toString(): string
+ {
+ return 'glob.'.$this->prefix.(int) $this->recursive.$this->pattern.(int) $this->forExclusion.implode("\0", $this->excludedPrefixes);
+ }
+
+ public function isFresh(int $timestamp): bool
+ {
+ $hash = $this->computeHash();
+ $this->hash ??= $hash;
+
+ return $this->hash === $hash;
+ }
+
+ public function __serialize(): array
+ {
+ $this->hash ??= $this->computeHash();
+
+ return [
+ 'prefix' => $this->prefix,
+ 'pattern' => $this->pattern,
+ 'recursive' => $this->recursive,
+ 'hash' => $this->hash,
+ 'forExclusion' => $this->forExclusion,
+ 'excludedPrefixes' => $this->excludedPrefixes,
+ ];
+ }
+
+ public function __unserialize(array $data): void
+ {
+ $this->prefix = array_shift($data);
+ $this->pattern = array_shift($data);
+ $this->recursive = array_shift($data);
+ $this->hash = array_shift($data);
+ $this->forExclusion = array_shift($data);
+ $this->excludedPrefixes = array_shift($data);
+ $this->globBrace = \defined('GLOB_BRACE') ? \GLOB_BRACE : 0;
+ }
+
+ public function getIterator(): \Traversable
+ {
+ if ((!$this->recursive && '' === $this->pattern) || !file_exists($this->prefix)) {
+ return;
+ }
+
+ if (is_file($prefix = str_replace('\\', '/', $this->prefix))) {
+ $prefix = \dirname($prefix);
+ $pattern = basename($prefix).$this->pattern;
+ } else {
+ $pattern = $this->pattern;
+ }
+
+ if (class_exists(Finder::class)) {
+ $regex = Glob::toRegex($pattern);
+ if ($this->recursive) {
+ $regex = substr_replace($regex, str_ends_with($pattern, '/') ? '' : '(/|$)', -2, 1);
+ }
+ } else {
+ $regex = null;
+ }
+
+ $prefixLen = \strlen($prefix);
+ $paths = null;
+
+ if ('' === $this->pattern && is_file($this->prefix)) {
+ $paths = [$this->prefix => null];
+ } elseif (!str_starts_with($this->prefix, 'phar://') && (null !== $regex || !str_contains($this->pattern, '/**/'))) {
+ if (!str_contains($this->pattern, '/**/') && ($this->globBrace || !str_contains($this->pattern, '{'))) {
+ $paths = array_fill_keys(glob($this->prefix.$this->pattern, \GLOB_NOSORT | $this->globBrace), null);
+ } elseif (!str_contains($this->pattern, '\\') || !preg_match('/\\\\[,{}]/', $this->pattern)) {
+ $paths = [];
+ foreach ($this->expandGlob($this->pattern) as $p) {
+ if (false !== $i = strpos($p, '/**/')) {
+ $p = substr_replace($p, '/*', $i);
+ }
+ $paths += array_fill_keys(glob($this->prefix.$p, \GLOB_NOSORT), false !== $i ? $regex : null);
+ }
+ }
+ }
+
+ if (null !== $paths) {
+ uksort($paths, 'strnatcmp');
+ foreach ($paths as $path => $regex) {
+ if ($this->excludedPrefixes) {
+ $normalizedPath = str_replace('\\', '/', $path);
+ do {
+ if (isset($this->excludedPrefixes[$dirPath = $normalizedPath])) {
+ continue 2;
+ }
+ } while ($prefix !== $dirPath && $dirPath !== $normalizedPath = \dirname($dirPath));
+ }
+
+ if ((null === $regex || preg_match($regex, substr(str_replace('\\', '/', $path), $prefixLen))) && is_file($path)) {
+ yield $path => new \SplFileInfo($path);
+ }
+ if (!is_dir($path)) {
+ continue;
+ }
+ if ($this->forExclusion && (null === $regex || preg_match($regex, substr(str_replace('\\', '/', $path), $prefixLen)))) {
+ yield $path => new \SplFileInfo($path);
+ continue;
+ }
+ if (!($this->recursive || null !== $regex) || isset($this->excludedPrefixes[str_replace('\\', '/', $path)])) {
+ continue;
+ }
+ $files = iterator_to_array(new \RecursiveIteratorIterator(
+ new \RecursiveCallbackFilterIterator(
+ new \RecursiveDirectoryIterator($path, \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS),
+ fn (\SplFileInfo $file, $path) => !isset($this->excludedPrefixes[$path = str_replace('\\', '/', $path)])
+ && (null === $regex || preg_match($regex, substr($path, $prefixLen)) || $file->isDir())
+ && '.' !== $file->getBasename()[0]
+ ),
+ \RecursiveIteratorIterator::LEAVES_ONLY
+ ));
+ uksort($files, 'strnatcmp');
+
+ foreach ($files as $path => $info) {
+ if ($info->isFile()) {
+ yield $path => $info;
+ }
+ }
+ }
+
+ return;
+ }
+
+ if (!class_exists(Finder::class)) {
+ throw new \LogicException('Extended glob patterns cannot be used as the Finder component is not installed. Try running "composer require symfony/finder".');
+ }
+
+ yield from (new Finder())
+ ->followLinks()
+ ->filter(function (\SplFileInfo $info) use ($regex, $prefixLen, $prefix) {
+ $normalizedPath = str_replace('\\', '/', $info->getPathname());
+ if (!preg_match($regex, substr($normalizedPath, $prefixLen)) || !$info->isFile()) {
+ return false;
+ }
+ if ($this->excludedPrefixes) {
+ do {
+ if (isset($this->excludedPrefixes[$dirPath = $normalizedPath])) {
+ return false;
+ }
+ } while ($prefix !== $dirPath && $dirPath !== $normalizedPath = \dirname($dirPath));
+ }
+ })
+ ->sortByName()
+ ->in($prefix)
+ ;
+ }
+
+ private function computeHash(): string
+ {
+ $hash = hash_init('xxh128');
+
+ foreach ($this->getIterator() as $path => $info) {
+ hash_update($hash, $path."\n");
+ }
+
+ return hash_final($hash);
+ }
+
+ private function expandGlob(string $pattern): array
+ {
+ $segments = preg_split('/\{([^{}]*+)\}/', $pattern, -1, \PREG_SPLIT_DELIM_CAPTURE);
+ $paths = [$segments[0]];
+ $patterns = [];
+
+ for ($i = 1; $i < \count($segments); $i += 2) {
+ $patterns = [];
+
+ foreach (explode(',', $segments[$i]) as $s) {
+ foreach ($paths as $p) {
+ $patterns[] = $p.$s.$segments[1 + $i];
+ }
+ }
+
+ $paths = $patterns;
+ }
+
+ $j = 0;
+ foreach ($patterns as $i => $p) {
+ if (str_contains($p, '{')) {
+ $p = $this->expandGlob($p);
+ array_splice($paths, $i + $j, 1, $p);
+ $j += \count($p) - 1;
+ }
+ }
+
+ return $paths;
+ }
+}
diff --git a/symfony/config/Resource/ReflectionClassResource.php b/symfony/config/Resource/ReflectionClassResource.php
new file mode 100644
index 0000000000000000000000000000000000000000..53394b6c32b56bd37d5aee83a2b26e00ea4f5ca7
--- /dev/null
+++ b/symfony/config/Resource/ReflectionClassResource.php
@@ -0,0 +1,215 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Resource;
+
+use Symfony\Component\EventDispatcher\EventSubscriberInterface;
+use Symfony\Contracts\Service\ServiceSubscriberInterface;
+
+/**
+ * @author Nicolas Grekas
+ *
+ * @final
+ */
+class ReflectionClassResource implements SelfCheckingResourceInterface
+{
+ private array $files = [];
+ private string $className;
+ private array $excludedVendors = [];
+ private string $hash;
+
+ public function __construct(
+ private \ReflectionClass $classReflector,
+ array $excludedVendors = [],
+ ) {
+ $this->className = $classReflector->name;
+ $this->excludedVendors = $excludedVendors;
+ }
+
+ public function isFresh(int $timestamp): bool
+ {
+ if (!isset($this->hash)) {
+ $this->hash = $this->computeHash();
+ $this->loadFiles($this->classReflector);
+ }
+
+ foreach ($this->files as $file => $v) {
+ if (false === $filemtime = @filemtime($file)) {
+ return false;
+ }
+
+ if ($filemtime > $timestamp) {
+ return $this->hash === $this->computeHash();
+ }
+ }
+
+ return true;
+ }
+
+ public function __toString(): string
+ {
+ return 'reflection.'.$this->className;
+ }
+
+ public function __serialize(): array
+ {
+ if (!isset($this->hash)) {
+ $this->hash = $this->computeHash();
+ $this->loadFiles($this->classReflector);
+ }
+
+ return [
+ 'files' => $this->files,
+ 'className' => $this->className,
+ 'excludedVendors' => $this->excludedVendors,
+ 'hash' => $this->hash,
+ ];
+ }
+
+ private function loadFiles(\ReflectionClass $class): void
+ {
+ foreach ($class->getInterfaces() as $v) {
+ $this->loadFiles($v);
+ }
+ do {
+ $file = $class->getFileName();
+ if (false !== $file && is_file($file)) {
+ foreach ($this->excludedVendors as $vendor) {
+ if (\in_array($file[\strlen($vendor)] ?? '', ['/', \DIRECTORY_SEPARATOR], true) && str_starts_with($file, $vendor)) {
+ $file = false;
+ break;
+ }
+ }
+ if ($file) {
+ $this->files[$file] = null;
+ }
+ }
+ foreach ($class->getTraits() as $v) {
+ $this->loadFiles($v);
+ }
+ } while ($class = $class->getParentClass());
+ }
+
+ private function computeHash(): string
+ {
+ try {
+ $this->classReflector ??= new \ReflectionClass($this->className);
+ } catch (\ReflectionException) {
+ // the class does not exist anymore
+ return false;
+ }
+ $hash = hash_init('xxh128');
+
+ foreach ($this->generateSignature($this->classReflector) as $info) {
+ hash_update($hash, $info);
+ }
+
+ return hash_final($hash);
+ }
+
+ private function generateSignature(\ReflectionClass $class): iterable
+ {
+ $attributes = [];
+ foreach ($class->getAttributes() as $a) {
+ $attributes[] = [$a->getName(), (string) $a];
+ }
+ yield print_r($attributes, true);
+ $attributes = [];
+
+ yield $class->getDocComment() ?: '';
+ yield (int) $class->isFinal();
+ yield (int) $class->isAbstract();
+
+ if ($class->isTrait()) {
+ yield print_r(class_uses($class->name), true);
+ } else {
+ yield print_r(class_parents($class->name), true);
+ yield print_r(class_implements($class->name), true);
+ yield print_r($class->getConstants(), true);
+ }
+
+ foreach ($class->getReflectionConstants() as $constant) {
+ foreach ($constant->getAttributes() as $a) {
+ $attributes[] = [$a->getName(), (string) $a];
+ }
+ yield $constant->name.print_r($attributes, true);
+ $attributes = [];
+ }
+
+ if (!$class->isInterface()) {
+ $defaults = $class->getDefaultProperties();
+
+ foreach ($class->getProperties(\ReflectionProperty::IS_PUBLIC | \ReflectionProperty::IS_PROTECTED) as $p) {
+ foreach ($p->getAttributes() as $a) {
+ $attributes[] = [$a->getName(), (string) $a];
+ }
+ yield print_r($attributes, true);
+ $attributes = [];
+
+ yield $p->getDocComment() ?: '';
+ yield $p->isDefault() ? '' : '';
+ yield $p->isPublic() ? 'public' : 'protected';
+ yield $p->isStatic() ? 'static' : '';
+ yield '$'.$p->name;
+ yield print_r(isset($defaults[$p->name]) && !\is_object($defaults[$p->name]) ? $defaults[$p->name] : null, true);
+ }
+ }
+
+ foreach ($class->getMethods(\ReflectionMethod::IS_PUBLIC | \ReflectionMethod::IS_PROTECTED) as $m) {
+ foreach ($this->excludedVendors as $vendor) {
+ $file = $m->getFileName();
+ if (\in_array($file[\strlen($vendor)] ?? '', ['/', \DIRECTORY_SEPARATOR], true) && str_starts_with($file, $vendor)) {
+ continue 2;
+ }
+ }
+
+ foreach ($m->getAttributes() as $a) {
+ $attributes[] = [$a->getName(), (string) $a];
+ }
+ yield print_r($attributes, true);
+ $attributes = [];
+
+ $defaults = [];
+ foreach ($m->getParameters() as $p) {
+ foreach ($p->getAttributes() as $a) {
+ $attributes[] = [$a->getName(), (string) $a];
+ }
+ yield print_r($attributes, true);
+ $attributes = [];
+
+ if (!$p->isDefaultValueAvailable()) {
+ $defaults[$p->name] = null;
+
+ continue;
+ }
+
+ $defaults[$p->name] = (string) $p;
+ }
+
+ yield preg_replace('/^ @@.*/m', '', $m);
+ yield print_r($defaults, true);
+ }
+
+ if ($class->isAbstract() || $class->isInterface() || $class->isTrait()) {
+ return;
+ }
+
+ if (interface_exists(EventSubscriberInterface::class, false) && $class->isSubclassOf(EventSubscriberInterface::class)) {
+ yield EventSubscriberInterface::class;
+ yield print_r($class->name::getSubscribedEvents(), true);
+ }
+
+ if (interface_exists(ServiceSubscriberInterface::class, false) && $class->isSubclassOf(ServiceSubscriberInterface::class)) {
+ yield ServiceSubscriberInterface::class;
+ yield print_r($class->name::getSubscribedServices(), true);
+ }
+ }
+}
diff --git a/symfony/config/Resource/ResourceInterface.php b/symfony/config/Resource/ResourceInterface.php
new file mode 100644
index 0000000000000000000000000000000000000000..a97671d1499a27e94ebdaf6fc16968532227a59c
--- /dev/null
+++ b/symfony/config/Resource/ResourceInterface.php
@@ -0,0 +1,31 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Resource;
+
+/**
+ * ResourceInterface is the interface that must be implemented by all Resource classes.
+ *
+ * @author Fabien Potencier
+ */
+interface ResourceInterface extends \Stringable
+{
+ /**
+ * Returns a string representation of the Resource.
+ *
+ * This method is necessary to allow for resource de-duplication, for example by means
+ * of array_unique(). The string returned need not have a particular meaning, but has
+ * to be identical for different ResourceInterface instances referring to the same
+ * resource; and it should be unlikely to collide with that of other, unrelated
+ * resource instances.
+ */
+ public function __toString(): string;
+}
diff --git a/symfony/config/Resource/SelfCheckingResourceChecker.php b/symfony/config/Resource/SelfCheckingResourceChecker.php
new file mode 100644
index 0000000000000000000000000000000000000000..5abdbadd40e79a56f941a0f1f56e1b152ba121af
--- /dev/null
+++ b/symfony/config/Resource/SelfCheckingResourceChecker.php
@@ -0,0 +1,46 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Resource;
+
+use Symfony\Component\Config\ResourceCheckerInterface;
+
+/**
+ * Resource checker for instances of SelfCheckingResourceInterface.
+ *
+ * As these resources perform the actual check themselves, we can provide
+ * this class as a standard way of validating them.
+ *
+ * @author Matthias Pigulla
+ */
+class SelfCheckingResourceChecker implements ResourceCheckerInterface
+{
+ // Common shared cache, because this checker can be used in different
+ // situations. For example, when using the full stack framework, the router
+ // and the container have their own cache. But they may check the very same
+ // resources
+ private static array $cache = [];
+
+ public function supports(ResourceInterface $metadata): bool
+ {
+ return $metadata instanceof SelfCheckingResourceInterface;
+ }
+
+ /**
+ * @param SelfCheckingResourceInterface $resource
+ */
+ public function isFresh(ResourceInterface $resource, int $timestamp): bool
+ {
+ $key = "$resource:$timestamp";
+
+ return self::$cache[$key] ??= $resource->isFresh($timestamp);
+ }
+}
diff --git a/symfony/config/Resource/SelfCheckingResourceInterface.php b/symfony/config/Resource/SelfCheckingResourceInterface.php
new file mode 100644
index 0000000000000000000000000000000000000000..197ff1f9bff57c751bc4b0e0a2525627df104cfd
--- /dev/null
+++ b/symfony/config/Resource/SelfCheckingResourceInterface.php
@@ -0,0 +1,28 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Resource;
+
+/**
+ * Interface for Resources that can check for freshness autonomously,
+ * without special support from external services.
+ *
+ * @author Matthias Pigulla
+ */
+interface SelfCheckingResourceInterface extends ResourceInterface
+{
+ /**
+ * Returns true if the resource has not been updated since the given timestamp.
+ *
+ * @param int $timestamp The last time the resource was loaded
+ */
+ public function isFresh(int $timestamp): bool;
+}
diff --git a/symfony/config/Resource/SkippingResourceChecker.php b/symfony/config/Resource/SkippingResourceChecker.php
new file mode 100644
index 0000000000000000000000000000000000000000..7fad4daf6df1124cc4f0f63fff7913526905e578
--- /dev/null
+++ b/symfony/config/Resource/SkippingResourceChecker.php
@@ -0,0 +1,44 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Resource;
+
+use Symfony\Component\Config\ResourceCheckerInterface;
+
+class SkippingResourceChecker implements ResourceCheckerInterface
+{
+ private array $skippedResourceTypes;
+
+ /**
+ * @param class-string[] $skippedResourceTypes
+ */
+ public function __construct(array $skippedResourceTypes = [])
+ {
+ $this->skippedResourceTypes = array_flip($skippedResourceTypes);
+ }
+
+ public function supports(ResourceInterface $metadata): bool
+ {
+ return !$this->skippedResourceTypes || isset($this->skippedResourceTypes[$metadata::class]);
+ }
+
+ public function isFresh(ResourceInterface $resource, int $timestamp): bool
+ {
+ return true;
+ }
+
+ public function __serialize(): array
+ {
+ return [
+ 'skippedResourceTypes' => $this->skippedResourceTypes,
+ ];
+ }
+}
diff --git a/symfony/config/ResourceCheckerConfigCache.php b/symfony/config/ResourceCheckerConfigCache.php
new file mode 100644
index 0000000000000000000000000000000000000000..9a189cff43f5baf11b6229d3a1662346c8810eee
--- /dev/null
+++ b/symfony/config/ResourceCheckerConfigCache.php
@@ -0,0 +1,183 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config;
+
+use Symfony\Component\Config\Resource\ResourceInterface;
+use Symfony\Component\Filesystem\Exception\IOException;
+use Symfony\Component\Filesystem\Filesystem;
+
+/**
+ * ResourceCheckerConfigCache uses instances of ResourceCheckerInterface
+ * to check whether cached data is still fresh.
+ *
+ * @author Matthias Pigulla
+ */
+class ResourceCheckerConfigCache implements ConfigCacheInterface
+{
+ private string $metaFile;
+
+ /**
+ * @param string $file The absolute cache path
+ * @param iterable $resourceCheckers The ResourceCheckers to use for the freshness check
+ * @param string|null $metaFile The absolute path to the meta file, defaults to $file.meta if null
+ */
+ public function __construct(
+ private string $file,
+ private iterable $resourceCheckers = [],
+ ?string $metaFile = null,
+ ) {
+ $this->metaFile = $metaFile ?? $file.'.meta';
+ }
+
+ public function getPath(): string
+ {
+ return $this->file;
+ }
+
+ /**
+ * Checks if the cache is still fresh.
+ *
+ * This implementation will make a decision solely based on the ResourceCheckers
+ * passed in the constructor.
+ *
+ * The first ResourceChecker that supports a given resource is considered authoritative.
+ * Resources with no matching ResourceChecker will silently be ignored and considered fresh.
+ */
+ public function isFresh(): bool
+ {
+ if (!is_file($this->file)) {
+ return false;
+ }
+
+ if ($this->resourceCheckers instanceof \Traversable && !$this->resourceCheckers instanceof \Countable) {
+ $this->resourceCheckers = iterator_to_array($this->resourceCheckers);
+ }
+
+ if (!\count($this->resourceCheckers)) {
+ return true; // shortcut - if we don't have any checkers we don't need to bother with the meta file at all
+ }
+
+ $metadata = $this->metaFile;
+
+ if (!is_file($metadata)) {
+ return false;
+ }
+
+ $meta = $this->safelyUnserialize($metadata);
+
+ if (false === $meta) {
+ return false;
+ }
+
+ $time = filemtime($this->file);
+
+ foreach ($meta as $resource) {
+ foreach ($this->resourceCheckers as $checker) {
+ if (!$checker->supports($resource)) {
+ continue; // next checker
+ }
+ if ($checker->isFresh($resource, $time)) {
+ break; // no need to further check this resource
+ }
+
+ return false; // cache is stale
+ }
+ // no suitable checker found, ignore this resource
+ }
+
+ return true;
+ }
+
+ /**
+ * Writes cache.
+ *
+ * @param string $content The content to write in the cache
+ * @param ResourceInterface[] $metadata An array of metadata
+ *
+ * @throws \RuntimeException When cache file can't be written
+ */
+ public function write(string $content, ?array $metadata = null): void
+ {
+ $mode = 0o666;
+ $umask = umask();
+ $filesystem = new Filesystem();
+ $filesystem->dumpFile($this->file, $content);
+ try {
+ $filesystem->chmod($this->file, $mode, $umask);
+ } catch (IOException) {
+ // discard chmod failure (some filesystem may not support it)
+ }
+
+ if (null !== $metadata) {
+ $filesystem->dumpFile($this->metaFile, $ser = serialize($metadata));
+ try {
+ $filesystem->chmod($this->metaFile, $mode, $umask);
+ } catch (IOException) {
+ // discard chmod failure (some filesystem may not support it)
+ }
+
+ $ser = preg_replace_callback('/;O:(\d+):"/', static fn ($m) => ';O:'.(9 + $m[1]).':"Tracking\\', $ser);
+ $ser = preg_replace_callback('/s:(\d+):"(\0[^\0]++\0)/', static fn ($m) => 's:'.($m[1] - \strlen($m[2])).':"', $ser);
+ $ser = unserialize($ser, ['allowed_classes' => false]);
+ $ser = @json_encode($ser, \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE) ?: [];
+ $ser = str_replace('"__PHP_Incomplete_Class_Name":"Tracking\\\\', '"@type":"', $ser);
+ $ser = \sprintf('{"resources":%s}', $ser);
+
+ $filesystem->dumpFile($this->metaFile.'.json', $ser);
+ try {
+ $filesystem->chmod($this->metaFile.'.json', $mode, $umask);
+ } catch (IOException) {
+ // discard chmod failure (some filesystem may not support it)
+ }
+ }
+
+ if (\function_exists('opcache_invalidate') && filter_var(\ini_get('opcache.enable'), \FILTER_VALIDATE_BOOL)) {
+ @opcache_invalidate($this->file, true);
+ }
+ }
+
+ private function safelyUnserialize(string $file): mixed
+ {
+ $meta = false;
+ $content = (new Filesystem())->readFile($file);
+ $signalingException = new \UnexpectedValueException();
+ $prevUnserializeHandler = ini_set('unserialize_callback_func', self::class.'::handleUnserializeCallback');
+ $prevErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = []) use (&$prevErrorHandler, $signalingException) {
+ if (__FILE__ === $file && !\in_array($type, [\E_DEPRECATED, \E_USER_DEPRECATED], true)) {
+ throw $signalingException;
+ }
+
+ return $prevErrorHandler ? $prevErrorHandler($type, $msg, $file, $line, $context) : false;
+ });
+
+ try {
+ $meta = unserialize($content);
+ } catch (\Throwable $e) {
+ if ($e !== $signalingException) {
+ throw $e;
+ }
+ } finally {
+ restore_error_handler();
+ ini_set('unserialize_callback_func', $prevUnserializeHandler);
+ }
+
+ return $meta;
+ }
+
+ /**
+ * @internal
+ */
+ public static function handleUnserializeCallback(string $class): void
+ {
+ trigger_error('Class not found: '.$class);
+ }
+}
diff --git a/symfony/config/ResourceCheckerConfigCacheFactory.php b/symfony/config/ResourceCheckerConfigCacheFactory.php
new file mode 100644
index 0000000000000000000000000000000000000000..595855ccb4c84f1ee5fff3e969a11399df99e3a2
--- /dev/null
+++ b/symfony/config/ResourceCheckerConfigCacheFactory.php
@@ -0,0 +1,39 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config;
+
+/**
+ * A ConfigCacheFactory implementation that validates the
+ * cache with an arbitrary set of ResourceCheckers.
+ *
+ * @author Matthias Pigulla
+ */
+class ResourceCheckerConfigCacheFactory implements ConfigCacheFactoryInterface
+{
+ /**
+ * @param iterable $resourceCheckers
+ */
+ public function __construct(
+ private iterable $resourceCheckers = [],
+ ) {
+ }
+
+ public function cache(string $file, callable $callable): ConfigCacheInterface
+ {
+ $cache = new ResourceCheckerConfigCache($file, $this->resourceCheckers);
+ if (!$cache->isFresh()) {
+ $callable($cache);
+ }
+
+ return $cache;
+ }
+}
diff --git a/symfony/config/ResourceCheckerInterface.php b/symfony/config/ResourceCheckerInterface.php
new file mode 100644
index 0000000000000000000000000000000000000000..13ae03f454dc728ffa7ef83f9ffe2fe0bd283680
--- /dev/null
+++ b/symfony/config/ResourceCheckerInterface.php
@@ -0,0 +1,41 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config;
+
+use Symfony\Component\Config\Resource\ResourceInterface;
+
+/**
+ * Interface for ResourceCheckers.
+ *
+ * When a ResourceCheckerConfigCache instance is checked for freshness, all its associated
+ * metadata resources are passed to ResourceCheckers. The ResourceCheckers
+ * can then inspect the resources and decide whether the cache can be considered
+ * fresh or not.
+ *
+ * @author Matthias Pigulla
+ * @author Benjamin Klotz
+ */
+interface ResourceCheckerInterface
+{
+ /**
+ * Queries the ResourceChecker whether it can validate a given
+ * resource or not.
+ */
+ public function supports(ResourceInterface $metadata): bool;
+
+ /**
+ * Validates the resource.
+ *
+ * @param int $timestamp The timestamp at which the cache associated with this resource was created
+ */
+ public function isFresh(ResourceInterface $resource, int $timestamp): bool;
+}
diff --git a/symfony/config/Util/Exception/InvalidXmlException.php b/symfony/config/Util/Exception/InvalidXmlException.php
new file mode 100644
index 0000000000000000000000000000000000000000..155571cecb969d5c4e1e817e441dd627a7960a6e
--- /dev/null
+++ b/symfony/config/Util/Exception/InvalidXmlException.php
@@ -0,0 +1,22 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Util\Exception;
+
+/**
+ * Exception class for when XML parsing with an XSD schema file path or a callable validator produces errors unrelated
+ * to the actual XML parsing.
+ *
+ * @author Ole Rößner
+ */
+class InvalidXmlException extends XmlParsingException
+{
+}
diff --git a/symfony/config/Util/Exception/XmlParsingException.php b/symfony/config/Util/Exception/XmlParsingException.php
new file mode 100644
index 0000000000000000000000000000000000000000..9bceed660baede3fc8c7c4c121df4c87c8b3d82b
--- /dev/null
+++ b/symfony/config/Util/Exception/XmlParsingException.php
@@ -0,0 +1,21 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Util\Exception;
+
+/**
+ * Exception class for when XML cannot be parsed properly.
+ *
+ * @author Ole Rößner
+ */
+class XmlParsingException extends \InvalidArgumentException
+{
+}
diff --git a/symfony/config/Util/XmlUtils.php b/symfony/config/Util/XmlUtils.php
new file mode 100644
index 0000000000000000000000000000000000000000..02ebe7dbe28cd00ff6d2d0fab1dc22eb89da0f00
--- /dev/null
+++ b/symfony/config/Util/XmlUtils.php
@@ -0,0 +1,270 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Config\Util;
+
+use Symfony\Component\Config\Util\Exception\InvalidXmlException;
+use Symfony\Component\Config\Util\Exception\XmlParsingException;
+use Symfony\Component\Filesystem\Filesystem;
+
+/**
+ * XMLUtils is a bunch of utility methods to XML operations.
+ *
+ * This class contains static methods only and is not meant to be instantiated.
+ *
+ * @author Fabien Potencier
+ * @author Martin Hasoň
+ * @author Ole Rößner
+ */
+class XmlUtils
+{
+ /**
+ * This class should not be instantiated.
+ */
+ private function __construct()
+ {
+ }
+
+ /**
+ * Parses an XML string.
+ *
+ * @param string $content An XML string
+ * @param string|callable|null $schemaOrCallable An XSD schema file path, a callable, or null to disable validation
+ *
+ * @throws XmlParsingException When parsing of XML file returns error
+ * @throws InvalidXmlException When parsing of XML with schema or callable produces any errors unrelated to the XML parsing itself
+ * @throws \RuntimeException When DOM extension is missing
+ */
+ public static function parse(string $content, string|callable|null $schemaOrCallable = null): \DOMDocument
+ {
+ if (!\extension_loaded('dom')) {
+ throw new \LogicException('Extension DOM is required.');
+ }
+
+ $internalErrors = libxml_use_internal_errors(true);
+ libxml_clear_errors();
+
+ $dom = new \DOMDocument();
+ $dom->validateOnParse = true;
+ if (!$dom->loadXML($content, \LIBXML_NONET | \LIBXML_COMPACT)) {
+ throw new XmlParsingException(implode("\n", static::getXmlErrors($internalErrors)));
+ }
+
+ $dom->normalizeDocument();
+
+ libxml_use_internal_errors($internalErrors);
+
+ foreach ($dom->childNodes as $child) {
+ if (\XML_DOCUMENT_TYPE_NODE === $child->nodeType) {
+ throw new XmlParsingException('Document types are not allowed.');
+ }
+ }
+
+ if (null !== $schemaOrCallable) {
+ $internalErrors = libxml_use_internal_errors(true);
+ libxml_clear_errors();
+
+ $e = null;
+ if (\is_callable($schemaOrCallable)) {
+ try {
+ $valid = $schemaOrCallable($dom, $internalErrors);
+ } catch (\Exception $e) {
+ $valid = false;
+ }
+ } elseif (is_file($schemaOrCallable)) {
+ $schemaSource = (new Filesystem())->readFile($schemaOrCallable);
+ $valid = @$dom->schemaValidateSource($schemaSource);
+ } else {
+ libxml_use_internal_errors($internalErrors);
+
+ throw new XmlParsingException(\sprintf('Invalid XSD file: "%s".', $schemaOrCallable));
+ }
+
+ if (!$valid) {
+ $messages = static::getXmlErrors($internalErrors);
+ if (!$messages) {
+ throw new InvalidXmlException('The XML is not valid.', 0, $e);
+ }
+ throw new XmlParsingException(implode("\n", $messages), 0, $e);
+ }
+ }
+
+ libxml_clear_errors();
+ libxml_use_internal_errors($internalErrors);
+
+ return $dom;
+ }
+
+ /**
+ * Loads an XML file.
+ *
+ * @param string $file An XML file path
+ * @param string|callable|null $schemaOrCallable An XSD schema file path, a callable, or null to disable validation
+ *
+ * @throws \InvalidArgumentException When loading of XML file returns error
+ * @throws XmlParsingException When XML parsing returns any errors
+ * @throws \RuntimeException When DOM extension is missing
+ */
+ public static function loadFile(string $file, string|callable|null $schemaOrCallable = null): \DOMDocument
+ {
+ if (!is_file($file)) {
+ throw new \InvalidArgumentException(\sprintf('Resource "%s" is not a file.', $file));
+ }
+
+ if (!is_readable($file)) {
+ throw new \InvalidArgumentException(\sprintf('File "%s" is not readable.', $file));
+ }
+
+ $content = (new Filesystem())->readFile($file);
+
+ if ('' === trim($content)) {
+ throw new \InvalidArgumentException(\sprintf('File "%s" does not contain valid XML, it is empty.', $file));
+ }
+
+ try {
+ return static::parse($content, $schemaOrCallable);
+ } catch (InvalidXmlException $e) {
+ throw new XmlParsingException(\sprintf('The XML file "%s" is not valid.', $file), 0, $e->getPrevious());
+ }
+ }
+
+ /**
+ * Converts a \DOMElement object to a PHP array.
+ *
+ * The following rules applies during the conversion:
+ *
+ * * Each tag is converted to a key value or an array
+ * if there is more than one "value"
+ *
+ * * The content of a tag is set under a "value" key (bar)
+ * if the tag also has some nested tags
+ *
+ * * The attributes are converted to keys ()
+ *
+ * * The nested-tags are converted to keys (bar)
+ *
+ * @param \DOMElement $element A \DOMElement instance
+ * @param bool $checkPrefix Check prefix in an element or an attribute name
+ */
+ public static function convertDomElementToArray(\DOMElement $element, bool $checkPrefix = true): mixed
+ {
+ $prefix = $element->prefix;
+ $empty = true;
+ $config = [];
+ foreach ($element->attributes as $name => $node) {
+ if ($checkPrefix && !\in_array((string) $node->prefix, ['', $prefix], true)) {
+ continue;
+ }
+ $config[$name] = static::phpize($node->value);
+ $empty = false;
+ }
+
+ $nodeValue = false;
+ foreach ($element->childNodes as $node) {
+ if ($node instanceof \DOMText) {
+ if ('' !== trim($node->nodeValue)) {
+ $nodeValue = trim($node->nodeValue);
+ $empty = false;
+ }
+ } elseif ($checkPrefix && $prefix != $node->prefix) {
+ continue;
+ } elseif (!$node instanceof \DOMComment) {
+ $value = static::convertDomElementToArray($node, $checkPrefix);
+
+ $key = $node->localName;
+ if (isset($config[$key])) {
+ if (!\is_array($config[$key]) || !\is_int(key($config[$key]))) {
+ $config[$key] = [$config[$key]];
+ }
+ $config[$key][] = $value;
+ } else {
+ $config[$key] = $value;
+ }
+
+ $empty = false;
+ }
+ }
+
+ if (false !== $nodeValue) {
+ $value = static::phpize($nodeValue);
+ if (\count($config)) {
+ $config['value'] = $value;
+ } else {
+ $config = $value;
+ }
+ }
+
+ return !$empty ? $config : null;
+ }
+
+ /**
+ * Converts an xml value to a PHP type.
+ */
+ public static function phpize(string|\Stringable $value): mixed
+ {
+ $value = (string) $value;
+ $lowercaseValue = strtolower($value);
+
+ switch (true) {
+ case 'null' === $lowercaseValue:
+ return null;
+ case ctype_digit($value):
+ case isset($value[1]) && '-' === $value[0] && ctype_digit(substr($value, 1)):
+ $raw = $value;
+ $cast = (int) $value;
+
+ return self::isOctal($value) ? \intval($value, 8) : (($raw === (string) $cast) ? $cast : $raw);
+ case 'true' === $lowercaseValue:
+ return true;
+ case 'false' === $lowercaseValue:
+ return false;
+ case isset($value[1]) && '0b' == $value[0].$value[1] && preg_match('/^0b[01]*$/', $value):
+ return bindec($value);
+ case is_numeric($value):
+ return '0x' === $value[0].$value[1] ? hexdec($value) : (float) $value;
+ case preg_match('/^0x[0-9a-f]++$/i', $value):
+ return hexdec($value);
+ case preg_match('/^[+-]?[0-9]+(\.[0-9]+)?$/', $value):
+ return (float) $value;
+ default:
+ return $value;
+ }
+ }
+
+ protected static function getXmlErrors(bool $internalErrors): array
+ {
+ $errors = [];
+ foreach (libxml_get_errors() as $error) {
+ $errors[] = \sprintf('[%s %s] %s (in %s - line %d, column %d)',
+ \LIBXML_ERR_WARNING == $error->level ? 'WARNING' : 'ERROR',
+ $error->code,
+ trim($error->message),
+ $error->file ?: 'n/a',
+ $error->line,
+ $error->column
+ );
+ }
+
+ libxml_clear_errors();
+ libxml_use_internal_errors($internalErrors);
+
+ return $errors;
+ }
+
+ private static function isOctal(string $str): bool
+ {
+ if ('-' === $str[0]) {
+ $str = substr($str, 1);
+ }
+
+ return $str === '0'.decoct(\intval($str, 8));
+ }
+}
diff --git a/symfony/config/composer.json b/symfony/config/composer.json
new file mode 100644
index 0000000000000000000000000000000000000000..af999bafa38ff30c0c1b33b672efd2c3a7e8dd87
--- /dev/null
+++ b/symfony/config/composer.json
@@ -0,0 +1,42 @@
+{
+ "name": "symfony/config",
+ "type": "library",
+ "description": "Helps you find, load, combine, autofill and validate configuration values of any kind",
+ "keywords": [],
+ "homepage": "https://symfony.com",
+ "license": "MIT",
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "require": {
+ "php": ">=8.2",
+ "symfony/deprecation-contracts": "^2.5|^3",
+ "symfony/filesystem": "^7.1|^8.0",
+ "symfony/polyfill-ctype": "~1.8"
+ },
+ "require-dev": {
+ "symfony/event-dispatcher": "^6.4|^7.0|^8.0",
+ "symfony/finder": "^6.4|^7.0|^8.0",
+ "symfony/messenger": "^6.4|^7.0|^8.0",
+ "symfony/service-contracts": "^2.5|^3",
+ "symfony/yaml": "^6.4|^7.0|^8.0"
+ },
+ "conflict": {
+ "symfony/finder": "<6.4",
+ "symfony/service-contracts": "<2.5"
+ },
+ "autoload": {
+ "psr-4": { "Symfony\\Component\\Config\\": "" },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
+ },
+ "minimum-stability": "dev"
+}
diff --git a/symfony/console/Application.php b/symfony/console/Application.php
new file mode 100644
index 0000000000000000000000000000000000000000..f61761df5293a2aa3c2febfbe297ae6ad16facad
--- /dev/null
+++ b/symfony/console/Application.php
@@ -0,0 +1,1345 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Console;
+
+use Symfony\Component\Console\Command\Command;
+use Symfony\Component\Console\Command\CompleteCommand;
+use Symfony\Component\Console\Command\DumpCompletionCommand;
+use Symfony\Component\Console\Command\HelpCommand;
+use Symfony\Component\Console\Command\LazyCommand;
+use Symfony\Component\Console\Command\ListCommand;
+use Symfony\Component\Console\Command\SignalableCommandInterface;
+use Symfony\Component\Console\CommandLoader\CommandLoaderInterface;
+use Symfony\Component\Console\Completion\CompletionInput;
+use Symfony\Component\Console\Completion\CompletionSuggestions;
+use Symfony\Component\Console\Completion\Suggestion;
+use Symfony\Component\Console\Event\ConsoleCommandEvent;
+use Symfony\Component\Console\Event\ConsoleErrorEvent;
+use Symfony\Component\Console\Event\ConsoleSignalEvent;
+use Symfony\Component\Console\Event\ConsoleTerminateEvent;
+use Symfony\Component\Console\Exception\CommandNotFoundException;
+use Symfony\Component\Console\Exception\ExceptionInterface;
+use Symfony\Component\Console\Exception\LogicException;
+use Symfony\Component\Console\Exception\NamespaceNotFoundException;
+use Symfony\Component\Console\Exception\RuntimeException;
+use Symfony\Component\Console\Formatter\OutputFormatter;
+use Symfony\Component\Console\Helper\DebugFormatterHelper;
+use Symfony\Component\Console\Helper\DescriptorHelper;
+use Symfony\Component\Console\Helper\FormatterHelper;
+use Symfony\Component\Console\Helper\Helper;
+use Symfony\Component\Console\Helper\HelperSet;
+use Symfony\Component\Console\Helper\ProcessHelper;
+use Symfony\Component\Console\Helper\QuestionHelper;
+use Symfony\Component\Console\Input\ArgvInput;
+use Symfony\Component\Console\Input\ArrayInput;
+use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Input\InputAwareInterface;
+use Symfony\Component\Console\Input\InputDefinition;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Output\ConsoleOutput;
+use Symfony\Component\Console\Output\ConsoleOutputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Console\SignalRegistry\SignalRegistry;
+use Symfony\Component\Console\Style\SymfonyStyle;
+use Symfony\Component\ErrorHandler\ErrorHandler;
+use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
+use Symfony\Contracts\Service\ResetInterface;
+
+/**
+ * An Application is the container for a collection of commands.
+ *
+ * It is the main entry point of a Console application.
+ *
+ * This class is optimized for a standard CLI environment.
+ *
+ * Usage:
+ *
+ * $app = new Application('myapp', '1.0 (stable)');
+ * $app->add(new SimpleCommand());
+ * $app->run();
+ *
+ * @author Fabien Potencier
+ */
+class Application implements ResetInterface
+{
+ private array $commands = [];
+ private bool $wantHelps = false;
+ private ?Command $runningCommand = null;
+ private string $name;
+ private string $version;
+ private ?CommandLoaderInterface $commandLoader = null;
+ private bool $catchExceptions = true;
+ private bool $catchErrors = false;
+ private bool $autoExit = true;
+ private InputDefinition $definition;
+ private HelperSet $helperSet;
+ private ?EventDispatcherInterface $dispatcher = null;
+ private Terminal $terminal;
+ private string $defaultCommand;
+ private bool $singleCommand = false;
+ private bool $initialized = false;
+ private ?SignalRegistry $signalRegistry = null;
+ private array $signalsToDispatchEvent = [];
+
+ public function __construct(string $name = 'UNKNOWN', string $version = 'UNKNOWN')
+ {
+ $this->name = $name;
+ $this->version = $version;
+ $this->terminal = new Terminal();
+ $this->defaultCommand = 'list';
+ if (\defined('SIGINT') && SignalRegistry::isSupported()) {
+ $this->signalRegistry = new SignalRegistry();
+ $this->signalsToDispatchEvent = [\SIGINT, \SIGTERM, \SIGUSR1, \SIGUSR2];
+ }
+ }
+
+ /**
+ * @final
+ */
+ public function setDispatcher(EventDispatcherInterface $dispatcher): void
+ {
+ $this->dispatcher = $dispatcher;
+ }
+
+ /**
+ * @return void
+ */
+ public function setCommandLoader(CommandLoaderInterface $commandLoader)
+ {
+ $this->commandLoader = $commandLoader;
+ }
+
+ public function getSignalRegistry(): SignalRegistry
+ {
+ if (!$this->signalRegistry) {
+ throw new RuntimeException('Signals are not supported. Make sure that the "pcntl" extension is installed and that "pcntl_*" functions are not disabled by your php.ini\'s "disable_functions" directive.');
+ }
+
+ return $this->signalRegistry;
+ }
+
+ /**
+ * @return void
+ */
+ public function setSignalsToDispatchEvent(int ...$signalsToDispatchEvent)
+ {
+ $this->signalsToDispatchEvent = $signalsToDispatchEvent;
+ }
+
+ /**
+ * Runs the current application.
+ *
+ * @return int 0 if everything went fine, or an error code
+ *
+ * @throws \Exception When running fails. Bypass this when {@link setCatchExceptions()}.
+ */
+ public function run(?InputInterface $input = null, ?OutputInterface $output = null): int
+ {
+ if (\function_exists('putenv')) {
+ @putenv('LINES='.$this->terminal->getHeight());
+ @putenv('COLUMNS='.$this->terminal->getWidth());
+ }
+
+ $input ??= new ArgvInput();
+ $output ??= new ConsoleOutput();
+
+ $renderException = function (\Throwable $e) use ($output) {
+ if ($output instanceof ConsoleOutputInterface) {
+ $this->renderThrowable($e, $output->getErrorOutput());
+ } else {
+ $this->renderThrowable($e, $output);
+ }
+ };
+ if ($phpHandler = set_exception_handler($renderException)) {
+ restore_exception_handler();
+ if (!\is_array($phpHandler) || !$phpHandler[0] instanceof ErrorHandler) {
+ $errorHandler = true;
+ } elseif ($errorHandler = $phpHandler[0]->setExceptionHandler($renderException)) {
+ $phpHandler[0]->setExceptionHandler($errorHandler);
+ }
+ }
+
+ try {
+ $this->configureIO($input, $output);
+
+ $exitCode = $this->doRun($input, $output);
+ } catch (\Throwable $e) {
+ if ($e instanceof \Exception && !$this->catchExceptions) {
+ throw $e;
+ }
+ if (!$e instanceof \Exception && !$this->catchErrors) {
+ throw $e;
+ }
+
+ $renderException($e);
+
+ $exitCode = $e->getCode();
+ if (is_numeric($exitCode)) {
+ $exitCode = (int) $exitCode;
+ if ($exitCode <= 0) {
+ $exitCode = 1;
+ }
+ } else {
+ $exitCode = 1;
+ }
+ } finally {
+ // if the exception handler changed, keep it
+ // otherwise, unregister $renderException
+ if (!$phpHandler) {
+ if (set_exception_handler($renderException) === $renderException) {
+ restore_exception_handler();
+ }
+ restore_exception_handler();
+ } elseif (!$errorHandler) {
+ $finalHandler = $phpHandler[0]->setExceptionHandler(null);
+ if ($finalHandler !== $renderException) {
+ $phpHandler[0]->setExceptionHandler($finalHandler);
+ }
+ }
+ }
+
+ if ($this->autoExit) {
+ if ($exitCode > 255) {
+ $exitCode = 255;
+ }
+
+ exit($exitCode);
+ }
+
+ return $exitCode;
+ }
+
+ /**
+ * Runs the current application.
+ *
+ * @return int 0 if everything went fine, or an error code
+ */
+ public function doRun(InputInterface $input, OutputInterface $output)
+ {
+ if (true === $input->hasParameterOption(['--version', '-V'], true)) {
+ $output->writeln($this->getLongVersion());
+
+ return 0;
+ }
+
+ try {
+ // Makes ArgvInput::getFirstArgument() able to distinguish an option from an argument.
+ $input->bind($this->getDefinition());
+ } catch (ExceptionInterface) {
+ // Errors must be ignored, full binding/validation happens later when the command is known.
+ }
+
+ $name = $this->getCommandName($input);
+ if (true === $input->hasParameterOption(['--help', '-h'], true)) {
+ if (!$name) {
+ $name = 'help';
+ $input = new ArrayInput(['command_name' => $this->defaultCommand]);
+ } else {
+ $this->wantHelps = true;
+ }
+ }
+
+ if (!$name) {
+ $name = $this->defaultCommand;
+ $definition = $this->getDefinition();
+ $definition->setArguments(array_merge(
+ $definition->getArguments(),
+ [
+ 'command' => new InputArgument('command', InputArgument::OPTIONAL, $definition->getArgument('command')->getDescription(), $name),
+ ]
+ ));
+ }
+
+ try {
+ $this->runningCommand = null;
+ // the command name MUST be the first element of the input
+ $command = $this->find($name);
+ } catch (\Throwable $e) {
+ if (($e instanceof CommandNotFoundException && !$e instanceof NamespaceNotFoundException) && 1 === \count($alternatives = $e->getAlternatives()) && $input->isInteractive()) {
+ $alternative = $alternatives[0];
+
+ $style = new SymfonyStyle($input, $output);
+ $output->writeln('');
+ $formattedBlock = (new FormatterHelper())->formatBlock(\sprintf('Command "%s" is not defined.', $name), 'error', true);
+ $output->writeln($formattedBlock);
+ if (!$style->confirm(\sprintf('Do you want to run "%s" instead? ', $alternative), false)) {
+ if (null !== $this->dispatcher) {
+ $event = new ConsoleErrorEvent($input, $output, $e);
+ $this->dispatcher->dispatch($event, ConsoleEvents::ERROR);
+
+ return $event->getExitCode();
+ }
+
+ return 1;
+ }
+
+ $command = $this->find($alternative);
+ } else {
+ if (null !== $this->dispatcher) {
+ $event = new ConsoleErrorEvent($input, $output, $e);
+ $this->dispatcher->dispatch($event, ConsoleEvents::ERROR);
+
+ if (0 === $event->getExitCode()) {
+ return 0;
+ }
+
+ $e = $event->getError();
+ }
+
+ try {
+ if ($e instanceof CommandNotFoundException && $namespace = $this->findNamespace($name)) {
+ $helper = new DescriptorHelper();
+ $helper->describe($output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output, $this, [
+ 'format' => 'txt',
+ 'raw_text' => false,
+ 'namespace' => $namespace,
+ 'short' => false,
+ ]);
+
+ return isset($event) ? $event->getExitCode() : 1;
+ }
+
+ throw $e;
+ } catch (NamespaceNotFoundException) {
+ throw $e;
+ }
+ }
+ }
+
+ if ($command instanceof LazyCommand) {
+ $command = $command->getCommand();
+ }
+
+ $this->runningCommand = $command;
+ $exitCode = $this->doRunCommand($command, $input, $output);
+ $this->runningCommand = null;
+
+ return $exitCode;
+ }
+
+ /**
+ * @return void
+ */
+ public function reset()
+ {
+ }
+
+ /**
+ * @return void
+ */
+ public function setHelperSet(HelperSet $helperSet)
+ {
+ $this->helperSet = $helperSet;
+ }
+
+ /**
+ * Get the helper set associated with the command.
+ */
+ public function getHelperSet(): HelperSet
+ {
+ return $this->helperSet ??= $this->getDefaultHelperSet();
+ }
+
+ /**
+ * @return void
+ */
+ public function setDefinition(InputDefinition $definition)
+ {
+ $this->definition = $definition;
+ }
+
+ /**
+ * Gets the InputDefinition related to this Application.
+ */
+ public function getDefinition(): InputDefinition
+ {
+ $this->definition ??= $this->getDefaultInputDefinition();
+
+ if ($this->singleCommand) {
+ $inputDefinition = $this->definition;
+ $inputDefinition->setArguments();
+
+ return $inputDefinition;
+ }
+
+ return $this->definition;
+ }
+
+ /**
+ * Adds suggestions to $suggestions for the current completion input (e.g. option or argument).
+ */
+ public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
+ {
+ if (
+ CompletionInput::TYPE_ARGUMENT_VALUE === $input->getCompletionType()
+ && 'command' === $input->getCompletionName()
+ ) {
+ foreach ($this->all() as $name => $command) {
+ // skip hidden commands and aliased commands as they already get added below
+ if ($command->isHidden() || $command->getName() !== $name) {
+ continue;
+ }
+ $suggestions->suggestValue(new Suggestion($command->getName(), $command->getDescription()));
+ foreach ($command->getAliases() as $name) {
+ $suggestions->suggestValue(new Suggestion($name, $command->getDescription()));
+ }
+ }
+
+ return;
+ }
+
+ if (CompletionInput::TYPE_OPTION_NAME === $input->getCompletionType()) {
+ $suggestions->suggestOptions($this->getDefinition()->getOptions());
+
+ return;
+ }
+
+ if (
+ CompletionInput::TYPE_OPTION_VALUE === $input->getCompletionType()
+ && ($definition = $this->getDefinition())->hasOption($input->getCompletionName())
+ ) {
+ $definition->getOption($input->getCompletionName())->complete($input, $suggestions);
+
+ return;
+ }
+ }
+
+ /**
+ * Gets the help message.
+ */
+ public function getHelp(): string
+ {
+ return $this->getLongVersion();
+ }
+
+ /**
+ * Gets whether to catch exceptions or not during commands execution.
+ */
+ public function areExceptionsCaught(): bool
+ {
+ return $this->catchExceptions;
+ }
+
+ /**
+ * Sets whether to catch exceptions or not during commands execution.
+ *
+ * @return void
+ */
+ public function setCatchExceptions(bool $boolean)
+ {
+ $this->catchExceptions = $boolean;
+ }
+
+ /**
+ * Sets whether to catch errors or not during commands execution.
+ */
+ public function setCatchErrors(bool $catchErrors = true): void
+ {
+ $this->catchErrors = $catchErrors;
+ }
+
+ /**
+ * Gets whether to automatically exit after a command execution or not.
+ */
+ public function isAutoExitEnabled(): bool
+ {
+ return $this->autoExit;
+ }
+
+ /**
+ * Sets whether to automatically exit after a command execution or not.
+ *
+ * @return void
+ */
+ public function setAutoExit(bool $boolean)
+ {
+ $this->autoExit = $boolean;
+ }
+
+ /**
+ * Gets the name of the application.
+ */
+ public function getName(): string
+ {
+ return $this->name;
+ }
+
+ /**
+ * Sets the application name.
+ *
+ * @return void
+ */
+ public function setName(string $name)
+ {
+ $this->name = $name;
+ }
+
+ /**
+ * Gets the application version.
+ */
+ public function getVersion(): string
+ {
+ return $this->version;
+ }
+
+ /**
+ * Sets the application version.
+ *
+ * @return void
+ */
+ public function setVersion(string $version)
+ {
+ $this->version = $version;
+ }
+
+ /**
+ * Returns the long version of the application.
+ *
+ * @return string
+ */
+ public function getLongVersion()
+ {
+ if ('UNKNOWN' !== $this->getName()) {
+ if ('UNKNOWN' !== $this->getVersion()) {
+ return \sprintf('%s %s', $this->getName(), $this->getVersion());
+ }
+
+ return $this->getName();
+ }
+
+ return 'Console Tool';
+ }
+
+ /**
+ * Registers a new command.
+ */
+ public function register(string $name): Command
+ {
+ return $this->add(new Command($name));
+ }
+
+ /**
+ * Adds an array of command objects.
+ *
+ * If a Command is not enabled it will not be added.
+ *
+ * @param Command[] $commands An array of commands
+ *
+ * @return void
+ */
+ public function addCommands(array $commands)
+ {
+ foreach ($commands as $command) {
+ $this->add($command);
+ }
+ }
+
+ /**
+ * Adds a command object.
+ *
+ * If a command with the same name already exists, it will be overridden.
+ * If the command is not enabled it will not be added.
+ *
+ * @return Command|null
+ */
+ public function add(Command $command)
+ {
+ $this->init();
+
+ $command->setApplication($this);
+
+ if (!$command->isEnabled()) {
+ $command->setApplication(null);
+
+ return null;
+ }
+
+ if (!$command instanceof LazyCommand) {
+ // Will throw if the command is not correctly initialized.
+ $command->getDefinition();
+ }
+
+ if (!$command->getName()) {
+ throw new LogicException(\sprintf('The command defined in "%s" cannot have an empty name.', get_debug_type($command)));
+ }
+
+ $this->commands[$command->getName()] = $command;
+
+ foreach ($command->getAliases() as $alias) {
+ $this->commands[$alias] = $command;
+ }
+
+ return $command;
+ }
+
+ /**
+ * Returns a registered command by name or alias.
+ *
+ * @return Command
+ *
+ * @throws CommandNotFoundException When given command name does not exist
+ */
+ public function get(string $name)
+ {
+ $this->init();
+
+ if (!$this->has($name)) {
+ throw new CommandNotFoundException(\sprintf('The command "%s" does not exist.', $name));
+ }
+
+ // When the command has a different name than the one used at the command loader level
+ if (!isset($this->commands[$name])) {
+ throw new CommandNotFoundException(\sprintf('The "%s" command cannot be found because it is registered under multiple names. Make sure you don\'t set a different name via constructor or "setName()".', $name));
+ }
+
+ $command = $this->commands[$name];
+
+ if ($this->wantHelps) {
+ $this->wantHelps = false;
+
+ $helpCommand = $this->get('help');
+ $helpCommand->setCommand($command);
+
+ return $helpCommand;
+ }
+
+ return $command;
+ }
+
+ /**
+ * Returns true if the command exists, false otherwise.
+ */
+ public function has(string $name): bool
+ {
+ $this->init();
+
+ return isset($this->commands[$name]) || ($this->commandLoader?->has($name) && $this->add($this->commandLoader->get($name)));
+ }
+
+ /**
+ * Returns an array of all unique namespaces used by currently registered commands.
+ *
+ * It does not return the global namespace which always exists.
+ *
+ * @return string[]
+ */
+ public function getNamespaces(): array
+ {
+ $namespaces = [];
+ foreach ($this->all() as $command) {
+ if ($command->isHidden()) {
+ continue;
+ }
+
+ $namespaces[] = $this->extractAllNamespaces($command->getName());
+
+ foreach ($command->getAliases() as $alias) {
+ $namespaces[] = $this->extractAllNamespaces($alias);
+ }
+ }
+
+ return array_values(array_unique(array_filter(array_merge([], ...$namespaces))));
+ }
+
+ /**
+ * Finds a registered namespace by a name or an abbreviation.
+ *
+ * @throws NamespaceNotFoundException When namespace is incorrect or ambiguous
+ */
+ public function findNamespace(string $namespace): string
+ {
+ $allNamespaces = $this->getNamespaces();
+ $expr = implode('[^:]*:', array_map('preg_quote', explode(':', $namespace))).'[^:]*';
+ $namespaces = preg_grep('{^'.$expr.'}', $allNamespaces);
+
+ if (empty($namespaces)) {
+ $message = \sprintf('There are no commands defined in the "%s" namespace.', $namespace);
+
+ if ($alternatives = $this->findAlternatives($namespace, $allNamespaces)) {
+ if (1 == \count($alternatives)) {
+ $message .= "\n\nDid you mean this?\n ";
+ } else {
+ $message .= "\n\nDid you mean one of these?\n ";
+ }
+
+ $message .= implode("\n ", $alternatives);
+ }
+
+ throw new NamespaceNotFoundException($message, $alternatives);
+ }
+
+ $exact = \in_array($namespace, $namespaces, true);
+ if (\count($namespaces) > 1 && !$exact) {
+ throw new NamespaceNotFoundException(\sprintf("The namespace \"%s\" is ambiguous.\nDid you mean one of these?\n%s.", $namespace, $this->getAbbreviationSuggestions(array_values($namespaces))), array_values($namespaces));
+ }
+
+ return $exact ? $namespace : reset($namespaces);
+ }
+
+ /**
+ * Finds a command by name or alias.
+ *
+ * Contrary to get, this command tries to find the best
+ * match if you give it an abbreviation of a name or alias.
+ *
+ * @return Command
+ *
+ * @throws CommandNotFoundException When command name is incorrect or ambiguous
+ */
+ public function find(string $name)
+ {
+ $this->init();
+
+ $aliases = [];
+
+ foreach ($this->commands as $command) {
+ foreach ($command->getAliases() as $alias) {
+ if (!$this->has($alias)) {
+ $this->commands[$alias] = $command;
+ }
+ }
+ }
+
+ if ($this->has($name)) {
+ return $this->get($name);
+ }
+
+ $allCommands = $this->commandLoader ? array_merge($this->commandLoader->getNames(), array_keys($this->commands)) : array_keys($this->commands);
+ $expr = implode('[^:]*:', array_map('preg_quote', explode(':', $name))).'[^:]*';
+ $commands = preg_grep('{^'.$expr.'}', $allCommands);
+
+ if (empty($commands)) {
+ $commands = preg_grep('{^'.$expr.'}i', $allCommands);
+ }
+
+ // if no commands matched or we just matched namespaces
+ if (empty($commands) || \count(preg_grep('{^'.$expr.'$}i', $commands)) < 1) {
+ if (false !== $pos = strrpos($name, ':')) {
+ // check if a namespace exists and contains commands
+ $this->findNamespace(substr($name, 0, $pos));
+ }
+
+ $message = \sprintf('Command "%s" is not defined.', $name);
+
+ if ($alternatives = $this->findAlternatives($name, $allCommands)) {
+ $wantHelps = $this->wantHelps;
+ $this->wantHelps = false;
+
+ // remove hidden commands
+ if ($alternatives = array_filter($alternatives, fn ($name) => !$this->get($name)->isHidden())) {
+ $message .= \sprintf("\n\nDid you mean %s?\n %s", 1 === \count($alternatives) ? 'this' : 'one of these', implode("\n ", $alternatives));
+ }
+ $this->wantHelps = $wantHelps;
+ }
+
+ throw new CommandNotFoundException($message, array_values($alternatives));
+ }
+
+ // filter out aliases for commands which are already on the list
+ if (\count($commands) > 1) {
+ $commandList = $this->commandLoader ? array_merge(array_flip($this->commandLoader->getNames()), $this->commands) : $this->commands;
+ $commands = array_unique(array_filter($commands, function ($nameOrAlias) use (&$commandList, $commands, &$aliases) {
+ if (!$commandList[$nameOrAlias] instanceof Command) {
+ $commandList[$nameOrAlias] = $this->commandLoader->get($nameOrAlias);
+ }
+
+ $commandName = $commandList[$nameOrAlias]->getName();
+
+ $aliases[$nameOrAlias] = $commandName;
+
+ return $commandName === $nameOrAlias || !\in_array($commandName, $commands);
+ }));
+ }
+
+ if (\count($commands) > 1) {
+ $usableWidth = $this->terminal->getWidth() - 10;
+ $abbrevs = array_values($commands);
+ $maxLen = 0;
+ foreach ($abbrevs as $abbrev) {
+ $maxLen = max(Helper::width($abbrev), $maxLen);
+ }
+ $abbrevs = array_map(function ($cmd) use ($commandList, $usableWidth, $maxLen, &$commands) {
+ if ($commandList[$cmd]->isHidden()) {
+ unset($commands[array_search($cmd, $commands)]);
+
+ return false;
+ }
+
+ $abbrev = str_pad($cmd, $maxLen, ' ').' '.$commandList[$cmd]->getDescription();
+
+ return Helper::width($abbrev) > $usableWidth ? Helper::substr($abbrev, 0, $usableWidth - 3).'...' : $abbrev;
+ }, array_values($commands));
+
+ if (\count($commands) > 1) {
+ $suggestions = $this->getAbbreviationSuggestions(array_filter($abbrevs));
+
+ throw new CommandNotFoundException(\sprintf("Command \"%s\" is ambiguous.\nDid you mean one of these?\n%s.", $name, $suggestions), array_values($commands));
+ }
+ }
+
+ $command = $commands ? $this->get(reset($commands)) : null;
+
+ if (!$command || $command->isHidden()) {
+ throw new CommandNotFoundException(\sprintf('The command "%s" does not exist.', $name));
+ }
+
+ return $command;
+ }
+
+ /**
+ * Gets the commands (registered in the given namespace if provided).
+ *
+ * The array keys are the full names and the values the command instances.
+ *
+ * @return Command[]
+ */
+ public function all(?string $namespace = null)
+ {
+ $this->init();
+
+ if (null === $namespace) {
+ if (!$this->commandLoader) {
+ return $this->commands;
+ }
+
+ $commands = $this->commands;
+ foreach ($this->commandLoader->getNames() as $name) {
+ if (!isset($commands[$name]) && $this->has($name)) {
+ $commands[$name] = $this->get($name);
+ }
+ }
+
+ return $commands;
+ }
+
+ $commands = [];
+ foreach ($this->commands as $name => $command) {
+ if ($namespace === $this->extractNamespace($name, substr_count($namespace, ':') + 1)) {
+ $commands[$name] = $command;
+ }
+ }
+
+ if ($this->commandLoader) {
+ foreach ($this->commandLoader->getNames() as $name) {
+ if (!isset($commands[$name]) && $namespace === $this->extractNamespace($name, substr_count($namespace, ':') + 1) && $this->has($name)) {
+ $commands[$name] = $this->get($name);
+ }
+ }
+ }
+
+ return $commands;
+ }
+
+ /**
+ * Returns an array of possible abbreviations given a set of names.
+ *
+ * @return string[][]
+ */
+ public static function getAbbreviations(array $names): array
+ {
+ $abbrevs = [];
+ foreach ($names as $name) {
+ for ($len = \strlen($name); $len > 0; --$len) {
+ $abbrev = substr($name, 0, $len);
+ $abbrevs[$abbrev][] = $name;
+ }
+ }
+
+ return $abbrevs;
+ }
+
+ public function renderThrowable(\Throwable $e, OutputInterface $output): void
+ {
+ $output->writeln('', OutputInterface::VERBOSITY_QUIET);
+
+ $this->doRenderThrowable($e, $output);
+
+ if (null !== $this->runningCommand) {
+ $output->writeln(\sprintf('%s', OutputFormatter::escape(\sprintf($this->runningCommand->getSynopsis(), $this->getName()))), OutputInterface::VERBOSITY_QUIET);
+ $output->writeln('', OutputInterface::VERBOSITY_QUIET);
+ }
+ }
+
+ protected function doRenderThrowable(\Throwable $e, OutputInterface $output): void
+ {
+ do {
+ $message = trim($e->getMessage());
+ if ('' === $message || OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
+ $class = get_debug_type($e);
+ $title = \sprintf(' [%s%s] ', $class, 0 !== ($code = $e->getCode()) ? ' ('.$code.')' : '');
+ $len = Helper::width($title);
+ } else {
+ $len = 0;
+ }
+
+ if (str_contains($message, "@anonymous\0")) {
+ $message = preg_replace_callback('/[a-zA-Z_\x7f-\xff][\\\\a-zA-Z0-9_\x7f-\xff]*+@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)?[0-9a-fA-F]++/', fn ($m) => class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0])) ?: 'class').'@anonymous' : $m[0], $message);
+ }
+
+ $width = $this->terminal->getWidth() ? $this->terminal->getWidth() - 1 : \PHP_INT_MAX;
+ $lines = [];
+ foreach ('' !== $message ? preg_split('/\r?\n/', $message) : [] as $line) {
+ foreach ($this->splitStringByWidth($line, $width - 4) as $line) {
+ // pre-format lines to get the right string length
+ $lineLength = Helper::width($line) + 4;
+ $lines[] = [$line, $lineLength];
+
+ $len = max($lineLength, $len);
+ }
+ }
+
+ $messages = [];
+ if (!$e instanceof ExceptionInterface || OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
+ $messages[] = \sprintf('%s', OutputFormatter::escape(\sprintf('In %s line %s:', basename($e->getFile()) ?: 'n/a', $e->getLine() ?: 'n/a')));
+ }
+ $messages[] = $emptyLine = \sprintf('%s', str_repeat(' ', $len));
+ if ('' === $message || OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
+ $messages[] = \sprintf('%s%s', $title, str_repeat(' ', max(0, $len - Helper::width($title))));
+ }
+ foreach ($lines as $line) {
+ $messages[] = \sprintf(' %s %s', OutputFormatter::escape($line[0]), str_repeat(' ', $len - $line[1]));
+ }
+ $messages[] = $emptyLine;
+ $messages[] = '';
+
+ $output->writeln($messages, OutputInterface::VERBOSITY_QUIET);
+
+ if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
+ $output->writeln('Exception trace:', OutputInterface::VERBOSITY_QUIET);
+
+ // exception related properties
+ $trace = $e->getTrace();
+
+ array_unshift($trace, [
+ 'function' => '',
+ 'file' => $e->getFile() ?: 'n/a',
+ 'line' => $e->getLine() ?: 'n/a',
+ 'args' => [],
+ ]);
+
+ for ($i = 0, $count = \count($trace); $i < $count; ++$i) {
+ $class = $trace[$i]['class'] ?? '';
+ $type = $trace[$i]['type'] ?? '';
+ $function = $trace[$i]['function'] ?? '';
+ $file = $trace[$i]['file'] ?? 'n/a';
+ $line = $trace[$i]['line'] ?? 'n/a';
+
+ $output->writeln(\sprintf(' %s%s at %s:%s', $class, $function ? $type.$function.'()' : '', $file, $line), OutputInterface::VERBOSITY_QUIET);
+ }
+
+ $output->writeln('', OutputInterface::VERBOSITY_QUIET);
+ }
+ } while ($e = $e->getPrevious());
+ }
+
+ /**
+ * Configures the input and output instances based on the user arguments and options.
+ *
+ * @return void
+ */
+ protected function configureIO(InputInterface $input, OutputInterface $output)
+ {
+ if (true === $input->hasParameterOption(['--ansi'], true)) {
+ $output->setDecorated(true);
+ } elseif (true === $input->hasParameterOption(['--no-ansi'], true)) {
+ $output->setDecorated(false);
+ }
+
+ if (true === $input->hasParameterOption(['--no-interaction', '-n'], true)) {
+ $input->setInteractive(false);
+ }
+
+ switch ($shellVerbosity = (int) getenv('SHELL_VERBOSITY')) {
+ case -1:
+ $output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
+ break;
+ case 1:
+ $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
+ break;
+ case 2:
+ $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE);
+ break;
+ case 3:
+ $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG);
+ break;
+ default:
+ $shellVerbosity = 0;
+ break;
+ }
+
+ if (true === $input->hasParameterOption(['--quiet', '-q'], true)) {
+ $output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
+ $shellVerbosity = -1;
+ } else {
+ if ($input->hasParameterOption('-vvv', true) || $input->hasParameterOption('--verbose=3', true) || 3 === $input->getParameterOption('--verbose', false, true)) {
+ $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG);
+ $shellVerbosity = 3;
+ } elseif ($input->hasParameterOption('-vv', true) || $input->hasParameterOption('--verbose=2', true) || 2 === $input->getParameterOption('--verbose', false, true)) {
+ $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE);
+ $shellVerbosity = 2;
+ } elseif ($input->hasParameterOption('-v', true) || $input->hasParameterOption('--verbose=1', true) || $input->hasParameterOption('--verbose', true) || $input->getParameterOption('--verbose', false, true)) {
+ $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
+ $shellVerbosity = 1;
+ }
+ }
+
+ if (-1 === $shellVerbosity) {
+ $input->setInteractive(false);
+ }
+
+ if (\function_exists('putenv')) {
+ @putenv('SHELL_VERBOSITY='.$shellVerbosity);
+ }
+ $_ENV['SHELL_VERBOSITY'] = $shellVerbosity;
+ $_SERVER['SHELL_VERBOSITY'] = $shellVerbosity;
+ }
+
+ /**
+ * Runs the current command.
+ *
+ * If an event dispatcher has been attached to the application,
+ * events are also dispatched during the life-cycle of the command.
+ *
+ * @return int 0 if everything went fine, or an error code
+ */
+ protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output)
+ {
+ foreach ($command->getHelperSet() as $helper) {
+ if ($helper instanceof InputAwareInterface) {
+ $helper->setInput($input);
+ }
+ }
+
+ $registeredSignals = false;
+ $commandSignals = $command instanceof SignalableCommandInterface ? $command->getSubscribedSignals() : [];
+ if ($commandSignals || $this->dispatcher && $this->signalsToDispatchEvent) {
+ if (!$this->signalRegistry) {
+ throw new RuntimeException('Unable to subscribe to signal events. Make sure that the "pcntl" extension is installed and that "pcntl_*" functions are not disabled by your php.ini\'s "disable_functions" directive.');
+ }
+
+ $registeredSignals = true;
+ $this->getSignalRegistry()->pushCurrentHandlers();
+
+ if ($this->dispatcher) {
+ // We register application signals, so that we can dispatch the event
+ foreach ($this->signalsToDispatchEvent as $signal) {
+ $event = new ConsoleSignalEvent($command, $input, $output, $signal);
+
+ $this->signalRegistry->register($signal, function ($signal) use ($event, $command, $commandSignals) {
+ $this->dispatcher->dispatch($event, ConsoleEvents::SIGNAL);
+ $exitCode = $event->getExitCode();
+
+ // If the command is signalable, we call the handleSignal() method
+ if (\in_array($signal, $commandSignals, true)) {
+ $exitCode = $command->handleSignal($signal, $exitCode);
+ // BC layer for Symfony <= 5
+ if (null === $exitCode) {
+ trigger_deprecation('symfony/console', '6.3', 'Not returning an exit code from "%s::handleSignal()" is deprecated, return "false" to keep the command running or "0" to exit successfully.', get_debug_type($command));
+ $exitCode = 0;
+ }
+ }
+
+ if (false !== $exitCode) {
+ $event = new ConsoleTerminateEvent($command, $event->getInput(), $event->getOutput(), $exitCode, $signal);
+ $this->dispatcher->dispatch($event, ConsoleEvents::TERMINATE);
+
+ exit($event->getExitCode());
+ }
+ });
+ }
+
+ // then we register command signals, but not if already handled after the dispatcher
+ $commandSignals = array_diff($commandSignals, $this->signalsToDispatchEvent);
+ }
+
+ foreach ($commandSignals as $signal) {
+ $this->signalRegistry->register($signal, function (int $signal) use ($command): void {
+ $exitCode = $command->handleSignal($signal);
+ // BC layer for Symfony <= 5
+ if (null === $exitCode) {
+ trigger_deprecation('symfony/console', '6.3', 'Not returning an exit code from "%s::handleSignal()" is deprecated, return "false" to keep the command running or "0" to exit successfully.', get_debug_type($command));
+ $exitCode = 0;
+ }
+
+ if (false !== $exitCode) {
+ exit($exitCode);
+ }
+ });
+ }
+ }
+
+ if (null === $this->dispatcher) {
+ try {
+ return $command->run($input, $output);
+ } finally {
+ if ($registeredSignals) {
+ $this->getSignalRegistry()->popPreviousHandlers();
+ }
+ }
+ }
+
+ // bind before the console.command event, so the listeners have access to input options/arguments
+ try {
+ $command->mergeApplicationDefinition();
+ $input->bind($command->getDefinition());
+ } catch (ExceptionInterface) {
+ // ignore invalid options/arguments for now, to allow the event listeners to customize the InputDefinition
+ }
+
+ $event = new ConsoleCommandEvent($command, $input, $output);
+ $e = null;
+
+ try {
+ $this->dispatcher->dispatch($event, ConsoleEvents::COMMAND);
+
+ if ($event->commandShouldRun()) {
+ $exitCode = $command->run($input, $output);
+ } else {
+ $exitCode = ConsoleCommandEvent::RETURN_CODE_DISABLED;
+ }
+ } catch (\Throwable $e) {
+ $event = new ConsoleErrorEvent($input, $output, $e, $command);
+ $this->dispatcher->dispatch($event, ConsoleEvents::ERROR);
+ $e = $event->getError();
+
+ if (0 === $exitCode = $event->getExitCode()) {
+ $e = null;
+ }
+ } finally {
+ if ($registeredSignals) {
+ $this->getSignalRegistry()->popPreviousHandlers();
+ }
+ }
+
+ $event = new ConsoleTerminateEvent($command, $input, $output, $exitCode);
+ $this->dispatcher->dispatch($event, ConsoleEvents::TERMINATE);
+
+ if (null !== $e) {
+ throw $e;
+ }
+
+ return $event->getExitCode();
+ }
+
+ /**
+ * Gets the name of the command based on input.
+ */
+ protected function getCommandName(InputInterface $input): ?string
+ {
+ return $this->singleCommand ? $this->defaultCommand : $input->getFirstArgument();
+ }
+
+ /**
+ * Gets the default input definition.
+ */
+ protected function getDefaultInputDefinition(): InputDefinition
+ {
+ return new InputDefinition([
+ new InputArgument('command', InputArgument::REQUIRED, 'The command to execute'),
+ new InputOption('--help', '-h', InputOption::VALUE_NONE, 'Display help for the given command. When no command is given display help for the '.$this->defaultCommand.' command'),
+ new InputOption('--quiet', '-q', InputOption::VALUE_NONE, 'Do not output any message'),
+ new InputOption('--verbose', '-v|vv|vvv', InputOption::VALUE_NONE, 'Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug'),
+ new InputOption('--version', '-V', InputOption::VALUE_NONE, 'Display this application version'),
+ new InputOption('--ansi', '', InputOption::VALUE_NEGATABLE, 'Force (or disable --no-ansi) ANSI output', null),
+ new InputOption('--no-interaction', '-n', InputOption::VALUE_NONE, 'Do not ask any interactive question'),
+ ]);
+ }
+
+ /**
+ * Gets the default commands that should always be available.
+ *
+ * @return Command[]
+ */
+ protected function getDefaultCommands(): array
+ {
+ return [new HelpCommand(), new ListCommand(), new CompleteCommand(), new DumpCompletionCommand()];
+ }
+
+ /**
+ * Gets the default helper set with the helpers that should always be available.
+ */
+ protected function getDefaultHelperSet(): HelperSet
+ {
+ return new HelperSet([
+ new FormatterHelper(),
+ new DebugFormatterHelper(),
+ new ProcessHelper(),
+ new QuestionHelper(),
+ ]);
+ }
+
+ /**
+ * Returns abbreviated suggestions in string format.
+ */
+ private function getAbbreviationSuggestions(array $abbrevs): string
+ {
+ return ' '.implode("\n ", $abbrevs);
+ }
+
+ /**
+ * Returns the namespace part of the command name.
+ *
+ * This method is not part of public API and should not be used directly.
+ */
+ public function extractNamespace(string $name, ?int $limit = null): string
+ {
+ $parts = explode(':', $name, -1);
+
+ return implode(':', null === $limit ? $parts : \array_slice($parts, 0, $limit));
+ }
+
+ /**
+ * Finds alternative of $name among $collection,
+ * if nothing is found in $collection, try in $abbrevs.
+ *
+ * @return string[]
+ */
+ private function findAlternatives(string $name, iterable $collection): array
+ {
+ $threshold = 1e3;
+ $alternatives = [];
+
+ $collectionParts = [];
+ foreach ($collection as $item) {
+ $collectionParts[$item] = explode(':', $item);
+ }
+
+ foreach (explode(':', $name) as $i => $subname) {
+ foreach ($collectionParts as $collectionName => $parts) {
+ $exists = isset($alternatives[$collectionName]);
+ if (!isset($parts[$i]) && $exists) {
+ $alternatives[$collectionName] += $threshold;
+ continue;
+ } elseif (!isset($parts[$i])) {
+ continue;
+ }
+
+ $lev = levenshtein($subname, $parts[$i]);
+ if ($lev <= \strlen($subname) / 3 || '' !== $subname && str_contains($parts[$i], $subname)) {
+ $alternatives[$collectionName] = $exists ? $alternatives[$collectionName] + $lev : $lev;
+ } elseif ($exists) {
+ $alternatives[$collectionName] += $threshold;
+ }
+ }
+ }
+
+ foreach ($collection as $item) {
+ $lev = levenshtein($name, $item);
+ if ($lev <= \strlen($name) / 3 || str_contains($item, $name)) {
+ $alternatives[$item] = isset($alternatives[$item]) ? $alternatives[$item] - $lev : $lev;
+ }
+ }
+
+ $alternatives = array_filter($alternatives, fn ($lev) => $lev < 2 * $threshold);
+ ksort($alternatives, \SORT_NATURAL | \SORT_FLAG_CASE);
+
+ return array_keys($alternatives);
+ }
+
+ /**
+ * Sets the default Command name.
+ *
+ * @return $this
+ */
+ public function setDefaultCommand(string $commandName, bool $isSingleCommand = false): static
+ {
+ $this->defaultCommand = explode('|', ltrim($commandName, '|'))[0];
+
+ if ($isSingleCommand) {
+ // Ensure the command exist
+ $this->find($commandName);
+
+ $this->singleCommand = true;
+ }
+
+ return $this;
+ }
+
+ /**
+ * @internal
+ */
+ public function isSingleCommand(): bool
+ {
+ return $this->singleCommand;
+ }
+
+ private function splitStringByWidth(string $string, int $width): array
+ {
+ // str_split is not suitable for multi-byte characters, we should use preg_split to get char array properly.
+ // additionally, array_slice() is not enough as some character has doubled width.
+ // we need a function to split string not by character count but by string width
+ if (false === $encoding = mb_detect_encoding($string, null, true)) {
+ return str_split($string, $width);
+ }
+
+ $utf8String = mb_convert_encoding($string, 'utf8', $encoding);
+ $lines = [];
+ $line = '';
+
+ $offset = 0;
+ while (preg_match('/.{1,10000}/u', $utf8String, $m, 0, $offset)) {
+ $offset += \strlen($m[0]);
+
+ foreach (preg_split('//u', $m[0]) as $char) {
+ // test if $char could be appended to current line
+ if (Helper::width($line.$char) <= $width) {
+ $line .= $char;
+ continue;
+ }
+ // if not, push current line to array and make new line
+ $lines[] = str_pad($line, $width);
+ $line = $char;
+ }
+ }
+
+ $lines[] = \count($lines) ? str_pad($line, $width) : $line;
+
+ mb_convert_variables($encoding, 'utf8', $lines);
+
+ return $lines;
+ }
+
+ /**
+ * Returns all namespaces of the command name.
+ *
+ * @return string[]
+ */
+ private function extractAllNamespaces(string $name): array
+ {
+ // -1 as third argument is needed to skip the command short name when exploding
+ $parts = explode(':', $name, -1);
+ $namespaces = [];
+
+ foreach ($parts as $part) {
+ if (\count($namespaces)) {
+ $namespaces[] = end($namespaces).':'.$part;
+ } else {
+ $namespaces[] = $part;
+ }
+ }
+
+ return $namespaces;
+ }
+
+ private function init(): void
+ {
+ if ($this->initialized) {
+ return;
+ }
+ $this->initialized = true;
+
+ foreach ($this->getDefaultCommands() as $command) {
+ $this->add($command);
+ }
+ }
+}
diff --git a/symfony/console/Attribute/AsCommand.php b/symfony/console/Attribute/AsCommand.php
new file mode 100644
index 0000000000000000000000000000000000000000..b337f548f4663e342e4870b6f5d83c4ed71ec716
--- /dev/null
+++ b/symfony/console/Attribute/AsCommand.php
@@ -0,0 +1,39 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Console\Attribute;
+
+/**
+ * Service tag to autoconfigure commands.
+ */
+#[\Attribute(\Attribute::TARGET_CLASS)]
+class AsCommand
+{
+ public function __construct(
+ public string $name,
+ public ?string $description = null,
+ array $aliases = [],
+ bool $hidden = false,
+ ) {
+ if (!$hidden && !$aliases) {
+ return;
+ }
+
+ $name = explode('|', $name);
+ $name = array_merge($name, $aliases);
+
+ if ($hidden && '' !== $name[0]) {
+ array_unshift($name, '');
+ }
+
+ $this->name = implode('|', $name);
+ }
+}
diff --git a/symfony/console/CHANGELOG.md b/symfony/console/CHANGELOG.md
new file mode 100644
index 0000000000000000000000000000000000000000..9ccb41d9457923844e42413ffff114c066cf814a
--- /dev/null
+++ b/symfony/console/CHANGELOG.md
@@ -0,0 +1,261 @@
+CHANGELOG
+=========
+
+6.4
+---
+
+ * Add `SignalMap` to map signal value to its name
+ * Multi-line text in vertical tables is aligned properly
+ * The application can also catch errors with `Application::setCatchErrors(true)`
+ * Add `RunCommandMessage` and `RunCommandMessageHandler`
+ * Dispatch `ConsoleTerminateEvent` after an exit on signal handling and add `ConsoleTerminateEvent::getInterruptingSignal()`
+
+6.3
+---
+
+ * Add support for choosing exit code while handling signal, or to not exit at all
+ * Add `ProgressBar::setPlaceholderFormatter` to set a placeholder attached to a instance, instead of being global.
+ * Add `ReStructuredTextDescriptor`
+
+6.2
+---
+
+ * Improve truecolor terminal detection in some cases
+ * Add support for 256 color terminals (conversion from Ansi24 to Ansi8 if terminal is capable of it)
+ * Deprecate calling `*Command::setApplication()`, `*FormatterStyle::setForeground/setBackground()`, `Helper::setHelpSet()`, `Input*::setDefault()`, `Question::setAutocompleterCallback/setValidator()`without any arguments
+ * Change the signature of `OutputFormatterStyleInterface::setForeground/setBackground()` to `setForeground/setBackground(?string)`
+ * Change the signature of `HelperInterface::setHelperSet()` to `setHelperSet(?HelperSet)`
+
+6.1
+---
+
+ * Add support to display table vertically when calling setVertical()
+ * Add method `__toString()` to `InputInterface`
+ * Added `OutputWrapper` to prevent truncated URL in `SymfonyStyle::createBlock`.
+ * Deprecate `Command::$defaultName` and `Command::$defaultDescription`, use the `AsCommand` attribute instead
+ * Add suggested values for arguments and options in input definition, for input completion
+ * Add `$resumeAt` parameter to `ProgressBar#start()`, so that one can easily 'resume' progress on longer tasks, and still get accurate `getEstimate()` and `getRemaining()` results.
+
+6.0
+---
+
+ * `Command::setHidden()` has a default value (`true`) for `$hidden` parameter and is final
+ * Remove `Helper::strlen()`, use `Helper::width()` instead
+ * Remove `Helper::strlenWithoutDecoration()`, use `Helper::removeDecoration()` instead
+ * `AddConsoleCommandPass` can not be configured anymore
+ * Remove `HelperSet::setCommand()` and `getCommand()` without replacement
+
+5.4
+---
+
+ * Add `TesterTrait::assertCommandIsSuccessful()` to test command
+ * Deprecate `HelperSet::setCommand()` and `getCommand()` without replacement
+
+5.3
+---
+
+ * Add `GithubActionReporter` to render annotations in a Github Action
+ * Add `InputOption::VALUE_NEGATABLE` flag to handle `--foo`/`--no-foo` options
+ * Add the `Command::$defaultDescription` static property and the `description` attribute
+ on the `console.command` tag to allow the `list` command to instantiate commands lazily
+ * Add option `--short` to the `list` command
+ * Add support for bright colors
+ * Add `#[AsCommand]` attribute for declaring commands on PHP 8
+ * Add `Helper::width()` and `Helper::length()`
+ * The `--ansi` and `--no-ansi` options now default to `null`.
+
+5.2.0
+-----
+
+ * Added `SingleCommandApplication::setAutoExit()` to allow testing via `CommandTester`
+ * added support for multiline responses to questions through `Question::setMultiline()`
+ and `Question::isMultiline()`
+ * Added `SignalRegistry` class to stack signals handlers
+ * Added support for signals:
+ * Added `Application::getSignalRegistry()` and `Application::setSignalsToDispatchEvent()` methods
+ * Added `SignalableCommandInterface` interface
+ * Added `TableCellStyle` class to customize table cell
+ * Removed `php ` prefix invocation from help messages.
+
+5.1.0
+-----
+
+ * `Command::setHidden()` is final since Symfony 5.1
+ * Add `SingleCommandApplication`
+ * Add `Cursor` class
+
+5.0.0
+-----
+
+ * removed support for finding hidden commands using an abbreviation, use the full name instead
+ * removed `TableStyle::setCrossingChar()` method in favor of `TableStyle::setDefaultCrossingChar()`
+ * removed `TableStyle::setHorizontalBorderChar()` method in favor of `TableStyle::setDefaultCrossingChars()`
+ * removed `TableStyle::getHorizontalBorderChar()` method in favor of `TableStyle::getBorderChars()`
+ * removed `TableStyle::setVerticalBorderChar()` method in favor of `TableStyle::setVerticalBorderChars()`
+ * removed `TableStyle::getVerticalBorderChar()` method in favor of `TableStyle::getBorderChars()`
+ * removed support for returning `null` from `Command::execute()`, return `0` instead
+ * `ProcessHelper::run()` accepts only `array|Symfony\Component\Process\Process` for its `command` argument
+ * `Application::setDispatcher` accepts only `Symfony\Contracts\EventDispatcher\EventDispatcherInterface`
+ for its `dispatcher` argument
+ * renamed `Application::renderException()` and `Application::doRenderException()`
+ to `renderThrowable()` and `doRenderThrowable()` respectively.
+
+4.4.0
+-----
+
+ * deprecated finding hidden commands using an abbreviation, use the full name instead
+ * added `Question::setTrimmable` default to true to allow the answer to be trimmed
+ * added method `minSecondsBetweenRedraws()` and `maxSecondsBetweenRedraws()` on `ProgressBar`
+ * `Application` implements `ResetInterface`
+ * marked all dispatched event classes as `@final`
+ * added support for displaying table horizontally
+ * deprecated returning `null` from `Command::execute()`, return `0` instead
+ * Deprecated the `Application::renderException()` and `Application::doRenderException()` methods,
+ use `renderThrowable()` and `doRenderThrowable()` instead.
+ * added support for the `NO_COLOR` env var (https://no-color.org/)
+
+4.3.0
+-----
+
+ * added support for hyperlinks
+ * added `ProgressBar::iterate()` method that simplify updating the progress bar when iterating
+ * added `Question::setAutocompleterCallback()` to provide a callback function
+ that dynamically generates suggestions as the user types
+
+4.2.0
+-----
+
+ * allowed passing commands as `[$process, 'ENV_VAR' => 'value']` to
+ `ProcessHelper::run()` to pass environment variables
+ * deprecated passing a command as a string to `ProcessHelper::run()`,
+ pass it the command as an array of its arguments instead
+ * made the `ProcessHelper` class final
+ * added `WrappableOutputFormatterInterface::formatAndWrap()` (implemented in `OutputFormatter`)
+ * added `capture_stderr_separately` option to `CommandTester::execute()`
+
+4.1.0
+-----
+
+ * added option to run suggested command if command is not found and only 1 alternative is available
+ * added option to modify console output and print multiple modifiable sections
+ * added support for iterable messages in output `write` and `writeln` methods
+
+4.0.0
+-----
+
+ * `OutputFormatter` throws an exception when unknown options are used
+ * removed `QuestionHelper::setInputStream()/getInputStream()`
+ * removed `Application::getTerminalWidth()/getTerminalHeight()` and
+ `Application::setTerminalDimensions()/getTerminalDimensions()`
+ * removed `ConsoleExceptionEvent`
+ * removed `ConsoleEvents::EXCEPTION`
+
+3.4.0
+-----
+
+ * added `SHELL_VERBOSITY` env var to control verbosity
+ * added `CommandLoaderInterface`, `FactoryCommandLoader` and PSR-11
+ `ContainerCommandLoader` for commands lazy-loading
+ * added a case-insensitive command name matching fallback
+ * added static `Command::$defaultName/getDefaultName()`, allowing for
+ commands to be registered at compile time in the application command loader.
+ Setting the `$defaultName` property avoids the need for filling the `command`
+ attribute on the `console.command` tag when using `AddConsoleCommandPass`.
+
+3.3.0
+-----
+
+ * added `ExceptionListener`
+ * added `AddConsoleCommandPass` (originally in FrameworkBundle)
+ * [BC BREAK] `Input::getOption()` no longer returns the default value for options
+ with value optional explicitly passed empty
+ * added console.error event to catch exceptions thrown by other listeners
+ * deprecated console.exception event in favor of console.error
+ * added ability to handle `CommandNotFoundException` through the
+ `console.error` event
+ * deprecated default validation in `SymfonyQuestionHelper::ask`
+
+3.2.0
+------
+
+ * added `setInputs()` method to CommandTester for ease testing of commands expecting inputs
+ * added `setStream()` and `getStream()` methods to Input (implement StreamableInputInterface)
+ * added StreamableInputInterface
+ * added LockableTrait
+
+3.1.0
+-----
+
+ * added truncate method to FormatterHelper
+ * added setColumnWidth(s) method to Table
+
+2.8.3
+-----
+
+ * remove readline support from the question helper as it caused issues
+
+2.8.0
+-----
+
+ * use readline for user input in the question helper when available to allow
+ the use of arrow keys
+
+2.6.0
+-----
+
+ * added a Process helper
+ * added a DebugFormatter helper
+
+2.5.0
+-----
+
+ * deprecated the dialog helper (use the question helper instead)
+ * deprecated TableHelper in favor of Table
+ * deprecated ProgressHelper in favor of ProgressBar
+ * added ConsoleLogger
+ * added a question helper
+ * added a way to set the process name of a command
+ * added a way to set a default command instead of `ListCommand`
+
+2.4.0
+-----
+
+ * added a way to force terminal dimensions
+ * added a convenient method to detect verbosity level
+ * [BC BREAK] made descriptors use output instead of returning a string
+
+2.3.0
+-----
+
+ * added multiselect support to the select dialog helper
+ * added Table Helper for tabular data rendering
+ * added support for events in `Application`
+ * added a way to normalize EOLs in `ApplicationTester::getDisplay()` and `CommandTester::getDisplay()`
+ * added a way to set the progress bar progress via the `setCurrent` method
+ * added support for multiple InputOption shortcuts, written as `'-a|-b|-c'`
+ * added two additional verbosity levels, VERBOSITY_VERY_VERBOSE and VERBOSITY_DEBUG
+
+2.2.0
+-----
+
+ * added support for colorization on Windows via ConEmu
+ * add a method to Dialog Helper to ask for a question and hide the response
+ * added support for interactive selections in console (DialogHelper::select())
+ * added support for autocompletion as you type in Dialog Helper
+
+2.1.0
+-----
+
+ * added ConsoleOutputInterface
+ * added the possibility to disable a command (Command::isEnabled())
+ * added suggestions when a command does not exist
+ * added a --raw option to the list command
+ * added support for STDERR in the console output class (errors are now sent
+ to STDERR)
+ * made the defaults (helper set, commands, input definition) in Application
+ more easily customizable
+ * added support for the shell even if readline is not available
+ * added support for process isolation in Symfony shell via
+ `--process-isolation` switch
+ * added support for `--`, which disables options parsing after that point
+ (tokens will be parsed as arguments)
diff --git a/symfony/console/CI/GithubActionReporter.php b/symfony/console/CI/GithubActionReporter.php
new file mode 100644
index 0000000000000000000000000000000000000000..28112c2a299115bf4485ae3388d1cc45f452b6fb
--- /dev/null
+++ b/symfony/console/CI/GithubActionReporter.php
@@ -0,0 +1,99 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Console\CI;
+
+use Symfony\Component\Console\Output\OutputInterface;
+
+/**
+ * Utility class for Github actions.
+ *
+ * @author Maxime Steinhausser
+ */
+class GithubActionReporter
+{
+ private OutputInterface $output;
+
+ /**
+ * @see https://github.com/actions/toolkit/blob/5e5e1b7aacba68a53836a34db4a288c3c1c1585b/packages/core/src/command.ts#L80-L85
+ */
+ private const ESCAPED_DATA = [
+ '%' => '%25',
+ "\r" => '%0D',
+ "\n" => '%0A',
+ ];
+
+ /**
+ * @see https://github.com/actions/toolkit/blob/5e5e1b7aacba68a53836a34db4a288c3c1c1585b/packages/core/src/command.ts#L87-L94
+ */
+ private const ESCAPED_PROPERTIES = [
+ '%' => '%25',
+ "\r" => '%0D',
+ "\n" => '%0A',
+ ':' => '%3A',
+ ',' => '%2C',
+ ];
+
+ public function __construct(OutputInterface $output)
+ {
+ $this->output = $output;
+ }
+
+ public static function isGithubActionEnvironment(): bool
+ {
+ return false !== getenv('GITHUB_ACTIONS');
+ }
+
+ /**
+ * Output an error using the Github annotations format.
+ *
+ * @see https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#setting-an-error-message
+ */
+ public function error(string $message, ?string $file = null, ?int $line = null, ?int $col = null): void
+ {
+ $this->log('error', $message, $file, $line, $col);
+ }
+
+ /**
+ * Output a warning using the Github annotations format.
+ *
+ * @see https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#setting-a-warning-message
+ */
+ public function warning(string $message, ?string $file = null, ?int $line = null, ?int $col = null): void
+ {
+ $this->log('warning', $message, $file, $line, $col);
+ }
+
+ /**
+ * Output a debug log using the Github annotations format.
+ *
+ * @see https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#setting-a-debug-message
+ */
+ public function debug(string $message, ?string $file = null, ?int $line = null, ?int $col = null): void
+ {
+ $this->log('debug', $message, $file, $line, $col);
+ }
+
+ private function log(string $type, string $message, ?string $file = null, ?int $line = null, ?int $col = null): void
+ {
+ // Some values must be encoded.
+ $message = strtr($message, self::ESCAPED_DATA);
+
+ if (!$file) {
+ // No file provided, output the message solely:
+ $this->output->writeln(\sprintf('::%s::%s', $type, $message));
+
+ return;
+ }
+
+ $this->output->writeln(\sprintf('::%s file=%s,line=%s,col=%s::%s', $type, strtr($file, self::ESCAPED_PROPERTIES), strtr($line ?? 1, self::ESCAPED_PROPERTIES), strtr($col ?? 0, self::ESCAPED_PROPERTIES), $message));
+ }
+}
diff --git a/symfony/console/Color.php b/symfony/console/Color.php
new file mode 100644
index 0000000000000000000000000000000000000000..b1914c19ab6fbe3f96792886ca0f266f2d288eac
--- /dev/null
+++ b/symfony/console/Color.php
@@ -0,0 +1,133 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Console;
+
+use Symfony\Component\Console\Exception\InvalidArgumentException;
+
+/**
+ * @author Fabien Potencier
+ */
+final class Color
+{
+ private const COLORS = [
+ 'black' => 0,
+ 'red' => 1,
+ 'green' => 2,
+ 'yellow' => 3,
+ 'blue' => 4,
+ 'magenta' => 5,
+ 'cyan' => 6,
+ 'white' => 7,
+ 'default' => 9,
+ ];
+
+ private const BRIGHT_COLORS = [
+ 'gray' => 0,
+ 'bright-red' => 1,
+ 'bright-green' => 2,
+ 'bright-yellow' => 3,
+ 'bright-blue' => 4,
+ 'bright-magenta' => 5,
+ 'bright-cyan' => 6,
+ 'bright-white' => 7,
+ ];
+
+ private const AVAILABLE_OPTIONS = [
+ 'bold' => ['set' => 1, 'unset' => 22],
+ 'underscore' => ['set' => 4, 'unset' => 24],
+ 'blink' => ['set' => 5, 'unset' => 25],
+ 'reverse' => ['set' => 7, 'unset' => 27],
+ 'conceal' => ['set' => 8, 'unset' => 28],
+ ];
+
+ private string $foreground;
+ private string $background;
+ private array $options = [];
+
+ public function __construct(string $foreground = '', string $background = '', array $options = [])
+ {
+ $this->foreground = $this->parseColor($foreground);
+ $this->background = $this->parseColor($background, true);
+
+ foreach ($options as $option) {
+ if (!isset(self::AVAILABLE_OPTIONS[$option])) {
+ throw new InvalidArgumentException(\sprintf('Invalid option specified: "%s". Expected one of (%s).', $option, implode(', ', array_keys(self::AVAILABLE_OPTIONS))));
+ }
+
+ $this->options[$option] = self::AVAILABLE_OPTIONS[$option];
+ }
+ }
+
+ public function apply(string $text): string
+ {
+ return $this->set().$text.$this->unset();
+ }
+
+ public function set(): string
+ {
+ $setCodes = [];
+ if ('' !== $this->foreground) {
+ $setCodes[] = $this->foreground;
+ }
+ if ('' !== $this->background) {
+ $setCodes[] = $this->background;
+ }
+ foreach ($this->options as $option) {
+ $setCodes[] = $option['set'];
+ }
+ if (0 === \count($setCodes)) {
+ return '';
+ }
+
+ return \sprintf("\033[%sm", implode(';', $setCodes));
+ }
+
+ public function unset(): string
+ {
+ $unsetCodes = [];
+ if ('' !== $this->foreground) {
+ $unsetCodes[] = 39;
+ }
+ if ('' !== $this->background) {
+ $unsetCodes[] = 49;
+ }
+ foreach ($this->options as $option) {
+ $unsetCodes[] = $option['unset'];
+ }
+ if (0 === \count($unsetCodes)) {
+ return '';
+ }
+
+ return \sprintf("\033[%sm", implode(';', $unsetCodes));
+ }
+
+ private function parseColor(string $color, bool $background = false): string
+ {
+ if ('' === $color) {
+ return '';
+ }
+
+ if ('#' === $color[0]) {
+ return ($background ? '4' : '3').Terminal::getColorMode()->convertFromHexToAnsiColorCode($color);
+ }
+
+ if (isset(self::COLORS[$color])) {
+ return ($background ? '4' : '3').self::COLORS[$color];
+ }
+
+ if (isset(self::BRIGHT_COLORS[$color])) {
+ return ($background ? '10' : '9').self::BRIGHT_COLORS[$color];
+ }
+
+ throw new InvalidArgumentException(\sprintf('Invalid "%s" color; expected one of (%s).', $color, implode(', ', array_merge(array_keys(self::COLORS), array_keys(self::BRIGHT_COLORS)))));
+ }
+}
diff --git a/symfony/console/Command/Command.php b/symfony/console/Command/Command.php
new file mode 100644
index 0000000000000000000000000000000000000000..3ede6ca6bbc532925dab85f5cf1a567b1d113d5c
--- /dev/null
+++ b/symfony/console/Command/Command.php
@@ -0,0 +1,725 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Console\Command;
+
+use Symfony\Component\Console\Application;
+use Symfony\Component\Console\Attribute\AsCommand;
+use Symfony\Component\Console\Completion\CompletionInput;
+use Symfony\Component\Console\Completion\CompletionSuggestions;
+use Symfony\Component\Console\Completion\Suggestion;
+use Symfony\Component\Console\Exception\ExceptionInterface;
+use Symfony\Component\Console\Exception\InvalidArgumentException;
+use Symfony\Component\Console\Exception\LogicException;
+use Symfony\Component\Console\Helper\HelperInterface;
+use Symfony\Component\Console\Helper\HelperSet;
+use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Input\InputDefinition;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Output\OutputInterface;
+
+/**
+ * Base class for all commands.
+ *
+ * @author Fabien Potencier
+ */
+class Command
+{
+ // see https://tldp.org/LDP/abs/html/exitcodes.html
+ public const SUCCESS = 0;
+ public const FAILURE = 1;
+ public const INVALID = 2;
+
+ /**
+ * @var string|null The default command name
+ *
+ * @deprecated since Symfony 6.1, use the AsCommand attribute instead
+ */
+ protected static $defaultName;
+
+ /**
+ * @var string|null The default command description
+ *
+ * @deprecated since Symfony 6.1, use the AsCommand attribute instead
+ */
+ protected static $defaultDescription;
+
+ private ?Application $application = null;
+ private ?string $name = null;
+ private ?string $processTitle = null;
+ private array $aliases = [];
+ private InputDefinition $definition;
+ private bool $hidden = false;
+ private string $help = '';
+ private string $description = '';
+ private ?InputDefinition $fullDefinition = null;
+ private bool $ignoreValidationErrors = false;
+ private ?\Closure $code = null;
+ private array $synopsis = [];
+ private array $usages = [];
+ private ?HelperSet $helperSet = null;
+
+ public static function getDefaultName(): ?string
+ {
+ $class = static::class;
+
+ if ($attribute = (new \ReflectionClass($class))->getAttributes(AsCommand::class)) {
+ return $attribute[0]->newInstance()->name;
+ }
+
+ $r = new \ReflectionProperty($class, 'defaultName');
+
+ if ($class !== $r->class || null === static::$defaultName) {
+ return null;
+ }
+
+ trigger_deprecation('symfony/console', '6.1', 'Relying on the static property "$defaultName" for setting a command name is deprecated. Add the "%s" attribute to the "%s" class instead.', AsCommand::class, static::class);
+
+ return static::$defaultName;
+ }
+
+ public static function getDefaultDescription(): ?string
+ {
+ $class = static::class;
+
+ if ($attribute = (new \ReflectionClass($class))->getAttributes(AsCommand::class)) {
+ return $attribute[0]->newInstance()->description;
+ }
+
+ $r = new \ReflectionProperty($class, 'defaultDescription');
+
+ if ($class !== $r->class || null === static::$defaultDescription) {
+ return null;
+ }
+
+ trigger_deprecation('symfony/console', '6.1', 'Relying on the static property "$defaultDescription" for setting a command description is deprecated. Add the "%s" attribute to the "%s" class instead.', AsCommand::class, static::class);
+
+ return static::$defaultDescription;
+ }
+
+ /**
+ * @param string|null $name The name of the command; passing null means it must be set in configure()
+ *
+ * @throws LogicException When the command name is empty
+ */
+ public function __construct(?string $name = null)
+ {
+ $this->definition = new InputDefinition();
+
+ if (null === $name && null !== $name = static::getDefaultName()) {
+ $aliases = explode('|', $name);
+
+ if ('' === $name = array_shift($aliases)) {
+ $this->setHidden(true);
+ $name = array_shift($aliases);
+ }
+
+ $this->setAliases($aliases);
+ }
+
+ if (null !== $name) {
+ $this->setName($name);
+ }
+
+ if ('' === $this->description) {
+ $this->setDescription(static::getDefaultDescription() ?? '');
+ }
+
+ $this->configure();
+ }
+
+ /**
+ * Ignores validation errors.
+ *
+ * This is mainly useful for the help command.
+ *
+ * @return void
+ */
+ public function ignoreValidationErrors()
+ {
+ $this->ignoreValidationErrors = true;
+ }
+
+ /**
+ * @return void
+ */
+ public function setApplication(?Application $application = null)
+ {
+ if (1 > \func_num_args()) {
+ trigger_deprecation('symfony/console', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__);
+ }
+ $this->application = $application;
+ if ($application) {
+ $this->setHelperSet($application->getHelperSet());
+ } else {
+ $this->helperSet = null;
+ }
+
+ $this->fullDefinition = null;
+ }
+
+ /**
+ * @return void
+ */
+ public function setHelperSet(HelperSet $helperSet)
+ {
+ $this->helperSet = $helperSet;
+ }
+
+ /**
+ * Gets the helper set.
+ */
+ public function getHelperSet(): ?HelperSet
+ {
+ return $this->helperSet;
+ }
+
+ /**
+ * Gets the application instance for this command.
+ */
+ public function getApplication(): ?Application
+ {
+ return $this->application;
+ }
+
+ /**
+ * Checks whether the command is enabled or not in the current environment.
+ *
+ * Override this to check for x or y and return false if the command cannot
+ * run properly under the current conditions.
+ *
+ * @return bool
+ */
+ public function isEnabled()
+ {
+ return true;
+ }
+
+ /**
+ * Configures the current command.
+ *
+ * @return void
+ */
+ protected function configure()
+ {
+ }
+
+ /**
+ * Executes the current command.
+ *
+ * This method is not abstract because you can use this class
+ * as a concrete class. In this case, instead of defining the
+ * execute() method, you set the code to execute by passing
+ * a Closure to the setCode() method.
+ *
+ * @return int 0 if everything went fine, or an exit code
+ *
+ * @throws LogicException When this abstract method is not implemented
+ *
+ * @see setCode()
+ */
+ protected function execute(InputInterface $input, OutputInterface $output)
+ {
+ throw new LogicException('You must override the execute() method in the concrete command class.');
+ }
+
+ /**
+ * Interacts with the user.
+ *
+ * This method is executed before the InputDefinition is validated.
+ * This means that this is the only place where the command can
+ * interactively ask for values of missing required arguments.
+ *
+ * @return void
+ */
+ protected function interact(InputInterface $input, OutputInterface $output)
+ {
+ }
+
+ /**
+ * Initializes the command after the input has been bound and before the input
+ * is validated.
+ *
+ * This is mainly useful when a lot of commands extends one main command
+ * where some things need to be initialized based on the input arguments and options.
+ *
+ * @see InputInterface::bind()
+ * @see InputInterface::validate()
+ *
+ * @return void
+ */
+ protected function initialize(InputInterface $input, OutputInterface $output)
+ {
+ }
+
+ /**
+ * Runs the command.
+ *
+ * The code to execute is either defined directly with the
+ * setCode() method or by overriding the execute() method
+ * in a sub-class.
+ *
+ * @return int The command exit code
+ *
+ * @throws ExceptionInterface When input binding fails. Bypass this by calling {@link ignoreValidationErrors()}.
+ *
+ * @see setCode()
+ * @see execute()
+ */
+ public function run(InputInterface $input, OutputInterface $output): int
+ {
+ // add the application arguments and options
+ $this->mergeApplicationDefinition();
+
+ // bind the input against the command specific arguments/options
+ try {
+ $input->bind($this->getDefinition());
+ } catch (ExceptionInterface $e) {
+ if (!$this->ignoreValidationErrors) {
+ throw $e;
+ }
+ }
+
+ $this->initialize($input, $output);
+
+ if (null !== $this->processTitle) {
+ if (\function_exists('cli_set_process_title')) {
+ if (!@cli_set_process_title($this->processTitle)) {
+ if ('Darwin' === \PHP_OS) {
+ $output->writeln('Running "cli_set_process_title" as an unprivileged user is not supported on MacOS.', OutputInterface::VERBOSITY_VERY_VERBOSE);
+ } else {
+ cli_set_process_title($this->processTitle);
+ }
+ }
+ } elseif (\function_exists('setproctitle')) {
+ setproctitle($this->processTitle);
+ } elseif (OutputInterface::VERBOSITY_VERY_VERBOSE === $output->getVerbosity()) {
+ $output->writeln('Install the proctitle PECL to be able to change the process title.');
+ }
+ }
+
+ if ($input->isInteractive()) {
+ $this->interact($input, $output);
+ }
+
+ // The command name argument is often omitted when a command is executed directly with its run() method.
+ // It would fail the validation if we didn't make sure the command argument is present,
+ // since it's required by the application.
+ if ($input->hasArgument('command') && null === $input->getArgument('command')) {
+ $input->setArgument('command', $this->getName());
+ }
+
+ $input->validate();
+
+ if ($this->code) {
+ $statusCode = ($this->code)($input, $output);
+ } else {
+ $statusCode = $this->execute($input, $output);
+
+ if (!\is_int($statusCode)) {
+ throw new \TypeError(\sprintf('Return value of "%s::execute()" must be of the type int, "%s" returned.', static::class, get_debug_type($statusCode)));
+ }
+ }
+
+ return is_numeric($statusCode) ? (int) $statusCode : 0;
+ }
+
+ /**
+ * Adds suggestions to $suggestions for the current completion input (e.g. option or argument).
+ */
+ public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
+ {
+ $definition = $this->getDefinition();
+ if (CompletionInput::TYPE_OPTION_VALUE === $input->getCompletionType() && $definition->hasOption($input->getCompletionName())) {
+ $definition->getOption($input->getCompletionName())->complete($input, $suggestions);
+ } elseif (CompletionInput::TYPE_ARGUMENT_VALUE === $input->getCompletionType() && $definition->hasArgument($input->getCompletionName())) {
+ $definition->getArgument($input->getCompletionName())->complete($input, $suggestions);
+ }
+ }
+
+ /**
+ * Sets the code to execute when running this command.
+ *
+ * If this method is used, it overrides the code defined
+ * in the execute() method.
+ *
+ * @param callable $code A callable(InputInterface $input, OutputInterface $output)
+ *
+ * @return $this
+ *
+ * @throws InvalidArgumentException
+ *
+ * @see execute()
+ */
+ public function setCode(callable $code): static
+ {
+ if ($code instanceof \Closure) {
+ $r = new \ReflectionFunction($code);
+ if (null === $r->getClosureThis()) {
+ set_error_handler(static function () {});
+ try {
+ if ($c = \Closure::bind($code, $this)) {
+ $code = $c;
+ }
+ } finally {
+ restore_error_handler();
+ }
+ }
+ } else {
+ $code = $code(...);
+ }
+
+ $this->code = $code;
+
+ return $this;
+ }
+
+ /**
+ * Merges the application definition with the command definition.
+ *
+ * This method is not part of public API and should not be used directly.
+ *
+ * @param bool $mergeArgs Whether to merge or not the Application definition arguments to Command definition arguments
+ *
+ * @internal
+ */
+ public function mergeApplicationDefinition(bool $mergeArgs = true): void
+ {
+ if (null === $this->application) {
+ return;
+ }
+
+ $this->fullDefinition = new InputDefinition();
+ $this->fullDefinition->setOptions($this->definition->getOptions());
+ $this->fullDefinition->addOptions($this->application->getDefinition()->getOptions());
+
+ if ($mergeArgs) {
+ $this->fullDefinition->setArguments($this->application->getDefinition()->getArguments());
+ $this->fullDefinition->addArguments($this->definition->getArguments());
+ } else {
+ $this->fullDefinition->setArguments($this->definition->getArguments());
+ }
+ }
+
+ /**
+ * Sets an array of argument and option instances.
+ *
+ * @return $this
+ */
+ public function setDefinition(array|InputDefinition $definition): static
+ {
+ if ($definition instanceof InputDefinition) {
+ $this->definition = $definition;
+ } else {
+ $this->definition->setDefinition($definition);
+ }
+
+ $this->fullDefinition = null;
+
+ return $this;
+ }
+
+ /**
+ * Gets the InputDefinition attached to this Command.
+ */
+ public function getDefinition(): InputDefinition
+ {
+ return $this->fullDefinition ?? $this->getNativeDefinition();
+ }
+
+ /**
+ * Gets the InputDefinition to be used to create representations of this Command.
+ *
+ * Can be overridden to provide the original command representation when it would otherwise
+ * be changed by merging with the application InputDefinition.
+ *
+ * This method is not part of public API and should not be used directly.
+ */
+ public function getNativeDefinition(): InputDefinition
+ {
+ return $this->definition ?? throw new LogicException(\sprintf('Command class "%s" is not correctly initialized. You probably forgot to call the parent constructor.', static::class));
+ }
+
+ /**
+ * Adds an argument.
+ *
+ * @param $mode The argument mode: InputArgument::REQUIRED or InputArgument::OPTIONAL
+ * @param $default The default value (for InputArgument::OPTIONAL mode only)
+ * @param array|\Closure(CompletionInput,CompletionSuggestions):list $suggestedValues The values used for input completion
+ *
+ * @return $this
+ *
+ * @throws InvalidArgumentException When argument mode is not valid
+ */
+ public function addArgument(string $name, ?int $mode = null, string $description = '', mixed $default = null /* array|\Closure $suggestedValues = null */): static
+ {
+ $suggestedValues = 5 <= \func_num_args() ? func_get_arg(4) : [];
+ if (!\is_array($suggestedValues) && !$suggestedValues instanceof \Closure) {
+ throw new \TypeError(\sprintf('Argument 5 passed to "%s()" must be array or \Closure, "%s" given.', __METHOD__, get_debug_type($suggestedValues)));
+ }
+ $this->definition->addArgument(new InputArgument($name, $mode, $description, $default, $suggestedValues));
+ $this->fullDefinition?->addArgument(new InputArgument($name, $mode, $description, $default, $suggestedValues));
+
+ return $this;
+ }
+
+ /**
+ * Adds an option.
+ *
+ * @param $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts
+ * @param $mode The option mode: One of the InputOption::VALUE_* constants
+ * @param $default The default value (must be null for InputOption::VALUE_NONE)
+ * @param array|\Closure(CompletionInput,CompletionSuggestions):list $suggestedValues The values used for input completion
+ *
+ * @return $this
+ *
+ * @throws InvalidArgumentException If option mode is invalid or incompatible
+ */
+ public function addOption(string $name, string|array|null $shortcut = null, ?int $mode = null, string $description = '', mixed $default = null /* array|\Closure $suggestedValues = [] */): static
+ {
+ $suggestedValues = 6 <= \func_num_args() ? func_get_arg(5) : [];
+ if (!\is_array($suggestedValues) && !$suggestedValues instanceof \Closure) {
+ throw new \TypeError(\sprintf('Argument 5 passed to "%s()" must be array or \Closure, "%s" given.', __METHOD__, get_debug_type($suggestedValues)));
+ }
+ $this->definition->addOption(new InputOption($name, $shortcut, $mode, $description, $default, $suggestedValues));
+ $this->fullDefinition?->addOption(new InputOption($name, $shortcut, $mode, $description, $default, $suggestedValues));
+
+ return $this;
+ }
+
+ /**
+ * Sets the name of the command.
+ *
+ * This method can set both the namespace and the name if
+ * you separate them by a colon (:)
+ *
+ * $command->setName('foo:bar');
+ *
+ * @return $this
+ *
+ * @throws InvalidArgumentException When the name is invalid
+ */
+ public function setName(string $name): static
+ {
+ $this->validateName($name);
+
+ $this->name = $name;
+
+ return $this;
+ }
+
+ /**
+ * Sets the process title of the command.
+ *
+ * This feature should be used only when creating a long process command,
+ * like a daemon.
+ *
+ * @return $this
+ */
+ public function setProcessTitle(string $title): static
+ {
+ $this->processTitle = $title;
+
+ return $this;
+ }
+
+ /**
+ * Returns the command name.
+ */
+ public function getName(): ?string
+ {
+ return $this->name;
+ }
+
+ /**
+ * @param bool $hidden Whether or not the command should be hidden from the list of commands
+ *
+ * @return $this
+ */
+ public function setHidden(bool $hidden = true): static
+ {
+ $this->hidden = $hidden;
+
+ return $this;
+ }
+
+ /**
+ * @return bool whether the command should be publicly shown or not
+ */
+ public function isHidden(): bool
+ {
+ return $this->hidden;
+ }
+
+ /**
+ * Sets the description for the command.
+ *
+ * @return $this
+ */
+ public function setDescription(string $description): static
+ {
+ $this->description = $description;
+
+ return $this;
+ }
+
+ /**
+ * Returns the description for the command.
+ */
+ public function getDescription(): string
+ {
+ return $this->description;
+ }
+
+ /**
+ * Sets the help for the command.
+ *
+ * @return $this
+ */
+ public function setHelp(string $help): static
+ {
+ $this->help = $help;
+
+ return $this;
+ }
+
+ /**
+ * Returns the help for the command.
+ */
+ public function getHelp(): string
+ {
+ return $this->help;
+ }
+
+ /**
+ * Returns the processed help for the command replacing the %command.name% and
+ * %command.full_name% patterns with the real values dynamically.
+ */
+ public function getProcessedHelp(): string
+ {
+ $name = $this->name;
+ $isSingleCommand = $this->application?->isSingleCommand();
+
+ $placeholders = [
+ '%command.name%',
+ '%command.full_name%',
+ ];
+ $replacements = [
+ $name,
+ $isSingleCommand ? $_SERVER['PHP_SELF'] : $_SERVER['PHP_SELF'].' '.$name,
+ ];
+
+ return str_replace($placeholders, $replacements, $this->getHelp() ?: $this->getDescription());
+ }
+
+ /**
+ * Sets the aliases for the command.
+ *
+ * @param string[] $aliases An array of aliases for the command
+ *
+ * @return $this
+ *
+ * @throws InvalidArgumentException When an alias is invalid
+ */
+ public function setAliases(iterable $aliases): static
+ {
+ $list = [];
+
+ foreach ($aliases as $alias) {
+ $this->validateName($alias);
+ $list[] = $alias;
+ }
+
+ $this->aliases = \is_array($aliases) ? $aliases : $list;
+
+ return $this;
+ }
+
+ /**
+ * Returns the aliases for the command.
+ */
+ public function getAliases(): array
+ {
+ return $this->aliases;
+ }
+
+ /**
+ * Returns the synopsis for the command.
+ *
+ * @param bool $short Whether to show the short version of the synopsis (with options folded) or not
+ */
+ public function getSynopsis(bool $short = false): string
+ {
+ $key = $short ? 'short' : 'long';
+
+ if (!isset($this->synopsis[$key])) {
+ $this->synopsis[$key] = trim(\sprintf('%s %s', $this->name, $this->definition->getSynopsis($short)));
+ }
+
+ return $this->synopsis[$key];
+ }
+
+ /**
+ * Add a command usage example, it'll be prefixed with the command name.
+ *
+ * @return $this
+ */
+ public function addUsage(string $usage): static
+ {
+ if (!str_starts_with($usage, $this->name)) {
+ $usage = \sprintf('%s %s', $this->name, $usage);
+ }
+
+ $this->usages[] = $usage;
+
+ return $this;
+ }
+
+ /**
+ * Returns alternative usages of the command.
+ */
+ public function getUsages(): array
+ {
+ return $this->usages;
+ }
+
+ /**
+ * Gets a helper instance by name.
+ *
+ * @return HelperInterface
+ *
+ * @throws LogicException if no HelperSet is defined
+ * @throws InvalidArgumentException if the helper is not defined
+ */
+ public function getHelper(string $name): mixed
+ {
+ if (null === $this->helperSet) {
+ throw new LogicException(\sprintf('Cannot retrieve helper "%s" because there is no HelperSet defined. Did you forget to add your command to the application or to set the application on the command using the setApplication() method? You can also set the HelperSet directly using the setHelperSet() method.', $name));
+ }
+
+ return $this->helperSet->get($name);
+ }
+
+ /**
+ * Validates a command name.
+ *
+ * It must be non-empty and parts can optionally be separated by ":".
+ *
+ * @throws InvalidArgumentException When the name is invalid
+ */
+ private function validateName(string $name): void
+ {
+ if (!preg_match('/^[^\:]++(\:[^\:]++)*$/', $name)) {
+ throw new InvalidArgumentException(\sprintf('Command name "%s" is invalid.', $name));
+ }
+ }
+}
diff --git a/symfony/console/Command/CompleteCommand.php b/symfony/console/Command/CompleteCommand.php
new file mode 100644
index 0000000000000000000000000000000000000000..33f7f93c8f9e0b7267598e7ba2b13b56eb117695
--- /dev/null
+++ b/symfony/console/Command/CompleteCommand.php
@@ -0,0 +1,223 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Console\Command;
+
+use Symfony\Component\Console\Attribute\AsCommand;
+use Symfony\Component\Console\Completion\CompletionInput;
+use Symfony\Component\Console\Completion\CompletionSuggestions;
+use Symfony\Component\Console\Completion\Output\BashCompletionOutput;
+use Symfony\Component\Console\Completion\Output\CompletionOutputInterface;
+use Symfony\Component\Console\Completion\Output\FishCompletionOutput;
+use Symfony\Component\Console\Completion\Output\ZshCompletionOutput;
+use Symfony\Component\Console\Exception\CommandNotFoundException;
+use Symfony\Component\Console\Exception\ExceptionInterface;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Output\OutputInterface;
+
+/**
+ * Responsible for providing the values to the shell completion.
+ *
+ * @author Wouter de Jong
+ */
+#[AsCommand(name: '|_complete', description: 'Internal command to provide shell completion suggestions')]
+final class CompleteCommand extends Command
+{
+ public const COMPLETION_API_VERSION = '1';
+
+ /**
+ * @deprecated since Symfony 6.1
+ */
+ protected static $defaultName = '|_complete';
+
+ /**
+ * @deprecated since Symfony 6.1
+ */
+ protected static $defaultDescription = 'Internal command to provide shell completion suggestions';
+
+ private array $completionOutputs;
+
+ private bool $isDebug = false;
+
+ /**
+ * @param array> $completionOutputs A list of additional completion outputs, with shell name as key and FQCN as value
+ */
+ public function __construct(array $completionOutputs = [])
+ {
+ // must be set before the parent constructor, as the property value is used in configure()
+ $this->completionOutputs = $completionOutputs + [
+ 'bash' => BashCompletionOutput::class,
+ 'fish' => FishCompletionOutput::class,
+ 'zsh' => ZshCompletionOutput::class,
+ ];
+
+ parent::__construct();
+ }
+
+ protected function configure(): void
+ {
+ $this
+ ->addOption('shell', 's', InputOption::VALUE_REQUIRED, 'The shell type ("'.implode('", "', array_keys($this->completionOutputs)).'")')
+ ->addOption('input', 'i', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'An array of input tokens (e.g. COMP_WORDS or argv)')
+ ->addOption('current', 'c', InputOption::VALUE_REQUIRED, 'The index of the "input" array that the cursor is in (e.g. COMP_CWORD)')
+ ->addOption('api-version', 'a', InputOption::VALUE_REQUIRED, 'The API version of the completion script')
+ ->addOption('symfony', 'S', InputOption::VALUE_REQUIRED, 'deprecated')
+ ;
+ }
+
+ protected function initialize(InputInterface $input, OutputInterface $output): void
+ {
+ $this->isDebug = filter_var(getenv('SYMFONY_COMPLETION_DEBUG'), \FILTER_VALIDATE_BOOL);
+ }
+
+ protected function execute(InputInterface $input, OutputInterface $output): int
+ {
+ try {
+ // "symfony" must be kept for compat with the shell scripts generated by Symfony Console 5.4 - 6.1
+ $version = $input->getOption('symfony') ? '1' : $input->getOption('api-version');
+ if ($version && version_compare($version, self::COMPLETION_API_VERSION, '<')) {
+ $message = \sprintf('Completion script version is not supported ("%s" given, ">=%s" required).', $version, self::COMPLETION_API_VERSION);
+ $this->log($message);
+
+ $output->writeln($message.' Install the Symfony completion script again by using the "completion" command.');
+
+ return 126;
+ }
+
+ $shell = $input->getOption('shell');
+ if (!$shell) {
+ throw new \RuntimeException('The "--shell" option must be set.');
+ }
+
+ if (!$completionOutput = $this->completionOutputs[$shell] ?? false) {
+ throw new \RuntimeException(\sprintf('Shell completion is not supported for your shell: "%s" (supported: "%s").', $shell, implode('", "', array_keys($this->completionOutputs))));
+ }
+
+ $completionInput = $this->createCompletionInput($input);
+ $suggestions = new CompletionSuggestions();
+
+ $this->log([
+ '',
+ ''.date('Y-m-d H:i:s').'>',
+ 'Input:> ("|" indicates the cursor position)>',
+ ' '.(string) $completionInput,
+ 'Command:>',
+ ' '.(string) implode(' ', $_SERVER['argv']),
+ 'Messages:>',
+ ]);
+
+ $command = $this->findCommand($completionInput, $output);
+ if (null === $command) {
+ $this->log(' No command found, completing using the Application class.');
+
+ $this->getApplication()->complete($completionInput, $suggestions);
+ } elseif (
+ $completionInput->mustSuggestArgumentValuesFor('command')
+ && $command->getName() !== $completionInput->getCompletionValue()
+ && !\in_array($completionInput->getCompletionValue(), $command->getAliases(), true)
+ ) {
+ $this->log(' No command found, completing using the Application class.');
+
+ // expand shortcut names ("cache:cl") into their full name ("cache:clear")
+ $suggestions->suggestValues(array_filter(array_merge([$command->getName()], $command->getAliases())));
+ } else {
+ $command->mergeApplicationDefinition();
+ $completionInput->bind($command->getDefinition());
+
+ if (CompletionInput::TYPE_OPTION_NAME === $completionInput->getCompletionType()) {
+ $this->log(' Completing option names for the '.($command instanceof LazyCommand ? $command->getCommand() : $command)::class.'> command.');
+
+ $suggestions->suggestOptions($command->getDefinition()->getOptions());
+ } else {
+ $this->log([
+ ' Completing using the '.($command instanceof LazyCommand ? $command->getCommand() : $command)::class.'> class.',
+ ' Completing '.$completionInput->getCompletionType().'> for '.$completionInput->getCompletionName().'>',
+ ]);
+ if (null !== $compval = $completionInput->getCompletionValue()) {
+ $this->log(' Current value: '.$compval.'>');
+ }
+
+ $command->complete($completionInput, $suggestions);
+ }
+ }
+
+ /** @var CompletionOutputInterface $completionOutput */
+ $completionOutput = new $completionOutput();
+
+ $this->log('Suggestions:>');
+ if ($options = $suggestions->getOptionSuggestions()) {
+ $this->log(' --'.implode(' --', array_map(fn ($o) => $o->getName(), $options)));
+ } elseif ($values = $suggestions->getValueSuggestions()) {
+ $this->log(' '.implode(' ', $values));
+ } else {
+ $this->log(' No suggestions were provided>');
+ }
+
+ $completionOutput->write($suggestions, $output);
+ } catch (\Throwable $e) {
+ $this->log([
+ 'Error!',
+ (string) $e,
+ ]);
+
+ if ($output->isDebug()) {
+ throw $e;
+ }
+
+ return 2;
+ }
+
+ return 0;
+ }
+
+ private function createCompletionInput(InputInterface $input): CompletionInput
+ {
+ $currentIndex = $input->getOption('current');
+ if (!$currentIndex || !ctype_digit($currentIndex)) {
+ throw new \RuntimeException('The "--current" option must be set and it must be an integer.');
+ }
+
+ $completionInput = CompletionInput::fromTokens($input->getOption('input'), (int) $currentIndex);
+
+ try {
+ $completionInput->bind($this->getApplication()->getDefinition());
+ } catch (ExceptionInterface) {
+ }
+
+ return $completionInput;
+ }
+
+ private function findCommand(CompletionInput $completionInput, OutputInterface $output): ?Command
+ {
+ try {
+ $inputName = $completionInput->getFirstArgument();
+ if (null === $inputName) {
+ return null;
+ }
+
+ return $this->getApplication()->find($inputName);
+ } catch (CommandNotFoundException) {
+ }
+
+ return null;
+ }
+
+ private function log($messages): void
+ {
+ if (!$this->isDebug) {
+ return;
+ }
+
+ $commandName = basename($_SERVER['argv'][0]);
+ file_put_contents(sys_get_temp_dir().'/sf_'.$commandName.'.log', implode(\PHP_EOL, (array) $messages).\PHP_EOL, \FILE_APPEND);
+ }
+}
diff --git a/symfony/console/Command/DumpCompletionCommand.php b/symfony/console/Command/DumpCompletionCommand.php
new file mode 100644
index 0000000000000000000000000000000000000000..571425b88a8a665cd6580729343f63932ea914b5
--- /dev/null
+++ b/symfony/console/Command/DumpCompletionCommand.php
@@ -0,0 +1,161 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Console\Command;
+
+use Symfony\Component\Console\Attribute\AsCommand;
+use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Output\ConsoleOutputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Process\Process;
+
+/**
+ * Dumps the completion script for the current shell.
+ *
+ * @author Wouter de Jong
+ */
+#[AsCommand(name: 'completion', description: 'Dump the shell completion script')]
+final class DumpCompletionCommand extends Command
+{
+ /**
+ * @deprecated since Symfony 6.1
+ */
+ protected static $defaultName = 'completion';
+
+ /**
+ * @deprecated since Symfony 6.1
+ */
+ protected static $defaultDescription = 'Dump the shell completion script';
+
+ private array $supportedShells;
+
+ protected function configure(): void
+ {
+ $fullCommand = $_SERVER['PHP_SELF'];
+ $commandName = basename($fullCommand);
+ $fullCommand = @realpath($fullCommand) ?: $fullCommand;
+
+ $shell = $this->guessShell();
+ [$rcFile, $completionFile] = match ($shell) {
+ 'fish' => ['~/.config/fish/config.fish', "/etc/fish/completions/$commandName.fish"],
+ 'zsh' => ['~/.zshrc', '$fpath[1]/_'.$commandName],
+ default => ['~/.bashrc', "/etc/bash_completion.d/$commandName"],
+ };
+
+ $supportedShells = implode(', ', $this->getSupportedShells());
+
+ $this
+ ->setHelp(<<%command.name%> command dumps the shell completion script required
+to use shell autocompletion (currently, {$supportedShells} completion are supported).
+
+Static installation
+------------------->
+
+Dump the script to a global completion file and restart your shell:
+
+ %command.full_name% {$shell} | sudo tee {$completionFile}>
+
+Or dump the script to a local file and source it:
+
+ %command.full_name% {$shell} > completion.sh>
+
+ # source the file whenever you use the project>
+ source completion.sh>
+
+ # or add this line at the end of your "{$rcFile}" file:>
+ source /path/to/completion.sh>
+
+Dynamic installation
+-------------------->
+
+Add this to the end of your shell configuration file (e.g. "{$rcFile}">):
+
+ eval "$({$fullCommand} completion {$shell})">
+EOH
+ )
+ ->addArgument('shell', InputArgument::OPTIONAL, 'The shell type (e.g. "bash"), the value of the "$SHELL" env var will be used if this is not given', null, $this->getSupportedShells(...))
+ ->addOption('debug', null, InputOption::VALUE_NONE, 'Tail the completion debug log')
+ ;
+ }
+
+ protected function execute(InputInterface $input, OutputInterface $output): int
+ {
+ $commandName = basename($_SERVER['argv'][0]);
+
+ if ($input->getOption('debug')) {
+ $this->tailDebugLog($commandName, $output);
+
+ return 0;
+ }
+
+ $shell = $input->getArgument('shell') ?? self::guessShell();
+ $completionFile = __DIR__.'/../Resources/completion.'.$shell;
+ if (!file_exists($completionFile)) {
+ $supportedShells = $this->getSupportedShells();
+
+ if ($output instanceof ConsoleOutputInterface) {
+ $output = $output->getErrorOutput();
+ }
+ if ($shell) {
+ $output->writeln(\sprintf('Detected shell "%s", which is not supported by Symfony shell completion (supported shells: "%s").>', $shell, implode('", "', $supportedShells)));
+ } else {
+ $output->writeln(\sprintf('Shell not detected, Symfony shell completion only supports "%s").>', implode('", "', $supportedShells)));
+ }
+
+ return 2;
+ }
+
+ $output->write(str_replace(['{{ COMMAND_NAME }}', '{{ VERSION }}'], [$commandName, CompleteCommand::COMPLETION_API_VERSION], file_get_contents($completionFile)));
+
+ return 0;
+ }
+
+ private static function guessShell(): string
+ {
+ return basename($_SERVER['SHELL'] ?? '');
+ }
+
+ private function tailDebugLog(string $commandName, OutputInterface $output): void
+ {
+ $debugFile = sys_get_temp_dir().'/sf_'.$commandName.'.log';
+ if (!file_exists($debugFile)) {
+ touch($debugFile);
+ }
+ $process = new Process(['tail', '-f', $debugFile], null, null, null, 0);
+ $process->run(function (string $type, string $line) use ($output): void {
+ $output->write($line);
+ });
+ }
+
+ /**
+ * @return string[]
+ */
+ private function getSupportedShells(): array
+ {
+ if (isset($this->supportedShells)) {
+ return $this->supportedShells;
+ }
+
+ $shells = [];
+
+ foreach (new \DirectoryIterator(__DIR__.'/../Resources/') as $file) {
+ if (str_starts_with($file->getBasename(), 'completion.') && $file->isFile()) {
+ $shells[] = $file->getExtension();
+ }
+ }
+ sort($shells);
+
+ return $this->supportedShells = $shells;
+ }
+}
diff --git a/symfony/console/Command/HelpCommand.php b/symfony/console/Command/HelpCommand.php
new file mode 100644
index 0000000000000000000000000000000000000000..e6447b0506b8f59c2a94c405b43b89b0fd87a52c
--- /dev/null
+++ b/symfony/console/Command/HelpCommand.php
@@ -0,0 +1,82 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Console\Command;
+
+use Symfony\Component\Console\Descriptor\ApplicationDescription;
+use Symfony\Component\Console\Helper\DescriptorHelper;
+use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Output\OutputInterface;
+
+/**
+ * HelpCommand displays the help for a given command.
+ *
+ * @author Fabien Potencier
+ */
+class HelpCommand extends Command
+{
+ private Command $command;
+
+ /**
+ * @return void
+ */
+ protected function configure()
+ {
+ $this->ignoreValidationErrors();
+
+ $this
+ ->setName('help')
+ ->setDefinition([
+ new InputArgument('command_name', InputArgument::OPTIONAL, 'The command name', 'help', fn () => array_keys((new ApplicationDescription($this->getApplication()))->getCommands())),
+ new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt', fn () => (new DescriptorHelper())->getFormats()),
+ new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command help'),
+ ])
+ ->setDescription('Display help for a command')
+ ->setHelp(<<<'EOF'
+The %command.name% command displays help for a given command:
+
+ %command.full_name% list
+
+You can also output the help in other formats by using the --format option:
+
+ %command.full_name% --format=xml list
+
+To display the list of available commands, please use the list command.
+EOF
+ )
+ ;
+ }
+
+ /**
+ * @return void
+ */
+ public function setCommand(Command $command)
+ {
+ $this->command = $command;
+ }
+
+ protected function execute(InputInterface $input, OutputInterface $output): int
+ {
+ $this->command ??= $this->getApplication()->find($input->getArgument('command_name'));
+
+ $helper = new DescriptorHelper();
+ $helper->describe($output, $this->command, [
+ 'format' => $input->getOption('format'),
+ 'raw_text' => $input->getOption('raw'),
+ ]);
+
+ unset($this->command);
+
+ return 0;
+ }
+}
diff --git a/symfony/console/Command/LazyCommand.php b/symfony/console/Command/LazyCommand.php
new file mode 100644
index 0000000000000000000000000000000000000000..b94da6665af41f46d07d8eb55c096e43ee4ff28a
--- /dev/null
+++ b/symfony/console/Command/LazyCommand.php
@@ -0,0 +1,207 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Console\Command;
+
+use Symfony\Component\Console\Application;
+use Symfony\Component\Console\Completion\CompletionInput;
+use Symfony\Component\Console\Completion\CompletionSuggestions;
+use Symfony\Component\Console\Completion\Suggestion;
+use Symfony\Component\Console\Helper\HelperInterface;
+use Symfony\Component\Console\Helper\HelperSet;
+use Symfony\Component\Console\Input\InputDefinition;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+
+/**
+ * @author Nicolas Grekas
+ */
+final class LazyCommand extends Command
+{
+ private \Closure|Command $command;
+ private ?bool $isEnabled;
+
+ public function __construct(string $name, array $aliases, string $description, bool $isHidden, \Closure $commandFactory, ?bool $isEnabled = true)
+ {
+ $this->setName($name)
+ ->setAliases($aliases)
+ ->setHidden($isHidden)
+ ->setDescription($description);
+
+ $this->command = $commandFactory;
+ $this->isEnabled = $isEnabled;
+ }
+
+ public function ignoreValidationErrors(): void
+ {
+ $this->getCommand()->ignoreValidationErrors();
+ }
+
+ public function setApplication(?Application $application = null): void
+ {
+ if (1 > \func_num_args()) {
+ trigger_deprecation('symfony/console', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__);
+ }
+ if ($this->command instanceof parent) {
+ $this->command->setApplication($application);
+ }
+
+ parent::setApplication($application);
+ }
+
+ public function setHelperSet(HelperSet $helperSet): void
+ {
+ if ($this->command instanceof parent) {
+ $this->command->setHelperSet($helperSet);
+ }
+
+ parent::setHelperSet($helperSet);
+ }
+
+ public function isEnabled(): bool
+ {
+ return $this->isEnabled ?? $this->getCommand()->isEnabled();
+ }
+
+ public function run(InputInterface $input, OutputInterface $output): int
+ {
+ return $this->getCommand()->run($input, $output);
+ }
+
+ public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
+ {
+ $this->getCommand()->complete($input, $suggestions);
+ }
+
+ public function setCode(callable $code): static
+ {
+ $this->getCommand()->setCode($code);
+
+ return $this;
+ }
+
+ /**
+ * @internal
+ */
+ public function mergeApplicationDefinition(bool $mergeArgs = true): void
+ {
+ $this->getCommand()->mergeApplicationDefinition($mergeArgs);
+ }
+
+ public function setDefinition(array|InputDefinition $definition): static
+ {
+ $this->getCommand()->setDefinition($definition);
+
+ return $this;
+ }
+
+ public function getDefinition(): InputDefinition
+ {
+ return $this->getCommand()->getDefinition();
+ }
+
+ public function getNativeDefinition(): InputDefinition
+ {
+ return $this->getCommand()->getNativeDefinition();
+ }
+
+ /**
+ * @param array|\Closure(CompletionInput,CompletionSuggestions):list $suggestedValues The values used for input completion
+ */
+ public function addArgument(string $name, ?int $mode = null, string $description = '', mixed $default = null /* array|\Closure $suggestedValues = [] */): static
+ {
+ $suggestedValues = 5 <= \func_num_args() ? func_get_arg(4) : [];
+ $this->getCommand()->addArgument($name, $mode, $description, $default, $suggestedValues);
+
+ return $this;
+ }
+
+ /**
+ * @param array|\Closure(CompletionInput,CompletionSuggestions):list $suggestedValues The values used for input completion
+ */
+ public function addOption(string $name, string|array|null $shortcut = null, ?int $mode = null, string $description = '', mixed $default = null /* array|\Closure $suggestedValues = [] */): static
+ {
+ $suggestedValues = 6 <= \func_num_args() ? func_get_arg(5) : [];
+ $this->getCommand()->addOption($name, $shortcut, $mode, $description, $default, $suggestedValues);
+
+ return $this;
+ }
+
+ public function setProcessTitle(string $title): static
+ {
+ $this->getCommand()->setProcessTitle($title);
+
+ return $this;
+ }
+
+ public function setHelp(string $help): static
+ {
+ $this->getCommand()->setHelp($help);
+
+ return $this;
+ }
+
+ public function getHelp(): string
+ {
+ return $this->getCommand()->getHelp();
+ }
+
+ public function getProcessedHelp(): string
+ {
+ return $this->getCommand()->getProcessedHelp();
+ }
+
+ public function getSynopsis(bool $short = false): string
+ {
+ return $this->getCommand()->getSynopsis($short);
+ }
+
+ public function addUsage(string $usage): static
+ {
+ $this->getCommand()->addUsage($usage);
+
+ return $this;
+ }
+
+ public function getUsages(): array
+ {
+ return $this->getCommand()->getUsages();
+ }
+
+ public function getHelper(string $name): HelperInterface
+ {
+ return $this->getCommand()->getHelper($name);
+ }
+
+ public function getCommand(): parent
+ {
+ if (!$this->command instanceof \Closure) {
+ return $this->command;
+ }
+
+ $command = $this->command = ($this->command)();
+ $command->setApplication($this->getApplication());
+
+ if (null !== $this->getHelperSet()) {
+ $command->setHelperSet($this->getHelperSet());
+ }
+
+ $command->setName($this->getName())
+ ->setAliases($this->getAliases())
+ ->setHidden($this->isHidden())
+ ->setDescription($this->getDescription());
+
+ // Will throw if the command is not correctly initialized.
+ $command->getDefinition();
+
+ return $command;
+ }
+}
diff --git a/symfony/console/Command/ListCommand.php b/symfony/console/Command/ListCommand.php
new file mode 100644
index 0000000000000000000000000000000000000000..5850c3d7b814054f444864fc01f28e107a6e0779
--- /dev/null
+++ b/symfony/console/Command/ListCommand.php
@@ -0,0 +1,75 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Console\Command;
+
+use Symfony\Component\Console\Descriptor\ApplicationDescription;
+use Symfony\Component\Console\Helper\DescriptorHelper;
+use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Output\OutputInterface;
+
+/**
+ * ListCommand displays the list of all available commands for the application.
+ *
+ * @author Fabien Potencier
+ */
+class ListCommand extends Command
+{
+ /**
+ * @return void
+ */
+ protected function configure()
+ {
+ $this
+ ->setName('list')
+ ->setDefinition([
+ new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name', null, fn () => array_keys((new ApplicationDescription($this->getApplication()))->getNamespaces())),
+ new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command list'),
+ new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt', fn () => (new DescriptorHelper())->getFormats()),
+ new InputOption('short', null, InputOption::VALUE_NONE, 'To skip describing commands\' arguments'),
+ ])
+ ->setDescription('List commands')
+ ->setHelp(<<<'EOF'
+The %command.name% command lists all commands:
+
+ %command.full_name%
+
+You can also display the commands for a specific namespace:
+
+ %command.full_name% test
+
+You can also output the information in other formats by using the --format option:
+
+ %command.full_name% --format=xml
+
+It's also possible to get raw list of commands (useful for embedding command runner):
+
+ %command.full_name% --raw
+EOF
+ )
+ ;
+ }
+
+ protected function execute(InputInterface $input, OutputInterface $output): int
+ {
+ $helper = new DescriptorHelper();
+ $helper->describe($output, $this->getApplication(), [
+ 'format' => $input->getOption('format'),
+ 'raw_text' => $input->getOption('raw'),
+ 'namespace' => $input->getArgument('namespace'),
+ 'short' => $input->getOption('short'),
+ ]);
+
+ return 0;
+ }
+}
diff --git a/symfony/console/Command/LockableTrait.php b/symfony/console/Command/LockableTrait.php
new file mode 100644
index 0000000000000000000000000000000000000000..cd7548f02f9e96c508da904afad751c0d55ead47
--- /dev/null
+++ b/symfony/console/Command/LockableTrait.php
@@ -0,0 +1,68 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Console\Command;
+
+use Symfony\Component\Console\Exception\LogicException;
+use Symfony\Component\Lock\LockFactory;
+use Symfony\Component\Lock\LockInterface;
+use Symfony\Component\Lock\Store\FlockStore;
+use Symfony\Component\Lock\Store\SemaphoreStore;
+
+/**
+ * Basic lock feature for commands.
+ *
+ * @author Geoffrey Brier
+ */
+trait LockableTrait
+{
+ private ?LockInterface $lock = null;
+
+ /**
+ * Locks a command.
+ */
+ private function lock(?string $name = null, bool $blocking = false): bool
+ {
+ if (!class_exists(SemaphoreStore::class)) {
+ throw new LogicException('To enable the locking feature you must install the symfony/lock component. Try running "composer require symfony/lock".');
+ }
+
+ if (null !== $this->lock) {
+ throw new LogicException('A lock is already in place.');
+ }
+
+ if (SemaphoreStore::isSupported()) {
+ $store = new SemaphoreStore();
+ } else {
+ $store = new FlockStore();
+ }
+
+ $this->lock = (new LockFactory($store))->createLock($name ?: $this->getName());
+ if (!$this->lock->acquire($blocking)) {
+ $this->lock = null;
+
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Releases the command lock if there is one.
+ */
+ private function release(): void
+ {
+ if ($this->lock) {
+ $this->lock->release();
+ $this->lock = null;
+ }
+ }
+}
diff --git a/symfony/console/Command/SignalableCommandInterface.php b/symfony/console/Command/SignalableCommandInterface.php
new file mode 100644
index 0000000000000000000000000000000000000000..74d59b086d8b06352c731d8eba6d8f101010c1d2
--- /dev/null
+++ b/symfony/console/Command/SignalableCommandInterface.php
@@ -0,0 +1,34 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Console\Command;
+
+/**
+ * Interface for command reacting to signal.
+ *
+ * @author Grégoire Pineau