8889841cPKfŒ[$KÀ˜..Cache/Cache.phpnu„[µü¤namespace = (string) $namespace; $this->namespaceVersion = null; } public function getNamespace() { return $this->namespace; } public function fetch($id) { return $this->doFetch($this->getNamespacedId($id)); } public function fetchMultiple(array $keys) { if (empty($keys)) { return []; } // note: the array_combine() is in place to keep an association between our $keys and the $namespacedKeys $namespacedKeys = array_combine($keys, array_map([$this, 'getNamespacedId'], $keys)); $items = $this->doFetchMultiple($namespacedKeys); $foundItems = []; // no internal array function supports this sort of mapping: needs to be iterative // this filters and combines keys in one pass foreach ($namespacedKeys as $requestedKey => $namespacedKey) { if (!isset($items[$namespacedKey]) && !array_key_exists($namespacedKey, $items)) { continue; } $foundItems[$requestedKey] = $items[$namespacedKey]; } return $foundItems; } public function saveMultiple(array $keysAndValues, $lifetime = 0) { $namespacedKeysAndValues = []; foreach ($keysAndValues as $key => $value) { $namespacedKeysAndValues[$this->getNamespacedId($key)] = $value; } return $this->doSaveMultiple($namespacedKeysAndValues, $lifetime); } public function contains($id) { return $this->doContains($this->getNamespacedId($id)); } public function save($id, $data, $lifeTime = 0) { return $this->doSave($this->getNamespacedId($id), $data, $lifeTime); } public function deleteMultiple(array $keys) { return $this->doDeleteMultiple(array_map([$this, 'getNamespacedId'], $keys)); } public function delete($id) { return $this->doDelete($this->getNamespacedId($id)); } public function getStats() { return $this->doGetStats(); } public function flushAll() { return $this->doFlush(); } public function deleteAll() { $namespaceCacheKey = $this->getNamespaceCacheKey(); $namespaceVersion = $this->getNamespaceVersion() + 1; if ($this->doSave($namespaceCacheKey, $namespaceVersion)) { $this->namespaceVersion = $namespaceVersion; return \true; } return \false; } private function getNamespacedId(string $id) : string { $namespaceVersion = $this->getNamespaceVersion(); return sprintf('%s[%s][%s]', $this->namespace, $id, $namespaceVersion); } private function getNamespaceCacheKey() : string { return sprintf(self::DOCTRINE_NAMESPACE_CACHEKEY, $this->namespace); } private function getNamespaceVersion() : int { if ($this->namespaceVersion !== null) { return $this->namespaceVersion; } $namespaceCacheKey = $this->getNamespaceCacheKey(); $this->namespaceVersion = (int) $this->doFetch($namespaceCacheKey) ?: 1; return $this->namespaceVersion; } protected function doFetchMultiple(array $keys) { $returnValues = []; foreach ($keys as $key) { $item = $this->doFetch($key); if ($item === \false && !$this->doContains($key)) { continue; } $returnValues[$key] = $item; } return $returnValues; } protected abstract function doFetch($id); protected abstract function doContains($id); protected function doSaveMultiple(array $keysAndValues, $lifetime = 0) { $success = \true; foreach ($keysAndValues as $key => $value) { if ($this->doSave($key, $value, $lifetime)) { continue; } $success = \false; } return $success; } protected abstract function doSave($id, $data, $lifeTime = 0); protected function doDeleteMultiple(array $keys) { $success = \true; foreach ($keys as $key) { if ($this->doDelete($key)) { continue; } $success = \false; } return $success; } protected abstract function doDelete($id); protected abstract function doFlush(); protected abstract function doGetStats(); } PKfŒ[%ÏÅå66Cache/Psr6/InvalidArgument.phpnu„[µü¤getCache(); } if ($pool instanceof SymfonyDoctrineAdapter) { $getCache = function () { // phpcs:ignore Squiz.Scope.StaticThisUsage.Found return $this->provider; }; return $getCache->bindTo($pool, SymfonyDoctrineAdapter::class)(); } return new self($pool); } private function __construct(CacheItemPoolInterface $pool) { $this->pool = $pool; } public function getPool() : CacheItemPoolInterface { return $this->pool; } protected function doFetch($id) { $item = $this->pool->getItem(rawurlencode($id)); return $item->isHit() ? $item->get() : \false; } protected function doContains($id) { return $this->pool->hasItem(rawurlencode($id)); } protected function doSave($id, $data, $lifeTime = 0) { $item = $this->pool->getItem(rawurlencode($id)); if (0 < $lifeTime) { $item->expiresAfter($lifeTime); } return $this->pool->save($item->set($data)); } protected function doDelete($id) { return $this->pool->deleteItem(rawurlencode($id)); } protected function doFlush() { return $this->pool->clear(); } protected function doGetStats() { return null; } } PKfŒ[ÎãCache/Psr6/index.phpnu„[µü¤key = $key; $this->value = $data; $this->isHit = $isHit; } public function getKey() : string { return $this->key; } public function get() { return $this->value; } public function isHit() : bool { return $this->isHit; } public function set($value) : self { $this->value = $value; return $this; } public function expiresAt($expiration) : self { if ($expiration === null) { $this->expiry = null; } elseif ($expiration instanceof DateTimeInterface) { $this->expiry = (float) $expiration->format('U.u'); } else { throw new TypeError(sprintf('Expected $expiration to be an instance of DateTimeInterface or null, got %s', is_object($expiration) ? get_class($expiration) : gettype($expiration))); } return $this; } public function expiresAfter($time) : self { if ($time === null) { $this->expiry = null; } elseif ($time instanceof DateInterval) { $this->expiry = microtime(\true) + DateTime::createFromFormat('U', 0)->add($time)->format('U.u'); } elseif (is_int($time)) { $this->expiry = $time + microtime(\true); } else { throw new TypeError(sprintf('Expected $time to be either an integer, an instance of DateInterval or null, got %s', is_object($time) ? get_class($time) : gettype($time))); } return $this; } public function getExpiry() : ?float { return $this->expiry; } } PKfŒ[Q•ë1MMCache/Psr6/CacheAdapter.phpnu„[µü¤getNamespace()) { return $cache->getPool(); } if ($cache instanceof SymfonyDoctrineProvider && !$cache->getNamespace()) { $getPool = function () { // phpcs:ignore Squiz.Scope.StaticThisUsage.Found return $this->pool; }; return $getPool->bindTo($cache, SymfonyDoctrineProvider::class)(); } return new self($cache); } private function __construct(Cache $cache) { $this->cache = $cache; } public function getCache() : Cache { return $this->cache; } public function getItem($key) : CacheItemInterface { assert(self::validKey($key)); if (isset($this->deferredItems[$key])) { $this->commit(); } $value = $this->cache->fetch($key); if (PHP_VERSION_ID >= 80000) { if ($value !== \false) { return new TypedCacheItem($key, $value, \true); } return new TypedCacheItem($key, null, \false); } if ($value !== \false) { return new CacheItem($key, $value, \true); } return new CacheItem($key, null, \false); } public function getItems(array $keys = []) : array { if ($this->deferredItems) { $this->commit(); } assert(self::validKeys($keys)); $values = $this->doFetchMultiple($keys); $items = []; if (PHP_VERSION_ID >= 80000) { foreach ($keys as $key) { if (array_key_exists($key, $values)) { $items[$key] = new TypedCacheItem($key, $values[$key], \true); } else { $items[$key] = new TypedCacheItem($key, null, \false); } } return $items; } foreach ($keys as $key) { if (array_key_exists($key, $values)) { $items[$key] = new CacheItem($key, $values[$key], \true); } else { $items[$key] = new CacheItem($key, null, \false); } } return $items; } public function hasItem($key) : bool { assert(self::validKey($key)); if (isset($this->deferredItems[$key])) { $this->commit(); } return $this->cache->contains($key); } public function clear() : bool { $this->deferredItems = []; if (!$this->cache instanceof ClearableCache) { return \false; } return $this->cache->deleteAll(); } public function deleteItem($key) : bool { assert(self::validKey($key)); unset($this->deferredItems[$key]); return $this->cache->delete($key); } public function deleteItems(array $keys) : bool { foreach ($keys as $key) { assert(self::validKey($key)); unset($this->deferredItems[$key]); } return $this->doDeleteMultiple($keys); } public function save(CacheItemInterface $item) : bool { return $this->saveDeferred($item) && $this->commit(); } public function saveDeferred(CacheItemInterface $item) : bool { if (!$item instanceof CacheItem && !$item instanceof TypedCacheItem) { return \false; } $this->deferredItems[$item->getKey()] = $item; return \true; } public function commit() : bool { if (!$this->deferredItems) { return \true; } $now = microtime(\true); $itemsCount = 0; $byLifetime = []; $expiredKeys = []; foreach ($this->deferredItems as $key => $item) { $lifetime = ($item->getExpiry() ?? $now) - $now; if ($lifetime < 0) { $expiredKeys[] = $key; continue; } ++$itemsCount; $byLifetime[(int) $lifetime][$key] = $item->get(); } $this->deferredItems = []; switch (count($expiredKeys)) { case 0: break; case 1: $this->cache->delete(current($expiredKeys)); break; default: $this->doDeleteMultiple($expiredKeys); break; } if ($itemsCount === 1) { return $this->cache->save($key, $item->get(), (int) $lifetime); } $success = \true; foreach ($byLifetime as $lifetime => $values) { $success = $this->doSaveMultiple($values, $lifetime) && $success; } return $success; } public function __destruct() { $this->commit(); } private static function validKey($key) : bool { if (!is_string($key)) { throw new InvalidArgument(sprintf('Cache key must be string, "%s" given.', is_object($key) ? get_class($key) : gettype($key))); } if ($key === '') { throw new InvalidArgument('Cache key length must be greater than zero.'); } if (strpbrk($key, self::RESERVED_CHARACTERS) !== \false) { throw new InvalidArgument(sprintf('Cache key "%s" contains reserved characters "%s".', $key, self::RESERVED_CHARACTERS)); } return \true; } private static function validKeys(array $keys) : bool { foreach ($keys as $key) { self::validKey($key); } return \true; } private function doDeleteMultiple(array $keys) : bool { if ($this->cache instanceof MultiDeleteCache) { return $this->cache->deleteMultiple($keys); } $success = \true; foreach ($keys as $key) { $success = $this->cache->delete($key) && $success; } return $success; } private function doFetchMultiple(array $keys) : array { if ($this->cache instanceof MultiGetCache) { return $this->cache->fetchMultiple($keys); } $values = []; foreach ($keys as $key) { $value = $this->cache->fetch($key); if (!$value) { continue; } $values[$key] = $value; } return $values; } private function doSaveMultiple(array $keysAndValues, int $lifetime = 0) : bool { if ($this->cache instanceof MultiPutCache) { return $this->cache->saveMultiple($keysAndValues, $lifetime); } $success = \true; foreach ($keysAndValues as $key => $value) { $success = $this->cache->save($key, $value, $lifetime) && $success; } return $success; } } PKfŒ[؃+ìFFCache/Psr6/TypedCacheItem.phpnu„[µü¤key = $key; $this->value = $data; $this->isHit = $isHit; } public function getKey() : string { return $this->key; } public function get() { return $this->value; } public function isHit() : bool { return $this->isHit; } public function set($value) : self { $this->value = $value; return $this; } public function expiresAt($expiration) : self { if ($expiration === null) { $this->expiry = null; } elseif ($expiration instanceof DateTimeInterface) { $this->expiry = (float) $expiration->format('U.u'); } else { throw new TypeError(sprintf('Expected $expiration to be an instance of DateTimeInterface or null, got %s', is_object($expiration) ? get_class($expiration) : gettype($expiration))); } return $this; } public function expiresAfter($time) : self { if ($time === null) { $this->expiry = null; } elseif ($time instanceof DateInterval) { $this->expiry = microtime(\true) + DateTime::createFromFormat('U', 0)->add($time)->format('U.u'); } elseif (is_int($time)) { $this->expiry = $time + microtime(\true); } else { throw new TypeError(sprintf('Expected $time to be either an integer, an instance of DateInterval or null, got %s', is_object($time) ? get_class($time) : gettype($time))); } return $this; } public function getExpiry() : ?float { return $this->expiry; } } PKfŒ[ÎãCache/index.phpnu„[µü¤input = $input; $this->tokens = []; $this->reset(); $this->scan($input); } public function reset() { $this->lookahead = null; $this->token = null; $this->peek = 0; $this->position = 0; } public function resetPeek() { $this->peek = 0; } public function resetPosition($position = 0) { $this->position = $position; } public function getInputUntilPosition($position) { return substr($this->input, 0, $position); } public function isNextToken($type) { return $this->lookahead !== null && $this->lookahead['type'] === $type; } public function isNextTokenAny(array $types) { return $this->lookahead !== null && in_array($this->lookahead['type'], $types, \true); } public function moveNext() { $this->peek = 0; $this->token = $this->lookahead; $this->lookahead = isset($this->tokens[$this->position]) ? $this->tokens[$this->position++] : null; return $this->lookahead !== null; } public function skipUntil($type) { while ($this->lookahead !== null && $this->lookahead['type'] !== $type) { $this->moveNext(); } } public function isA($value, $token) { return $this->getType($value) === $token; } public function peek() { if (isset($this->tokens[$this->position + $this->peek])) { return $this->tokens[$this->position + $this->peek++]; } return null; } public function glimpse() { $peek = $this->peek(); $this->peek = 0; return $peek; } protected function scan($input) { if (!isset($this->regex)) { $this->regex = sprintf('/(%s)|%s/%s', implode(')|(', $this->getCatchablePatterns()), implode('|', $this->getNonCatchablePatterns()), $this->getModifiers()); } $flags = PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE; $matches = preg_split($this->regex, $input, -1, $flags); if ($matches === \false) { // Work around https://bugs.php.net/78122 $matches = [[$input, 0]]; } foreach ($matches as $match) { // Must remain before 'value' assignment since it can change content $type = $this->getType($match[0]); $this->tokens[] = ['value' => $match[0], 'type' => $type, 'position' => $match[1]]; } } public function getLiteral($token) { $className = static::class; $reflClass = new ReflectionClass($className); $constants = $reflClass->getConstants(); foreach ($constants as $name => $value) { if ($value === $token) { return $className . '::' . $name; } } return $token; } protected function getModifiers() { return 'iu'; } protected abstract function getCatchablePatterns(); protected abstract function getNonCatchablePatterns(); protected abstract function getType(&$value); } PKiŒ[ÎãLexer/index.phpnu„[µü¤