first commit
This commit is contained in:
19
vendor/doctrine/cache/LICENSE
vendored
Normal file
19
vendor/doctrine/cache/LICENSE
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
Copyright (c) 2006-2015 Doctrine Project
|
||||
|
||||
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.
|
10
vendor/doctrine/cache/README.md
vendored
Normal file
10
vendor/doctrine/cache/README.md
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
# Doctrine Cache
|
||||
|
||||
[](http://travis-ci.org/doctrine/cache)
|
||||
[](https://scrutinizer-ci.com/g/doctrine/cache/?branch=master)
|
||||
[](https://scrutinizer-ci.com/g/doctrine/cache/?branch=master)
|
||||
|
||||
[](https://packagist.org/packages/doctrine/cache)
|
||||
[](https://packagist.org/packages/doctrine/cache)
|
||||
|
||||
Cache component extracted from the Doctrine Common project. [Documentation](https://www.doctrine-project.org/projects/doctrine-orm/en/current/reference/caching.html)
|
16
vendor/doctrine/cache/UPGRADE.md
vendored
Normal file
16
vendor/doctrine/cache/UPGRADE.md
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
# Upgrade to 1.4
|
||||
|
||||
## Minor BC Break: `Doctrine\Common\Cache\FileCache#$extension` is now `private`.
|
||||
|
||||
If you need to override the value of `Doctrine\Common\Cache\FileCache#$extension`, then use the
|
||||
second parameter of `Doctrine\Common\Cache\FileCache#__construct()` instead of overriding
|
||||
the property in your own implementation.
|
||||
|
||||
## Minor BC Break: file based caches paths changed
|
||||
|
||||
`Doctrine\Common\Cache\FileCache`, `Doctrine\Common\Cache\PhpFileCache` and
|
||||
`Doctrine\Common\Cache\FilesystemCache` are using a different cache paths structure.
|
||||
|
||||
If you rely on warmed up caches for deployments, consider that caches generated
|
||||
with `doctrine/cache` `<1.4` are not compatible with the new directory structure,
|
||||
and will be ignored.
|
105
vendor/doctrine/cache/lib/Doctrine/Common/Cache/ApcCache.php
vendored
Normal file
105
vendor/doctrine/cache/lib/Doctrine/Common/Cache/ApcCache.php
vendored
Normal file
@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
use const PHP_VERSION_ID;
|
||||
use function apc_cache_info;
|
||||
use function apc_clear_cache;
|
||||
use function apc_delete;
|
||||
use function apc_exists;
|
||||
use function apc_fetch;
|
||||
use function apc_sma_info;
|
||||
use function apc_store;
|
||||
|
||||
/**
|
||||
* APC cache provider.
|
||||
*
|
||||
* @deprecated since version 1.6, use ApcuCache instead
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
*/
|
||||
class ApcCache extends CacheProvider
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFetch($id)
|
||||
{
|
||||
return apc_fetch($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doContains($id)
|
||||
{
|
||||
return apc_exists($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doSave($id, $data, $lifeTime = 0)
|
||||
{
|
||||
return apc_store($id, $data, $lifeTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doDelete($id)
|
||||
{
|
||||
// apc_delete returns false if the id does not exist
|
||||
return apc_delete($id) || ! apc_exists($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFlush()
|
||||
{
|
||||
return apc_clear_cache() && apc_clear_cache('user');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFetchMultiple(array $keys)
|
||||
{
|
||||
return apc_fetch($keys) ?: [];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doSaveMultiple(array $keysAndValues, $lifetime = 0)
|
||||
{
|
||||
$result = apc_store($keysAndValues, null, $lifetime);
|
||||
|
||||
return empty($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doGetStats()
|
||||
{
|
||||
$info = apc_cache_info('', true);
|
||||
$sma = apc_sma_info();
|
||||
|
||||
// @TODO - Temporary fix @see https://github.com/krakjoe/apcu/pull/42
|
||||
if (PHP_VERSION_ID >= 50500) {
|
||||
$info['num_hits'] = $info['num_hits'] ?? $info['nhits'];
|
||||
$info['num_misses'] = $info['num_misses'] ?? $info['nmisses'];
|
||||
$info['start_time'] = $info['start_time'] ?? $info['stime'];
|
||||
}
|
||||
|
||||
return [
|
||||
Cache::STATS_HITS => $info['num_hits'],
|
||||
Cache::STATS_MISSES => $info['num_misses'],
|
||||
Cache::STATS_UPTIME => $info['start_time'],
|
||||
Cache::STATS_MEMORY_USAGE => $info['mem_size'],
|
||||
Cache::STATS_MEMORY_AVAILABLE => $sma['avail_mem'],
|
||||
];
|
||||
}
|
||||
}
|
106
vendor/doctrine/cache/lib/Doctrine/Common/Cache/ApcuCache.php
vendored
Normal file
106
vendor/doctrine/cache/lib/Doctrine/Common/Cache/ApcuCache.php
vendored
Normal file
@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
use function apcu_cache_info;
|
||||
use function apcu_clear_cache;
|
||||
use function apcu_delete;
|
||||
use function apcu_exists;
|
||||
use function apcu_fetch;
|
||||
use function apcu_sma_info;
|
||||
use function apcu_store;
|
||||
use function count;
|
||||
|
||||
/**
|
||||
* APCu cache provider.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
*/
|
||||
class ApcuCache extends CacheProvider
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFetch($id)
|
||||
{
|
||||
return apcu_fetch($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doContains($id)
|
||||
{
|
||||
return apcu_exists($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doSave($id, $data, $lifeTime = 0)
|
||||
{
|
||||
return apcu_store($id, $data, $lifeTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doDelete($id)
|
||||
{
|
||||
// apcu_delete returns false if the id does not exist
|
||||
return apcu_delete($id) || ! apcu_exists($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doDeleteMultiple(array $keys)
|
||||
{
|
||||
$result = apcu_delete($keys);
|
||||
|
||||
return $result !== false && count($result) !== count($keys);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFlush()
|
||||
{
|
||||
return apcu_clear_cache();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFetchMultiple(array $keys)
|
||||
{
|
||||
return apcu_fetch($keys) ?: [];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doSaveMultiple(array $keysAndValues, $lifetime = 0)
|
||||
{
|
||||
$result = apcu_store($keysAndValues, null, $lifetime);
|
||||
|
||||
return empty($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doGetStats()
|
||||
{
|
||||
$info = apcu_cache_info(true);
|
||||
$sma = apcu_sma_info();
|
||||
|
||||
return [
|
||||
Cache::STATS_HITS => $info['num_hits'],
|
||||
Cache::STATS_MISSES => $info['num_misses'],
|
||||
Cache::STATS_UPTIME => $info['start_time'],
|
||||
Cache::STATS_MEMORY_USAGE => $info['mem_size'],
|
||||
Cache::STATS_MEMORY_AVAILABLE => $sma['avail_mem'],
|
||||
];
|
||||
}
|
||||
}
|
113
vendor/doctrine/cache/lib/Doctrine/Common/Cache/ArrayCache.php
vendored
Normal file
113
vendor/doctrine/cache/lib/Doctrine/Common/Cache/ArrayCache.php
vendored
Normal file
@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
use function time;
|
||||
|
||||
/**
|
||||
* Array cache driver.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
*/
|
||||
class ArrayCache extends CacheProvider
|
||||
{
|
||||
/** @var array[] $data each element being a tuple of [$data, $expiration], where the expiration is int|bool */
|
||||
private $data = [];
|
||||
|
||||
/** @var int */
|
||||
private $hitsCount = 0;
|
||||
|
||||
/** @var int */
|
||||
private $missesCount = 0;
|
||||
|
||||
/** @var int */
|
||||
private $upTime;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->upTime = time();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFetch($id)
|
||||
{
|
||||
if (! $this->doContains($id)) {
|
||||
$this->missesCount += 1;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->hitsCount += 1;
|
||||
|
||||
return $this->data[$id][0];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doContains($id)
|
||||
{
|
||||
if (! isset($this->data[$id])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$expiration = $this->data[$id][1];
|
||||
|
||||
if ($expiration && $expiration < time()) {
|
||||
$this->doDelete($id);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doSave($id, $data, $lifeTime = 0)
|
||||
{
|
||||
$this->data[$id] = [$data, $lifeTime ? time() + $lifeTime : false];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doDelete($id)
|
||||
{
|
||||
unset($this->data[$id]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFlush()
|
||||
{
|
||||
$this->data = [];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doGetStats()
|
||||
{
|
||||
return [
|
||||
Cache::STATS_HITS => $this->hitsCount,
|
||||
Cache::STATS_MISSES => $this->missesCount,
|
||||
Cache::STATS_UPTIME => $this->upTime,
|
||||
Cache::STATS_MEMORY_USAGE => null,
|
||||
Cache::STATS_MEMORY_AVAILABLE => null,
|
||||
];
|
||||
}
|
||||
}
|
90
vendor/doctrine/cache/lib/Doctrine/Common/Cache/Cache.php
vendored
Normal file
90
vendor/doctrine/cache/lib/Doctrine/Common/Cache/Cache.php
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
/**
|
||||
* Interface for cache drivers.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
*/
|
||||
interface Cache
|
||||
{
|
||||
public const STATS_HITS = 'hits';
|
||||
public const STATS_MISSES = 'misses';
|
||||
public const STATS_UPTIME = 'uptime';
|
||||
public const STATS_MEMORY_USAGE = 'memory_usage';
|
||||
public const STATS_MEMORY_AVAILABLE = 'memory_available';
|
||||
/**
|
||||
* Only for backward compatibility (may be removed in next major release)
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public const STATS_MEMORY_AVAILIABLE = 'memory_available';
|
||||
|
||||
/**
|
||||
* Fetches an entry from the cache.
|
||||
*
|
||||
* @param string $id The id of the cache entry to fetch.
|
||||
*
|
||||
* @return mixed The cached data or FALSE, if no cache entry exists for the given id.
|
||||
*/
|
||||
public function fetch($id);
|
||||
|
||||
/**
|
||||
* Tests if an entry exists in the cache.
|
||||
*
|
||||
* @param string $id The cache id of the entry to check for.
|
||||
*
|
||||
* @return bool TRUE if a cache entry exists for the given cache id, FALSE otherwise.
|
||||
*/
|
||||
public function contains($id);
|
||||
|
||||
/**
|
||||
* Puts data into the cache.
|
||||
*
|
||||
* If a cache entry with the given id already exists, its data will be replaced.
|
||||
*
|
||||
* @param string $id The cache id.
|
||||
* @param mixed $data The cache entry/data.
|
||||
* @param int $lifeTime The lifetime in number of seconds for this cache entry.
|
||||
* If zero (the default), the entry never expires (although it may be deleted from the cache
|
||||
* to make place for other entries).
|
||||
*
|
||||
* @return bool TRUE if the entry was successfully stored in the cache, FALSE otherwise.
|
||||
*/
|
||||
public function save($id, $data, $lifeTime = 0);
|
||||
|
||||
/**
|
||||
* Deletes a cache entry.
|
||||
*
|
||||
* @param string $id The cache id.
|
||||
*
|
||||
* @return bool TRUE if the cache entry was successfully deleted, FALSE otherwise.
|
||||
* Deleting a non-existing entry is considered successful.
|
||||
*/
|
||||
public function delete($id);
|
||||
|
||||
/**
|
||||
* Retrieves cached information from the data store.
|
||||
*
|
||||
* The server's statistics array has the following values:
|
||||
*
|
||||
* - <b>hits</b>
|
||||
* Number of keys that have been requested and found present.
|
||||
*
|
||||
* - <b>misses</b>
|
||||
* Number of items that have been requested and not found.
|
||||
*
|
||||
* - <b>uptime</b>
|
||||
* Time that the server is running.
|
||||
*
|
||||
* - <b>memory_usage</b>
|
||||
* Memory used by this server to store items.
|
||||
*
|
||||
* - <b>memory_available</b>
|
||||
* Memory allowed to use for storage.
|
||||
*
|
||||
* @return array|null An associative array with server's statistics if available, NULL otherwise.
|
||||
*/
|
||||
public function getStats();
|
||||
}
|
325
vendor/doctrine/cache/lib/Doctrine/Common/Cache/CacheProvider.php
vendored
Normal file
325
vendor/doctrine/cache/lib/Doctrine/Common/Cache/CacheProvider.php
vendored
Normal file
@ -0,0 +1,325 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
use function array_combine;
|
||||
use function array_key_exists;
|
||||
use function array_map;
|
||||
use function sprintf;
|
||||
|
||||
/**
|
||||
* Base class for cache provider implementations.
|
||||
*/
|
||||
abstract class CacheProvider implements Cache, FlushableCache, ClearableCache, MultiOperationCache
|
||||
{
|
||||
public const DOCTRINE_NAMESPACE_CACHEKEY = 'DoctrineNamespaceCacheKey[%s]';
|
||||
|
||||
/**
|
||||
* The namespace to prefix all cache ids with.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $namespace = '';
|
||||
|
||||
/**
|
||||
* The namespace version.
|
||||
*
|
||||
* @var int|null
|
||||
*/
|
||||
private $namespaceVersion;
|
||||
|
||||
/**
|
||||
* Sets the namespace to prefix all cache ids with.
|
||||
*
|
||||
* @param string $namespace
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setNamespace($namespace)
|
||||
{
|
||||
$this->namespace = (string) $namespace;
|
||||
$this->namespaceVersion = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the namespace that prefixes all cache ids.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getNamespace()
|
||||
{
|
||||
return $this->namespace;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fetch($id)
|
||||
{
|
||||
return $this->doFetch($this->getNamespacedId($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function saveMultiple(array $keysAndValues, $lifetime = 0)
|
||||
{
|
||||
$namespacedKeysAndValues = [];
|
||||
foreach ($keysAndValues as $key => $value) {
|
||||
$namespacedKeysAndValues[$this->getNamespacedId($key)] = $value;
|
||||
}
|
||||
|
||||
return $this->doSaveMultiple($namespacedKeysAndValues, $lifetime);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function contains($id)
|
||||
{
|
||||
return $this->doContains($this->getNamespacedId($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function save($id, $data, $lifeTime = 0)
|
||||
{
|
||||
return $this->doSave($this->getNamespacedId($id), $data, $lifeTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function deleteMultiple(array $keys)
|
||||
{
|
||||
return $this->doDeleteMultiple(array_map([$this, 'getNamespacedId'], $keys));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
return $this->doDelete($this->getNamespacedId($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getStats()
|
||||
{
|
||||
return $this->doGetStats();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function flushAll()
|
||||
{
|
||||
return $this->doFlush();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function deleteAll()
|
||||
{
|
||||
$namespaceCacheKey = $this->getNamespaceCacheKey();
|
||||
$namespaceVersion = $this->getNamespaceVersion() + 1;
|
||||
|
||||
if ($this->doSave($namespaceCacheKey, $namespaceVersion)) {
|
||||
$this->namespaceVersion = $namespaceVersion;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prefixes the passed id with the configured namespace value.
|
||||
*
|
||||
* @param string $id The id to namespace.
|
||||
*
|
||||
* @return string The namespaced id.
|
||||
*/
|
||||
private function getNamespacedId(string $id) : string
|
||||
{
|
||||
$namespaceVersion = $this->getNamespaceVersion();
|
||||
|
||||
return sprintf('%s[%s][%s]', $this->namespace, $id, $namespaceVersion);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the namespace cache key.
|
||||
*/
|
||||
private function getNamespaceCacheKey() : string
|
||||
{
|
||||
return sprintf(self::DOCTRINE_NAMESPACE_CACHEKEY, $this->namespace);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the namespace version.
|
||||
*/
|
||||
private function getNamespaceVersion() : int
|
||||
{
|
||||
if ($this->namespaceVersion !== null) {
|
||||
return $this->namespaceVersion;
|
||||
}
|
||||
|
||||
$namespaceCacheKey = $this->getNamespaceCacheKey();
|
||||
$this->namespaceVersion = (int) $this->doFetch($namespaceCacheKey) ?: 1;
|
||||
|
||||
return $this->namespaceVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default implementation of doFetchMultiple. Each driver that supports multi-get should owerwrite it.
|
||||
*
|
||||
* @param array $keys Array of keys to retrieve from cache
|
||||
*
|
||||
* @return array Array of values retrieved for the given keys.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches an entry from the cache.
|
||||
*
|
||||
* @param string $id The id of the cache entry to fetch.
|
||||
*
|
||||
* @return mixed|false The cached data or FALSE, if no cache entry exists for the given id.
|
||||
*/
|
||||
abstract protected function doFetch($id);
|
||||
|
||||
/**
|
||||
* Tests if an entry exists in the cache.
|
||||
*
|
||||
* @param string $id The cache id of the entry to check for.
|
||||
*
|
||||
* @return bool TRUE if a cache entry exists for the given cache id, FALSE otherwise.
|
||||
*/
|
||||
abstract protected function doContains($id);
|
||||
|
||||
/**
|
||||
* Default implementation of doSaveMultiple. Each driver that supports multi-put should override it.
|
||||
*
|
||||
* @param array $keysAndValues Array of keys and values to save in cache
|
||||
* @param int $lifetime The lifetime. If != 0, sets a specific lifetime for these
|
||||
* cache entries (0 => infinite lifeTime).
|
||||
*
|
||||
* @return bool TRUE if the operation was successful, FALSE if it wasn't.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts data into the cache.
|
||||
*
|
||||
* @param string $id The cache id.
|
||||
* @param string $data The cache entry/data.
|
||||
* @param int $lifeTime The lifetime. If != 0, sets a specific lifetime for this
|
||||
* cache entry (0 => infinite lifeTime).
|
||||
*
|
||||
* @return bool TRUE if the entry was successfully stored in the cache, FALSE otherwise.
|
||||
*/
|
||||
abstract protected function doSave($id, $data, $lifeTime = 0);
|
||||
|
||||
/**
|
||||
* Default implementation of doDeleteMultiple. Each driver that supports multi-delete should override it.
|
||||
*
|
||||
* @param array $keys Array of keys to delete from cache
|
||||
*
|
||||
* @return bool TRUE if the operation was successful, FALSE if it wasn't
|
||||
*/
|
||||
protected function doDeleteMultiple(array $keys)
|
||||
{
|
||||
$success = true;
|
||||
|
||||
foreach ($keys as $key) {
|
||||
if ($this->doDelete($key)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$success = false;
|
||||
}
|
||||
|
||||
return $success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a cache entry.
|
||||
*
|
||||
* @param string $id The cache id.
|
||||
*
|
||||
* @return bool TRUE if the cache entry was successfully deleted, FALSE otherwise.
|
||||
*/
|
||||
abstract protected function doDelete($id);
|
||||
|
||||
/**
|
||||
* Flushes all cache entries.
|
||||
*
|
||||
* @return bool TRUE if the cache entries were successfully flushed, FALSE otherwise.
|
||||
*/
|
||||
abstract protected function doFlush();
|
||||
|
||||
/**
|
||||
* Retrieves cached information from the data store.
|
||||
*
|
||||
* @return array|null An associative array with server's statistics if available, NULL otherwise.
|
||||
*/
|
||||
abstract protected function doGetStats();
|
||||
}
|
187
vendor/doctrine/cache/lib/Doctrine/Common/Cache/ChainCache.php
vendored
Normal file
187
vendor/doctrine/cache/lib/Doctrine/Common/Cache/ChainCache.php
vendored
Normal file
@ -0,0 +1,187 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
use Traversable;
|
||||
use function array_values;
|
||||
use function count;
|
||||
use function iterator_to_array;
|
||||
|
||||
/**
|
||||
* Cache provider that allows to easily chain multiple cache providers
|
||||
*/
|
||||
class ChainCache extends CacheProvider
|
||||
{
|
||||
/** @var CacheProvider[] */
|
||||
private $cacheProviders = [];
|
||||
|
||||
/**
|
||||
* @param CacheProvider[] $cacheProviders
|
||||
*/
|
||||
public function __construct($cacheProviders = [])
|
||||
{
|
||||
$this->cacheProviders = $cacheProviders instanceof Traversable
|
||||
? iterator_to_array($cacheProviders, false)
|
||||
: array_values($cacheProviders);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function setNamespace($namespace)
|
||||
{
|
||||
parent::setNamespace($namespace);
|
||||
|
||||
foreach ($this->cacheProviders as $cacheProvider) {
|
||||
$cacheProvider->setNamespace($namespace);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function doFetch($id)
|
||||
{
|
||||
foreach ($this->cacheProviders as $key => $cacheProvider) {
|
||||
if ($cacheProvider->doContains($id)) {
|
||||
$value = $cacheProvider->doFetch($id);
|
||||
|
||||
// We populate all the previous cache layers (that are assumed to be faster)
|
||||
for ($subKey = $key - 1; $subKey >= 0; $subKey--) {
|
||||
$this->cacheProviders[$subKey]->doSave($id, $value);
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFetchMultiple(array $keys)
|
||||
{
|
||||
/** @var CacheProvider[] $traversedProviders */
|
||||
$traversedProviders = [];
|
||||
$keysCount = count($keys);
|
||||
$fetchedValues = [];
|
||||
|
||||
foreach ($this->cacheProviders as $key => $cacheProvider) {
|
||||
$fetchedValues = $cacheProvider->doFetchMultiple($keys);
|
||||
|
||||
// We populate all the previous cache layers (that are assumed to be faster)
|
||||
if (count($fetchedValues) === $keysCount) {
|
||||
foreach ($traversedProviders as $previousCacheProvider) {
|
||||
$previousCacheProvider->doSaveMultiple($fetchedValues);
|
||||
}
|
||||
|
||||
return $fetchedValues;
|
||||
}
|
||||
|
||||
$traversedProviders[] = $cacheProvider;
|
||||
}
|
||||
|
||||
return $fetchedValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function doContains($id)
|
||||
{
|
||||
foreach ($this->cacheProviders as $cacheProvider) {
|
||||
if ($cacheProvider->doContains($id)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function doSave($id, $data, $lifeTime = 0)
|
||||
{
|
||||
$stored = true;
|
||||
|
||||
foreach ($this->cacheProviders as $cacheProvider) {
|
||||
$stored = $cacheProvider->doSave($id, $data, $lifeTime) && $stored;
|
||||
}
|
||||
|
||||
return $stored;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doSaveMultiple(array $keysAndValues, $lifetime = 0)
|
||||
{
|
||||
$stored = true;
|
||||
|
||||
foreach ($this->cacheProviders as $cacheProvider) {
|
||||
$stored = $cacheProvider->doSaveMultiple($keysAndValues, $lifetime) && $stored;
|
||||
}
|
||||
|
||||
return $stored;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function doDelete($id)
|
||||
{
|
||||
$deleted = true;
|
||||
|
||||
foreach ($this->cacheProviders as $cacheProvider) {
|
||||
$deleted = $cacheProvider->doDelete($id) && $deleted;
|
||||
}
|
||||
|
||||
return $deleted;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doDeleteMultiple(array $keys)
|
||||
{
|
||||
$deleted = true;
|
||||
|
||||
foreach ($this->cacheProviders as $cacheProvider) {
|
||||
$deleted = $cacheProvider->doDeleteMultiple($keys) && $deleted;
|
||||
}
|
||||
|
||||
return $deleted;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function doFlush()
|
||||
{
|
||||
$flushed = true;
|
||||
|
||||
foreach ($this->cacheProviders as $cacheProvider) {
|
||||
$flushed = $cacheProvider->doFlush() && $flushed;
|
||||
}
|
||||
|
||||
return $flushed;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function doGetStats()
|
||||
{
|
||||
// We return all the stats from all adapters
|
||||
$stats = [];
|
||||
|
||||
foreach ($this->cacheProviders as $cacheProvider) {
|
||||
$stats[] = $cacheProvider->doGetStats();
|
||||
}
|
||||
|
||||
return $stats;
|
||||
}
|
||||
}
|
21
vendor/doctrine/cache/lib/Doctrine/Common/Cache/ClearableCache.php
vendored
Normal file
21
vendor/doctrine/cache/lib/Doctrine/Common/Cache/ClearableCache.php
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
/**
|
||||
* Interface for cache that can be flushed.
|
||||
*
|
||||
* Intended to be used for partial clearing of a cache namespace. For a more
|
||||
* global "flushing", see {@see FlushableCache}.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
*/
|
||||
interface ClearableCache
|
||||
{
|
||||
/**
|
||||
* Deletes all cache entries in the current cache namespace.
|
||||
*
|
||||
* @return bool TRUE if the cache entries were successfully deleted, FALSE otherwise.
|
||||
*/
|
||||
public function deleteAll();
|
||||
}
|
197
vendor/doctrine/cache/lib/Doctrine/Common/Cache/CouchbaseBucketCache.php
vendored
Normal file
197
vendor/doctrine/cache/lib/Doctrine/Common/Cache/CouchbaseBucketCache.php
vendored
Normal file
@ -0,0 +1,197 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
use Couchbase\Bucket;
|
||||
use Couchbase\Document;
|
||||
use Couchbase\Exception;
|
||||
use RuntimeException;
|
||||
use function phpversion;
|
||||
use function serialize;
|
||||
use function sprintf;
|
||||
use function substr;
|
||||
use function time;
|
||||
use function unserialize;
|
||||
use function version_compare;
|
||||
|
||||
/**
|
||||
* Couchbase ^2.3.0 cache provider.
|
||||
*/
|
||||
final class CouchbaseBucketCache extends CacheProvider
|
||||
{
|
||||
private const MINIMUM_VERSION = '2.3.0';
|
||||
|
||||
private const KEY_NOT_FOUND = 13;
|
||||
|
||||
private const MAX_KEY_LENGTH = 250;
|
||||
|
||||
private const THIRTY_DAYS_IN_SECONDS = 2592000;
|
||||
|
||||
/** @var Bucket */
|
||||
private $bucket;
|
||||
|
||||
public function __construct(Bucket $bucket)
|
||||
{
|
||||
if (version_compare(phpversion('couchbase'), self::MINIMUM_VERSION) < 0) {
|
||||
// Manager is required to flush cache and pull stats.
|
||||
throw new RuntimeException(sprintf('ext-couchbase:^%s is required.', self::MINIMUM_VERSION));
|
||||
}
|
||||
|
||||
$this->bucket = $bucket;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFetch($id)
|
||||
{
|
||||
$id = $this->normalizeKey($id);
|
||||
|
||||
try {
|
||||
$document = $this->bucket->get($id);
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($document instanceof Document && $document->value !== false) {
|
||||
return unserialize($document->value);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doContains($id)
|
||||
{
|
||||
$id = $this->normalizeKey($id);
|
||||
|
||||
try {
|
||||
$document = $this->bucket->get($id);
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($document instanceof Document) {
|
||||
return ! $document->error;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doSave($id, $data, $lifeTime = 0)
|
||||
{
|
||||
$id = $this->normalizeKey($id);
|
||||
|
||||
$lifeTime = $this->normalizeExpiry($lifeTime);
|
||||
|
||||
try {
|
||||
$encoded = serialize($data);
|
||||
|
||||
$document = $this->bucket->upsert($id, $encoded, [
|
||||
'expiry' => (int) $lifeTime,
|
||||
]);
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($document instanceof Document) {
|
||||
return ! $document->error;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doDelete($id)
|
||||
{
|
||||
$id = $this->normalizeKey($id);
|
||||
|
||||
try {
|
||||
$document = $this->bucket->remove($id);
|
||||
} catch (Exception $e) {
|
||||
return $e->getCode() === self::KEY_NOT_FOUND;
|
||||
}
|
||||
|
||||
if ($document instanceof Document) {
|
||||
return ! $document->error;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFlush()
|
||||
{
|
||||
$manager = $this->bucket->manager();
|
||||
|
||||
// Flush does not return with success or failure, and must be enabled per bucket on the server.
|
||||
// Store a marker item so that we will know if it was successful.
|
||||
$this->doSave(__METHOD__, true, 60);
|
||||
|
||||
$manager->flush();
|
||||
|
||||
if ($this->doContains(__METHOD__)) {
|
||||
$this->doDelete(__METHOD__);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doGetStats()
|
||||
{
|
||||
$manager = $this->bucket->manager();
|
||||
$stats = $manager->info();
|
||||
$nodes = $stats['nodes'];
|
||||
$node = $nodes[0];
|
||||
$interestingStats = $node['interestingStats'];
|
||||
|
||||
return [
|
||||
Cache::STATS_HITS => $interestingStats['get_hits'],
|
||||
Cache::STATS_MISSES => $interestingStats['cmd_get'] - $interestingStats['get_hits'],
|
||||
Cache::STATS_UPTIME => $node['uptime'],
|
||||
Cache::STATS_MEMORY_USAGE => $interestingStats['mem_used'],
|
||||
Cache::STATS_MEMORY_AVAILABLE => $node['memoryFree'],
|
||||
];
|
||||
}
|
||||
|
||||
private function normalizeKey(string $id) : string
|
||||
{
|
||||
$normalized = substr($id, 0, self::MAX_KEY_LENGTH);
|
||||
|
||||
if ($normalized === false) {
|
||||
return $id;
|
||||
}
|
||||
|
||||
return $normalized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expiry treated as a unix timestamp instead of an offset if expiry is greater than 30 days.
|
||||
*
|
||||
* @src https://developer.couchbase.com/documentation/server/4.1/developer-guide/expiry.html
|
||||
*/
|
||||
private function normalizeExpiry(int $expiry) : int
|
||||
{
|
||||
if ($expiry > self::THIRTY_DAYS_IN_SECONDS) {
|
||||
return time() + $expiry;
|
||||
}
|
||||
|
||||
return $expiry;
|
||||
}
|
||||
}
|
105
vendor/doctrine/cache/lib/Doctrine/Common/Cache/CouchbaseCache.php
vendored
Normal file
105
vendor/doctrine/cache/lib/Doctrine/Common/Cache/CouchbaseCache.php
vendored
Normal file
@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
use Couchbase;
|
||||
use function explode;
|
||||
use function time;
|
||||
|
||||
/**
|
||||
* Couchbase cache provider.
|
||||
*
|
||||
* @deprecated Couchbase SDK 1.x is now deprecated. Use \Doctrine\Common\Cache\CouchbaseBucketCache instead.
|
||||
* https://developer.couchbase.com/documentation/server/current/sdk/php/compatibility-versions-features.html
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
*/
|
||||
class CouchbaseCache extends CacheProvider
|
||||
{
|
||||
/** @var Couchbase|null */
|
||||
private $couchbase;
|
||||
|
||||
/**
|
||||
* Sets the Couchbase instance to use.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setCouchbase(Couchbase $couchbase)
|
||||
{
|
||||
$this->couchbase = $couchbase;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Couchbase instance used by the cache.
|
||||
*
|
||||
* @return Couchbase|null
|
||||
*/
|
||||
public function getCouchbase()
|
||||
{
|
||||
return $this->couchbase;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFetch($id)
|
||||
{
|
||||
return $this->couchbase->get($id) ?: false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doContains($id)
|
||||
{
|
||||
return $this->couchbase->get($id) !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doSave($id, $data, $lifeTime = 0)
|
||||
{
|
||||
if ($lifeTime > 30 * 24 * 3600) {
|
||||
$lifeTime = time() + $lifeTime;
|
||||
}
|
||||
|
||||
return $this->couchbase->set($id, $data, (int) $lifeTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doDelete($id)
|
||||
{
|
||||
return $this->couchbase->delete($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFlush()
|
||||
{
|
||||
return $this->couchbase->flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doGetStats()
|
||||
{
|
||||
$stats = $this->couchbase->getStats();
|
||||
$servers = $this->couchbase->getServers();
|
||||
$server = explode(':', $servers[0]);
|
||||
$key = $server[0] . ':11210';
|
||||
$stats = $stats[$key];
|
||||
|
||||
return [
|
||||
Cache::STATS_HITS => $stats['get_hits'],
|
||||
Cache::STATS_MISSES => $stats['get_misses'],
|
||||
Cache::STATS_UPTIME => $stats['uptime'],
|
||||
Cache::STATS_MEMORY_USAGE => $stats['bytes'],
|
||||
Cache::STATS_MEMORY_AVAILABLE => $stats['limit_maxbytes'],
|
||||
];
|
||||
}
|
||||
}
|
198
vendor/doctrine/cache/lib/Doctrine/Common/Cache/ExtMongoDBCache.php
vendored
Normal file
198
vendor/doctrine/cache/lib/Doctrine/Common/Cache/ExtMongoDBCache.php
vendored
Normal file
@ -0,0 +1,198 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
use DateTime;
|
||||
use MongoDB\BSON\Binary;
|
||||
use MongoDB\BSON\UTCDateTime;
|
||||
use MongoDB\Collection;
|
||||
use MongoDB\Database;
|
||||
use MongoDB\Driver\Exception\Exception;
|
||||
use MongoDB\Model\BSONDocument;
|
||||
use function serialize;
|
||||
use function time;
|
||||
use function unserialize;
|
||||
|
||||
/**
|
||||
* MongoDB cache provider for ext-mongodb
|
||||
*
|
||||
* @internal Do not use - will be removed in 2.0. Use MongoDBCache instead
|
||||
*/
|
||||
class ExtMongoDBCache extends CacheProvider
|
||||
{
|
||||
/** @var Database */
|
||||
private $database;
|
||||
|
||||
/** @var Collection */
|
||||
private $collection;
|
||||
|
||||
/** @var bool */
|
||||
private $expirationIndexCreated = false;
|
||||
|
||||
/**
|
||||
* This provider will default to the write concern and read preference
|
||||
* options set on the Database instance (or inherited from MongoDB or
|
||||
* Client). Using an unacknowledged write concern (< 1) may make the return
|
||||
* values of delete() and save() unreliable. Reading from secondaries may
|
||||
* make contain() and fetch() unreliable.
|
||||
*
|
||||
* @see http://www.php.net/manual/en/mongo.readpreferences.php
|
||||
* @see http://www.php.net/manual/en/mongo.writeconcerns.php
|
||||
*/
|
||||
public function __construct(Collection $collection)
|
||||
{
|
||||
// Ensure there is no typemap set - we want to use our own
|
||||
$this->collection = $collection->withOptions(['typeMap' => null]);
|
||||
$this->database = new Database($collection->getManager(), $collection->getDatabaseName());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFetch($id)
|
||||
{
|
||||
$document = $this->collection->findOne(['_id' => $id], [MongoDBCache::DATA_FIELD, MongoDBCache::EXPIRATION_FIELD]);
|
||||
|
||||
if ($document === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->isExpired($document)) {
|
||||
$this->createExpirationIndex();
|
||||
$this->doDelete($id);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return unserialize($document[MongoDBCache::DATA_FIELD]->getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doContains($id)
|
||||
{
|
||||
$document = $this->collection->findOne(['_id' => $id], [MongoDBCache::EXPIRATION_FIELD]);
|
||||
|
||||
if ($document === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->isExpired($document)) {
|
||||
$this->createExpirationIndex();
|
||||
$this->doDelete($id);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doSave($id, $data, $lifeTime = 0)
|
||||
{
|
||||
try {
|
||||
$this->collection->updateOne(
|
||||
['_id' => $id],
|
||||
[
|
||||
'$set' => [
|
||||
MongoDBCache::EXPIRATION_FIELD => ($lifeTime > 0 ? new UTCDateTime((time() + $lifeTime) * 1000): null),
|
||||
MongoDBCache::DATA_FIELD => new Binary(serialize($data), Binary::TYPE_GENERIC),
|
||||
],
|
||||
],
|
||||
['upsert' => true]
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doDelete($id)
|
||||
{
|
||||
try {
|
||||
$this->collection->deleteOne(['_id' => $id]);
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFlush()
|
||||
{
|
||||
try {
|
||||
// Use remove() in lieu of drop() to maintain any collection indexes
|
||||
$this->collection->deleteMany([]);
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doGetStats()
|
||||
{
|
||||
$uptime = null;
|
||||
$memoryUsage = null;
|
||||
|
||||
try {
|
||||
$serverStatus = $this->database->command([
|
||||
'serverStatus' => 1,
|
||||
'locks' => 0,
|
||||
'metrics' => 0,
|
||||
'recordStats' => 0,
|
||||
'repl' => 0,
|
||||
])->toArray()[0];
|
||||
$uptime = $serverStatus['uptime'] ?? null;
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
|
||||
try {
|
||||
$collStats = $this->database->command(['collStats' => $this->collection->getCollectionName()])->toArray()[0];
|
||||
$memoryUsage = $collStats['size'] ?? null;
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
|
||||
return [
|
||||
Cache::STATS_HITS => null,
|
||||
Cache::STATS_MISSES => null,
|
||||
Cache::STATS_UPTIME => $uptime,
|
||||
Cache::STATS_MEMORY_USAGE => $memoryUsage,
|
||||
Cache::STATS_MEMORY_AVAILABLE => null,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the document is expired.
|
||||
*/
|
||||
private function isExpired(BSONDocument $document) : bool
|
||||
{
|
||||
return isset($document[MongoDBCache::EXPIRATION_FIELD]) &&
|
||||
$document[MongoDBCache::EXPIRATION_FIELD] instanceof UTCDateTime &&
|
||||
$document[MongoDBCache::EXPIRATION_FIELD]->toDateTime() < new DateTime();
|
||||
}
|
||||
|
||||
private function createExpirationIndex() : void
|
||||
{
|
||||
if ($this->expirationIndexCreated) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->collection->createIndex([MongoDBCache::EXPIRATION_FIELD => 1], ['background' => true, 'expireAfterSeconds' => 0]);
|
||||
}
|
||||
}
|
281
vendor/doctrine/cache/lib/Doctrine/Common/Cache/FileCache.php
vendored
Normal file
281
vendor/doctrine/cache/lib/Doctrine/Common/Cache/FileCache.php
vendored
Normal file
@ -0,0 +1,281 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
use FilesystemIterator;
|
||||
use InvalidArgumentException;
|
||||
use Iterator;
|
||||
use RecursiveDirectoryIterator;
|
||||
use RecursiveIteratorIterator;
|
||||
use const DIRECTORY_SEPARATOR;
|
||||
use const PATHINFO_DIRNAME;
|
||||
use function bin2hex;
|
||||
use function chmod;
|
||||
use function defined;
|
||||
use function disk_free_space;
|
||||
use function file_exists;
|
||||
use function file_put_contents;
|
||||
use function gettype;
|
||||
use function hash;
|
||||
use function is_dir;
|
||||
use function is_int;
|
||||
use function is_writable;
|
||||
use function mkdir;
|
||||
use function pathinfo;
|
||||
use function realpath;
|
||||
use function rename;
|
||||
use function rmdir;
|
||||
use function sprintf;
|
||||
use function strlen;
|
||||
use function strrpos;
|
||||
use function substr;
|
||||
use function tempnam;
|
||||
use function unlink;
|
||||
|
||||
/**
|
||||
* Base file cache driver.
|
||||
*/
|
||||
abstract class FileCache extends CacheProvider
|
||||
{
|
||||
/**
|
||||
* The cache directory.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $directory;
|
||||
|
||||
/**
|
||||
* The cache file extension.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $extension;
|
||||
|
||||
/** @var int */
|
||||
private $umask;
|
||||
|
||||
/** @var int */
|
||||
private $directoryStringLength;
|
||||
|
||||
/** @var int */
|
||||
private $extensionStringLength;
|
||||
|
||||
/** @var bool */
|
||||
private $isRunningOnWindows;
|
||||
|
||||
/**
|
||||
* @param string $directory The cache directory.
|
||||
* @param string $extension The cache file extension.
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function __construct($directory, $extension = '', $umask = 0002)
|
||||
{
|
||||
// YES, this needs to be *before* createPathIfNeeded()
|
||||
if (! is_int($umask)) {
|
||||
throw new InvalidArgumentException(sprintf(
|
||||
'The umask parameter is required to be integer, was: %s',
|
||||
gettype($umask)
|
||||
));
|
||||
}
|
||||
$this->umask = $umask;
|
||||
|
||||
if (! $this->createPathIfNeeded($directory)) {
|
||||
throw new InvalidArgumentException(sprintf(
|
||||
'The directory "%s" does not exist and could not be created.',
|
||||
$directory
|
||||
));
|
||||
}
|
||||
|
||||
if (! is_writable($directory)) {
|
||||
throw new InvalidArgumentException(sprintf(
|
||||
'The directory "%s" is not writable.',
|
||||
$directory
|
||||
));
|
||||
}
|
||||
|
||||
// YES, this needs to be *after* createPathIfNeeded()
|
||||
$this->directory = realpath($directory);
|
||||
$this->extension = (string) $extension;
|
||||
|
||||
$this->directoryStringLength = strlen($this->directory);
|
||||
$this->extensionStringLength = strlen($this->extension);
|
||||
$this->isRunningOnWindows = defined('PHP_WINDOWS_VERSION_BUILD');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the cache directory.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDirectory()
|
||||
{
|
||||
return $this->directory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the cache file extension.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getExtension()
|
||||
{
|
||||
return $this->extension;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getFilename($id)
|
||||
{
|
||||
$hash = hash('sha256', $id);
|
||||
|
||||
// This ensures that the filename is unique and that there are no invalid chars in it.
|
||||
if ($id === ''
|
||||
|| ((strlen($id) * 2 + $this->extensionStringLength) > 255)
|
||||
|| ($this->isRunningOnWindows && ($this->directoryStringLength + 4 + strlen($id) * 2 + $this->extensionStringLength) > 258)
|
||||
) {
|
||||
// Most filesystems have a limit of 255 chars for each path component. On Windows the the whole path is limited
|
||||
// to 260 chars (including terminating null char). Using long UNC ("\\?\" prefix) does not work with the PHP API.
|
||||
// And there is a bug in PHP (https://bugs.php.net/bug.php?id=70943) with path lengths of 259.
|
||||
// So if the id in hex representation would surpass the limit, we use the hash instead. The prefix prevents
|
||||
// collisions between the hash and bin2hex.
|
||||
$filename = '_' . $hash;
|
||||
} else {
|
||||
$filename = bin2hex($id);
|
||||
}
|
||||
|
||||
return $this->directory
|
||||
. DIRECTORY_SEPARATOR
|
||||
. substr($hash, 0, 2)
|
||||
. DIRECTORY_SEPARATOR
|
||||
. $filename
|
||||
. $this->extension;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doDelete($id)
|
||||
{
|
||||
$filename = $this->getFilename($id);
|
||||
|
||||
return @unlink($filename) || ! file_exists($filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFlush()
|
||||
{
|
||||
foreach ($this->getIterator() as $name => $file) {
|
||||
if ($file->isDir()) {
|
||||
// Remove the intermediate directories which have been created to balance the tree. It only takes effect
|
||||
// if the directory is empty. If several caches share the same directory but with different file extensions,
|
||||
// the other ones are not removed.
|
||||
@rmdir($name);
|
||||
} elseif ($this->isFilenameEndingWithExtension($name)) {
|
||||
// If an extension is set, only remove files which end with the given extension.
|
||||
// If no extension is set, we have no other choice than removing everything.
|
||||
@unlink($name);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doGetStats()
|
||||
{
|
||||
$usage = 0;
|
||||
foreach ($this->getIterator() as $name => $file) {
|
||||
if ($file->isDir() || ! $this->isFilenameEndingWithExtension($name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$usage += $file->getSize();
|
||||
}
|
||||
|
||||
$free = disk_free_space($this->directory);
|
||||
|
||||
return [
|
||||
Cache::STATS_HITS => null,
|
||||
Cache::STATS_MISSES => null,
|
||||
Cache::STATS_UPTIME => null,
|
||||
Cache::STATS_MEMORY_USAGE => $usage,
|
||||
Cache::STATS_MEMORY_AVAILABLE => $free,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Create path if needed.
|
||||
*
|
||||
* @return bool TRUE on success or if path already exists, FALSE if path cannot be created.
|
||||
*/
|
||||
private function createPathIfNeeded(string $path) : bool
|
||||
{
|
||||
if (! is_dir($path)) {
|
||||
if (@mkdir($path, 0777 & (~$this->umask), true) === false && ! is_dir($path)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a string content to file in an atomic way.
|
||||
*
|
||||
* @param string $filename Path to the file where to write the data.
|
||||
* @param string $content The content to write
|
||||
*
|
||||
* @return bool TRUE on success, FALSE if path cannot be created, if path is not writable or an any other error.
|
||||
*/
|
||||
protected function writeFile(string $filename, string $content) : bool
|
||||
{
|
||||
$filepath = pathinfo($filename, PATHINFO_DIRNAME);
|
||||
|
||||
if (! $this->createPathIfNeeded($filepath)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (! is_writable($filepath)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$tmpFile = tempnam($filepath, 'swap');
|
||||
@chmod($tmpFile, 0666 & (~$this->umask));
|
||||
|
||||
if (file_put_contents($tmpFile, $content) !== false) {
|
||||
@chmod($tmpFile, 0666 & (~$this->umask));
|
||||
if (@rename($tmpFile, $filename)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@unlink($tmpFile);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private function getIterator() : Iterator
|
||||
{
|
||||
return new RecursiveIteratorIterator(
|
||||
new RecursiveDirectoryIterator($this->directory, FilesystemIterator::SKIP_DOTS),
|
||||
RecursiveIteratorIterator::CHILD_FIRST
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name The filename
|
||||
*/
|
||||
private function isFilenameEndingWithExtension(string $name) : bool
|
||||
{
|
||||
return $this->extension === ''
|
||||
|| strrpos($name, $this->extension) === (strlen($name) - $this->extensionStringLength);
|
||||
}
|
||||
}
|
102
vendor/doctrine/cache/lib/Doctrine/Common/Cache/FilesystemCache.php
vendored
Normal file
102
vendor/doctrine/cache/lib/Doctrine/Common/Cache/FilesystemCache.php
vendored
Normal file
@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
use const PHP_EOL;
|
||||
use function fclose;
|
||||
use function fgets;
|
||||
use function fopen;
|
||||
use function is_file;
|
||||
use function serialize;
|
||||
use function time;
|
||||
use function unserialize;
|
||||
|
||||
/**
|
||||
* Filesystem cache driver.
|
||||
*/
|
||||
class FilesystemCache extends FileCache
|
||||
{
|
||||
public const EXTENSION = '.doctrinecache.data';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct($directory, $extension = self::EXTENSION, $umask = 0002)
|
||||
{
|
||||
parent::__construct($directory, $extension, $umask);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFetch($id)
|
||||
{
|
||||
$data = '';
|
||||
$lifetime = -1;
|
||||
$filename = $this->getFilename($id);
|
||||
|
||||
if (! is_file($filename)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$resource = fopen($filename, 'r');
|
||||
$line = fgets($resource);
|
||||
|
||||
if ($line !== false) {
|
||||
$lifetime = (int) $line;
|
||||
}
|
||||
|
||||
if ($lifetime !== 0 && $lifetime < time()) {
|
||||
fclose($resource);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
while (($line = fgets($resource)) !== false) {
|
||||
$data .= $line;
|
||||
}
|
||||
|
||||
fclose($resource);
|
||||
|
||||
return unserialize($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doContains($id)
|
||||
{
|
||||
$lifetime = -1;
|
||||
$filename = $this->getFilename($id);
|
||||
|
||||
if (! is_file($filename)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$resource = fopen($filename, 'r');
|
||||
$line = fgets($resource);
|
||||
|
||||
if ($line !== false) {
|
||||
$lifetime = (int) $line;
|
||||
}
|
||||
|
||||
fclose($resource);
|
||||
|
||||
return $lifetime === 0 || $lifetime > time();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doSave($id, $data, $lifeTime = 0)
|
||||
{
|
||||
if ($lifeTime > 0) {
|
||||
$lifeTime = time() + $lifeTime;
|
||||
}
|
||||
|
||||
$data = serialize($data);
|
||||
$filename = $this->getFilename($id);
|
||||
|
||||
return $this->writeFile($filename, $lifeTime . PHP_EOL . $data);
|
||||
}
|
||||
}
|
18
vendor/doctrine/cache/lib/Doctrine/Common/Cache/FlushableCache.php
vendored
Normal file
18
vendor/doctrine/cache/lib/Doctrine/Common/Cache/FlushableCache.php
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
/**
|
||||
* Interface for cache that can be flushed.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
*/
|
||||
interface FlushableCache
|
||||
{
|
||||
/**
|
||||
* Flushes all cache entries, globally.
|
||||
*
|
||||
* @return bool TRUE if the cache entries were successfully flushed, FALSE otherwise.
|
||||
*/
|
||||
public function flushAll();
|
||||
}
|
25
vendor/doctrine/cache/lib/Doctrine/Common/Cache/InvalidCacheId.php
vendored
Normal file
25
vendor/doctrine/cache/lib/Doctrine/Common/Cache/InvalidCacheId.php
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use function sprintf;
|
||||
|
||||
final class InvalidCacheId extends InvalidArgumentException
|
||||
{
|
||||
public static function exceedsMaxLength($id, int $maxLength) : self
|
||||
{
|
||||
return new self(sprintf('Cache id "%s" exceeds maximum length %d', $id, $maxLength));
|
||||
}
|
||||
|
||||
public static function containsUnauthorizedCharacter($id, string $character) : self
|
||||
{
|
||||
return new self(sprintf('Cache id "%s" contains unauthorized character "%s"', $id, $character));
|
||||
}
|
||||
|
||||
public static function containsControlCharacter($id) : self
|
||||
{
|
||||
return new self(sprintf('Cache id "%s" contains at least one control character', $id));
|
||||
}
|
||||
}
|
175
vendor/doctrine/cache/lib/Doctrine/Common/Cache/LegacyMongoDBCache.php
vendored
Normal file
175
vendor/doctrine/cache/lib/Doctrine/Common/Cache/LegacyMongoDBCache.php
vendored
Normal file
@ -0,0 +1,175 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
use MongoBinData;
|
||||
use MongoCollection;
|
||||
use MongoCursorException;
|
||||
use MongoDate;
|
||||
use const E_USER_DEPRECATED;
|
||||
use function serialize;
|
||||
use function time;
|
||||
use function trigger_error;
|
||||
use function unserialize;
|
||||
|
||||
/**
|
||||
* MongoDB cache provider.
|
||||
*
|
||||
* @internal Do not use - will be removed in 2.0. Use MongoDBCache instead
|
||||
*/
|
||||
class LegacyMongoDBCache extends CacheProvider
|
||||
{
|
||||
/** @var MongoCollection */
|
||||
private $collection;
|
||||
|
||||
/** @var bool */
|
||||
private $expirationIndexCreated = false;
|
||||
|
||||
/**
|
||||
* This provider will default to the write concern and read preference
|
||||
* options set on the MongoCollection instance (or inherited from MongoDB or
|
||||
* MongoClient). Using an unacknowledged write concern (< 1) may make the
|
||||
* return values of delete() and save() unreliable. Reading from secondaries
|
||||
* may make contain() and fetch() unreliable.
|
||||
*
|
||||
* @see http://www.php.net/manual/en/mongo.readpreferences.php
|
||||
* @see http://www.php.net/manual/en/mongo.writeconcerns.php
|
||||
*/
|
||||
public function __construct(MongoCollection $collection)
|
||||
{
|
||||
@trigger_error('Using the legacy MongoDB cache provider is deprecated and will be removed in 2.0', E_USER_DEPRECATED);
|
||||
$this->collection = $collection;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFetch($id)
|
||||
{
|
||||
$document = $this->collection->findOne(['_id' => $id], [MongoDBCache::DATA_FIELD, MongoDBCache::EXPIRATION_FIELD]);
|
||||
|
||||
if ($document === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->isExpired($document)) {
|
||||
$this->createExpirationIndex();
|
||||
$this->doDelete($id);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return unserialize($document[MongoDBCache::DATA_FIELD]->bin);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doContains($id)
|
||||
{
|
||||
$document = $this->collection->findOne(['_id' => $id], [MongoDBCache::EXPIRATION_FIELD]);
|
||||
|
||||
if ($document === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->isExpired($document)) {
|
||||
$this->createExpirationIndex();
|
||||
$this->doDelete($id);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doSave($id, $data, $lifeTime = 0)
|
||||
{
|
||||
try {
|
||||
$result = $this->collection->update(
|
||||
['_id' => $id],
|
||||
[
|
||||
'$set' => [
|
||||
MongoDBCache::EXPIRATION_FIELD => ($lifeTime > 0 ? new MongoDate(time() + $lifeTime) : null),
|
||||
MongoDBCache::DATA_FIELD => new MongoBinData(serialize($data), MongoBinData::BYTE_ARRAY),
|
||||
],
|
||||
],
|
||||
['upsert' => true, 'multiple' => false]
|
||||
);
|
||||
} catch (MongoCursorException $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return ($result['ok'] ?? 1) == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doDelete($id)
|
||||
{
|
||||
$result = $this->collection->remove(['_id' => $id]);
|
||||
|
||||
return ($result['ok'] ?? 1) == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFlush()
|
||||
{
|
||||
// Use remove() in lieu of drop() to maintain any collection indexes
|
||||
$result = $this->collection->remove();
|
||||
|
||||
return ($result['ok'] ?? 1) == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doGetStats()
|
||||
{
|
||||
$serverStatus = $this->collection->db->command([
|
||||
'serverStatus' => 1,
|
||||
'locks' => 0,
|
||||
'metrics' => 0,
|
||||
'recordStats' => 0,
|
||||
'repl' => 0,
|
||||
]);
|
||||
|
||||
$collStats = $this->collection->db->command(['collStats' => 1]);
|
||||
|
||||
return [
|
||||
Cache::STATS_HITS => null,
|
||||
Cache::STATS_MISSES => null,
|
||||
Cache::STATS_UPTIME => $serverStatus['uptime'] ?? null,
|
||||
Cache::STATS_MEMORY_USAGE => $collStats['size'] ?? null,
|
||||
Cache::STATS_MEMORY_AVAILABLE => null,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the document is expired.
|
||||
*
|
||||
* @param array $document
|
||||
*/
|
||||
private function isExpired(array $document) : bool
|
||||
{
|
||||
return isset($document[MongoDBCache::EXPIRATION_FIELD]) &&
|
||||
$document[MongoDBCache::EXPIRATION_FIELD] instanceof MongoDate &&
|
||||
$document[MongoDBCache::EXPIRATION_FIELD]->sec < time();
|
||||
}
|
||||
|
||||
private function createExpirationIndex() : void
|
||||
{
|
||||
if ($this->expirationIndexCreated) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->expirationIndexCreated = true;
|
||||
$this->collection->createIndex([MongoDBCache::EXPIRATION_FIELD => 1], ['background' => true, 'expireAfterSeconds' => 0]);
|
||||
}
|
||||
}
|
104
vendor/doctrine/cache/lib/Doctrine/Common/Cache/MemcacheCache.php
vendored
Normal file
104
vendor/doctrine/cache/lib/Doctrine/Common/Cache/MemcacheCache.php
vendored
Normal file
@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
use Memcache;
|
||||
use function time;
|
||||
|
||||
/**
|
||||
* Memcache cache provider.
|
||||
*
|
||||
* @deprecated
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
*/
|
||||
class MemcacheCache extends CacheProvider
|
||||
{
|
||||
/** @var Memcache|null */
|
||||
private $memcache;
|
||||
|
||||
/**
|
||||
* Sets the memcache instance to use.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setMemcache(Memcache $memcache)
|
||||
{
|
||||
$this->memcache = $memcache;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the memcache instance used by the cache.
|
||||
*
|
||||
* @return Memcache|null
|
||||
*/
|
||||
public function getMemcache()
|
||||
{
|
||||
return $this->memcache;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFetch($id)
|
||||
{
|
||||
return $this->memcache->get($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doContains($id)
|
||||
{
|
||||
$flags = null;
|
||||
$this->memcache->get($id, $flags);
|
||||
|
||||
//if memcache has changed the value of "flags", it means the value exists
|
||||
return $flags !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doSave($id, $data, $lifeTime = 0)
|
||||
{
|
||||
if ($lifeTime > 30 * 24 * 3600) {
|
||||
$lifeTime = time() + $lifeTime;
|
||||
}
|
||||
|
||||
return $this->memcache->set($id, $data, 0, (int) $lifeTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doDelete($id)
|
||||
{
|
||||
// Memcache::delete() returns false if entry does not exist
|
||||
return $this->memcache->delete($id) || ! $this->doContains($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFlush()
|
||||
{
|
||||
return $this->memcache->flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doGetStats()
|
||||
{
|
||||
$stats = $this->memcache->getStats();
|
||||
|
||||
return [
|
||||
Cache::STATS_HITS => $stats['get_hits'],
|
||||
Cache::STATS_MISSES => $stats['get_misses'],
|
||||
Cache::STATS_UPTIME => $stats['uptime'],
|
||||
Cache::STATS_MEMORY_USAGE => $stats['bytes'],
|
||||
Cache::STATS_MEMORY_AVAILABLE => $stats['limit_maxbytes'],
|
||||
];
|
||||
}
|
||||
}
|
170
vendor/doctrine/cache/lib/Doctrine/Common/Cache/MemcachedCache.php
vendored
Normal file
170
vendor/doctrine/cache/lib/Doctrine/Common/Cache/MemcachedCache.php
vendored
Normal file
@ -0,0 +1,170 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
use Memcached;
|
||||
use function array_keys;
|
||||
use function preg_match;
|
||||
use function strlen;
|
||||
use function strpos;
|
||||
use function time;
|
||||
|
||||
/**
|
||||
* Memcached cache provider.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
*/
|
||||
class MemcachedCache extends CacheProvider
|
||||
{
|
||||
public const CACHE_ID_MAX_LENGTH = 250;
|
||||
|
||||
/** @var Memcached|null */
|
||||
private $memcached;
|
||||
|
||||
/**
|
||||
* Sets the memcache instance to use.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setMemcached(Memcached $memcached)
|
||||
{
|
||||
$this->memcached = $memcached;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the memcached instance used by the cache.
|
||||
*
|
||||
* @return Memcached|null
|
||||
*/
|
||||
public function getMemcached()
|
||||
{
|
||||
return $this->memcached;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFetch($id)
|
||||
{
|
||||
return $this->memcached->get($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFetchMultiple(array $keys)
|
||||
{
|
||||
return $this->memcached->getMulti($keys) ?: [];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doSaveMultiple(array $keysAndValues, $lifetime = 0)
|
||||
{
|
||||
foreach (array_keys($keysAndValues) as $id) {
|
||||
$this->validateCacheId($id);
|
||||
}
|
||||
|
||||
if ($lifetime > 30 * 24 * 3600) {
|
||||
$lifetime = time() + $lifetime;
|
||||
}
|
||||
|
||||
return $this->memcached->setMulti($keysAndValues, $lifetime);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doContains($id)
|
||||
{
|
||||
$this->memcached->get($id);
|
||||
|
||||
return $this->memcached->getResultCode() === Memcached::RES_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doSave($id, $data, $lifeTime = 0)
|
||||
{
|
||||
$this->validateCacheId($id);
|
||||
|
||||
if ($lifeTime > 30 * 24 * 3600) {
|
||||
$lifeTime = time() + $lifeTime;
|
||||
}
|
||||
|
||||
return $this->memcached->set($id, $data, (int) $lifeTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doDeleteMultiple(array $keys)
|
||||
{
|
||||
return $this->memcached->deleteMulti($keys)
|
||||
|| $this->memcached->getResultCode() === Memcached::RES_NOTFOUND;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doDelete($id)
|
||||
{
|
||||
return $this->memcached->delete($id)
|
||||
|| $this->memcached->getResultCode() === Memcached::RES_NOTFOUND;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFlush()
|
||||
{
|
||||
return $this->memcached->flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doGetStats()
|
||||
{
|
||||
$stats = $this->memcached->getStats();
|
||||
$servers = $this->memcached->getServerList();
|
||||
$key = $servers[0]['host'] . ':' . $servers[0]['port'];
|
||||
$stats = $stats[$key];
|
||||
|
||||
return [
|
||||
Cache::STATS_HITS => $stats['get_hits'],
|
||||
Cache::STATS_MISSES => $stats['get_misses'],
|
||||
Cache::STATS_UPTIME => $stats['uptime'],
|
||||
Cache::STATS_MEMORY_USAGE => $stats['bytes'],
|
||||
Cache::STATS_MEMORY_AVAILABLE => $stats['limit_maxbytes'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the cache id
|
||||
*
|
||||
* @see https://github.com/memcached/memcached/blob/1.5.12/doc/protocol.txt#L41-L49
|
||||
*
|
||||
* @param string $id
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws InvalidCacheId
|
||||
*/
|
||||
private function validateCacheId($id)
|
||||
{
|
||||
if (strlen($id) > self::CACHE_ID_MAX_LENGTH) {
|
||||
throw InvalidCacheId::exceedsMaxLength($id, self::CACHE_ID_MAX_LENGTH);
|
||||
}
|
||||
|
||||
if (strpos($id, ' ') !== false) {
|
||||
throw InvalidCacheId::containsUnauthorizedCharacter($id, ' ');
|
||||
}
|
||||
|
||||
if (preg_match('/[\t\r\n]/', $id) === 1) {
|
||||
throw InvalidCacheId::containsControlCharacter($id);
|
||||
}
|
||||
}
|
||||
}
|
112
vendor/doctrine/cache/lib/Doctrine/Common/Cache/MongoDBCache.php
vendored
Normal file
112
vendor/doctrine/cache/lib/Doctrine/Common/Cache/MongoDBCache.php
vendored
Normal file
@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use MongoCollection;
|
||||
use MongoDB\Collection;
|
||||
use const E_USER_DEPRECATED;
|
||||
use function trigger_error;
|
||||
|
||||
/**
|
||||
* MongoDB cache provider.
|
||||
*/
|
||||
class MongoDBCache extends CacheProvider
|
||||
{
|
||||
/**
|
||||
* The data field will store the serialized PHP value.
|
||||
*/
|
||||
public const DATA_FIELD = 'd';
|
||||
|
||||
/**
|
||||
* The expiration field will store a MongoDate value indicating when the
|
||||
* cache entry should expire.
|
||||
*
|
||||
* With MongoDB 2.2+, entries can be automatically deleted by MongoDB by
|
||||
* indexing this field with the "expireAfterSeconds" option equal to zero.
|
||||
* This will direct MongoDB to regularly query for and delete any entries
|
||||
* whose date is older than the current time. Entries without a date value
|
||||
* in this field will be ignored.
|
||||
*
|
||||
* The cache provider will also check dates on its own, in case expired
|
||||
* entries are fetched before MongoDB's TTLMonitor pass can expire them.
|
||||
*
|
||||
* @see http://docs.mongodb.org/manual/tutorial/expire-data/
|
||||
*/
|
||||
public const EXPIRATION_FIELD = 'e';
|
||||
|
||||
/** @var CacheProvider */
|
||||
private $provider;
|
||||
|
||||
/**
|
||||
* This provider will default to the write concern and read preference
|
||||
* options set on the collection instance (or inherited from MongoDB or
|
||||
* MongoClient). Using an unacknowledged write concern (< 1) may make the
|
||||
* return values of delete() and save() unreliable. Reading from secondaries
|
||||
* may make contain() and fetch() unreliable.
|
||||
*
|
||||
* @see http://www.php.net/manual/en/mongo.readpreferences.php
|
||||
* @see http://www.php.net/manual/en/mongo.writeconcerns.php
|
||||
*
|
||||
* @param MongoCollection|Collection $collection
|
||||
*/
|
||||
public function __construct($collection)
|
||||
{
|
||||
if ($collection instanceof MongoCollection) {
|
||||
@trigger_error('Using a MongoCollection instance for creating a cache adapter is deprecated and will be removed in 2.0', E_USER_DEPRECATED);
|
||||
$this->provider = new LegacyMongoDBCache($collection);
|
||||
} elseif ($collection instanceof Collection) {
|
||||
$this->provider = new ExtMongoDBCache($collection);
|
||||
} else {
|
||||
throw new InvalidArgumentException('Invalid collection given - expected a MongoCollection or MongoDB\Collection instance');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFetch($id)
|
||||
{
|
||||
return $this->provider->doFetch($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doContains($id)
|
||||
{
|
||||
return $this->provider->doContains($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doSave($id, $data, $lifeTime = 0)
|
||||
{
|
||||
return $this->provider->doSave($id, $data, $lifeTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doDelete($id)
|
||||
{
|
||||
return $this->provider->doDelete($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFlush()
|
||||
{
|
||||
return $this->provider->doFlush();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doGetStats()
|
||||
{
|
||||
return $this->provider->doGetStats();
|
||||
}
|
||||
}
|
22
vendor/doctrine/cache/lib/Doctrine/Common/Cache/MultiDeleteCache.php
vendored
Normal file
22
vendor/doctrine/cache/lib/Doctrine/Common/Cache/MultiDeleteCache.php
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
/**
|
||||
* Interface for cache drivers that allows to put many items at once.
|
||||
*
|
||||
* @deprecated
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
*/
|
||||
interface MultiDeleteCache
|
||||
{
|
||||
/**
|
||||
* Deletes several cache entries.
|
||||
*
|
||||
* @param string[] $keys Array of keys to delete from cache
|
||||
*
|
||||
* @return bool TRUE if the operation was successful, FALSE if it wasn't.
|
||||
*/
|
||||
public function deleteMultiple(array $keys);
|
||||
}
|
23
vendor/doctrine/cache/lib/Doctrine/Common/Cache/MultiGetCache.php
vendored
Normal file
23
vendor/doctrine/cache/lib/Doctrine/Common/Cache/MultiGetCache.php
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
/**
|
||||
* Interface for cache drivers that allows to get many items at once.
|
||||
*
|
||||
* @deprecated
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
*/
|
||||
interface MultiGetCache
|
||||
{
|
||||
/**
|
||||
* Returns an associative array of values for keys is found in cache.
|
||||
*
|
||||
* @param string[] $keys Array of keys to retrieve from cache
|
||||
*
|
||||
* @return mixed[] Array of retrieved values, indexed by the specified keys.
|
||||
* Values that couldn't be retrieved are not contained in this array.
|
||||
*/
|
||||
public function fetchMultiple(array $keys);
|
||||
}
|
12
vendor/doctrine/cache/lib/Doctrine/Common/Cache/MultiOperationCache.php
vendored
Normal file
12
vendor/doctrine/cache/lib/Doctrine/Common/Cache/MultiOperationCache.php
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
/**
|
||||
* Interface for cache drivers that supports multiple items manipulation.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
*/
|
||||
interface MultiOperationCache extends MultiGetCache, MultiDeleteCache, MultiPutCache
|
||||
{
|
||||
}
|
24
vendor/doctrine/cache/lib/Doctrine/Common/Cache/MultiPutCache.php
vendored
Normal file
24
vendor/doctrine/cache/lib/Doctrine/Common/Cache/MultiPutCache.php
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
/**
|
||||
* Interface for cache drivers that allows to put many items at once.
|
||||
*
|
||||
* @deprecated
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
*/
|
||||
interface MultiPutCache
|
||||
{
|
||||
/**
|
||||
* Returns a boolean value indicating if the operation succeeded.
|
||||
*
|
||||
* @param array $keysAndValues Array of keys and values to save in cache
|
||||
* @param int $lifetime The lifetime. If != 0, sets a specific lifetime for these
|
||||
* cache entries (0 => infinite lifeTime).
|
||||
*
|
||||
* @return bool TRUE if the operation was successful, FALSE if it wasn't.
|
||||
*/
|
||||
public function saveMultiple(array $keysAndValues, $lifetime = 0);
|
||||
}
|
118
vendor/doctrine/cache/lib/Doctrine/Common/Cache/PhpFileCache.php
vendored
Normal file
118
vendor/doctrine/cache/lib/Doctrine/Common/Cache/PhpFileCache.php
vendored
Normal file
@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
use function is_object;
|
||||
use function method_exists;
|
||||
use function restore_error_handler;
|
||||
use function serialize;
|
||||
use function set_error_handler;
|
||||
use function sprintf;
|
||||
use function time;
|
||||
use function var_export;
|
||||
|
||||
/**
|
||||
* Php file cache driver.
|
||||
*/
|
||||
class PhpFileCache extends FileCache
|
||||
{
|
||||
public const EXTENSION = '.doctrinecache.php';
|
||||
|
||||
/**
|
||||
* @var callable
|
||||
*
|
||||
* This is cached in a local static variable to avoid instantiating a closure each time we need an empty handler
|
||||
*/
|
||||
private static $emptyErrorHandler;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct($directory, $extension = self::EXTENSION, $umask = 0002)
|
||||
{
|
||||
parent::__construct($directory, $extension, $umask);
|
||||
|
||||
self::$emptyErrorHandler = static function () {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFetch($id)
|
||||
{
|
||||
$value = $this->includeFileForId($id);
|
||||
|
||||
if ($value === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($value['lifetime'] !== 0 && $value['lifetime'] < time()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $value['data'];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doContains($id)
|
||||
{
|
||||
$value = $this->includeFileForId($id);
|
||||
|
||||
if ($value === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $value['lifetime'] === 0 || $value['lifetime'] > time();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doSave($id, $data, $lifeTime = 0)
|
||||
{
|
||||
if ($lifeTime > 0) {
|
||||
$lifeTime = time() + $lifeTime;
|
||||
}
|
||||
|
||||
$filename = $this->getFilename($id);
|
||||
|
||||
$value = [
|
||||
'lifetime' => $lifeTime,
|
||||
'data' => $data,
|
||||
];
|
||||
|
||||
if (is_object($data) && method_exists($data, '__set_state')) {
|
||||
$value = var_export($value, true);
|
||||
$code = sprintf('<?php return %s;', $value);
|
||||
} else {
|
||||
$value = var_export(serialize($value), true);
|
||||
$code = sprintf('<?php return unserialize(%s);', $value);
|
||||
}
|
||||
|
||||
return $this->writeFile($filename, $code);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|null
|
||||
*/
|
||||
private function includeFileForId(string $id) : ?array
|
||||
{
|
||||
$fileName = $this->getFilename($id);
|
||||
|
||||
// note: error suppression is still faster than `file_exists`, `is_file` and `is_readable`
|
||||
set_error_handler(self::$emptyErrorHandler);
|
||||
|
||||
$value = include $fileName;
|
||||
|
||||
restore_error_handler();
|
||||
|
||||
if (! isset($value['lifetime'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
}
|
143
vendor/doctrine/cache/lib/Doctrine/Common/Cache/PredisCache.php
vendored
Normal file
143
vendor/doctrine/cache/lib/Doctrine/Common/Cache/PredisCache.php
vendored
Normal file
@ -0,0 +1,143 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
use Predis\ClientInterface;
|
||||
use function array_combine;
|
||||
use function array_filter;
|
||||
use function array_map;
|
||||
use function call_user_func_array;
|
||||
use function serialize;
|
||||
use function unserialize;
|
||||
|
||||
/**
|
||||
* Predis cache provider.
|
||||
*/
|
||||
class PredisCache extends CacheProvider
|
||||
{
|
||||
/** @var ClientInterface */
|
||||
private $client;
|
||||
|
||||
public function __construct(ClientInterface $client)
|
||||
{
|
||||
$this->client = $client;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFetch($id)
|
||||
{
|
||||
$result = $this->client->get($id);
|
||||
if ($result === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return unserialize($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFetchMultiple(array $keys)
|
||||
{
|
||||
$fetchedItems = call_user_func_array([$this->client, 'mget'], $keys);
|
||||
|
||||
return array_map('unserialize', array_filter(array_combine($keys, $fetchedItems)));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doSaveMultiple(array $keysAndValues, $lifetime = 0)
|
||||
{
|
||||
if ($lifetime) {
|
||||
$success = true;
|
||||
|
||||
// Keys have lifetime, use SETEX for each of them
|
||||
foreach ($keysAndValues as $key => $value) {
|
||||
$response = (string) $this->client->setex($key, $lifetime, serialize($value));
|
||||
|
||||
if ($response == 'OK') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$success = false;
|
||||
}
|
||||
|
||||
return $success;
|
||||
}
|
||||
|
||||
// No lifetime, use MSET
|
||||
$response = $this->client->mset(array_map(static function ($value) {
|
||||
return serialize($value);
|
||||
}, $keysAndValues));
|
||||
|
||||
return (string) $response == 'OK';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doContains($id)
|
||||
{
|
||||
return (bool) $this->client->exists($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doSave($id, $data, $lifeTime = 0)
|
||||
{
|
||||
$data = serialize($data);
|
||||
if ($lifeTime > 0) {
|
||||
$response = $this->client->setex($id, $lifeTime, $data);
|
||||
} else {
|
||||
$response = $this->client->set($id, $data);
|
||||
}
|
||||
|
||||
return $response === true || $response == 'OK';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doDelete($id)
|
||||
{
|
||||
return $this->client->del($id) >= 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doDeleteMultiple(array $keys)
|
||||
{
|
||||
return $this->client->del($keys) >= 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFlush()
|
||||
{
|
||||
$response = $this->client->flushdb();
|
||||
|
||||
return $response === true || $response == 'OK';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doGetStats()
|
||||
{
|
||||
$info = $this->client->info();
|
||||
|
||||
return [
|
||||
Cache::STATS_HITS => $info['Stats']['keyspace_hits'],
|
||||
Cache::STATS_MISSES => $info['Stats']['keyspace_misses'],
|
||||
Cache::STATS_UPTIME => $info['Server']['uptime_in_seconds'],
|
||||
Cache::STATS_MEMORY_USAGE => $info['Memory']['used_memory'],
|
||||
Cache::STATS_MEMORY_AVAILABLE => false,
|
||||
];
|
||||
}
|
||||
}
|
181
vendor/doctrine/cache/lib/Doctrine/Common/Cache/RedisCache.php
vendored
Normal file
181
vendor/doctrine/cache/lib/Doctrine/Common/Cache/RedisCache.php
vendored
Normal file
@ -0,0 +1,181 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
use Redis;
|
||||
use function array_combine;
|
||||
use function array_diff_key;
|
||||
use function array_fill_keys;
|
||||
use function array_filter;
|
||||
use function array_keys;
|
||||
use function count;
|
||||
use function defined;
|
||||
use function extension_loaded;
|
||||
use function is_bool;
|
||||
|
||||
/**
|
||||
* Redis cache provider.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
*/
|
||||
class RedisCache extends CacheProvider
|
||||
{
|
||||
/** @var Redis|null */
|
||||
private $redis;
|
||||
|
||||
/**
|
||||
* Sets the redis instance to use.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setRedis(Redis $redis)
|
||||
{
|
||||
$redis->setOption(Redis::OPT_SERIALIZER, $this->getSerializerValue());
|
||||
$this->redis = $redis;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the redis instance used by the cache.
|
||||
*
|
||||
* @return Redis|null
|
||||
*/
|
||||
public function getRedis()
|
||||
{
|
||||
return $this->redis;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFetch($id)
|
||||
{
|
||||
return $this->redis->get($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFetchMultiple(array $keys)
|
||||
{
|
||||
$fetchedItems = array_combine($keys, $this->redis->mget($keys));
|
||||
|
||||
// Redis mget returns false for keys that do not exist. So we need to filter those out unless it's the real data.
|
||||
$keysToFilter = array_keys(array_filter($fetchedItems, static function ($item) : bool {
|
||||
return $item === false;
|
||||
}));
|
||||
|
||||
if ($keysToFilter) {
|
||||
$multi = $this->redis->multi(Redis::PIPELINE);
|
||||
foreach ($keysToFilter as $key) {
|
||||
$multi->exists($key);
|
||||
}
|
||||
$existItems = array_filter($multi->exec());
|
||||
$missedItemKeys = array_diff_key($keysToFilter, $existItems);
|
||||
$fetchedItems = array_diff_key($fetchedItems, array_fill_keys($missedItemKeys, true));
|
||||
}
|
||||
|
||||
return $fetchedItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doSaveMultiple(array $keysAndValues, $lifetime = 0)
|
||||
{
|
||||
if ($lifetime) {
|
||||
// Keys have lifetime, use SETEX for each of them
|
||||
$multi = $this->redis->multi(Redis::PIPELINE);
|
||||
foreach ($keysAndValues as $key => $value) {
|
||||
$multi->setex($key, $lifetime, $value);
|
||||
}
|
||||
$succeeded = array_filter($multi->exec());
|
||||
|
||||
return count($succeeded) == count($keysAndValues);
|
||||
}
|
||||
|
||||
// No lifetime, use MSET
|
||||
return (bool) $this->redis->mset($keysAndValues);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doContains($id)
|
||||
{
|
||||
$exists = $this->redis->exists($id);
|
||||
|
||||
if (is_bool($exists)) {
|
||||
return $exists;
|
||||
}
|
||||
|
||||
return $exists > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doSave($id, $data, $lifeTime = 0)
|
||||
{
|
||||
if ($lifeTime > 0) {
|
||||
return $this->redis->setex($id, $lifeTime, $data);
|
||||
}
|
||||
|
||||
return $this->redis->set($id, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doDelete($id)
|
||||
{
|
||||
return $this->redis->del($id) >= 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doDeleteMultiple(array $keys)
|
||||
{
|
||||
return $this->redis->del($keys) >= 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFlush()
|
||||
{
|
||||
return $this->redis->flushDB();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doGetStats()
|
||||
{
|
||||
$info = $this->redis->info();
|
||||
|
||||
return [
|
||||
Cache::STATS_HITS => $info['keyspace_hits'],
|
||||
Cache::STATS_MISSES => $info['keyspace_misses'],
|
||||
Cache::STATS_UPTIME => $info['uptime_in_seconds'],
|
||||
Cache::STATS_MEMORY_USAGE => $info['used_memory'],
|
||||
Cache::STATS_MEMORY_AVAILABLE => false,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the serializer constant to use. If Redis is compiled with
|
||||
* igbinary support, that is used. Otherwise the default PHP serializer is
|
||||
* used.
|
||||
*
|
||||
* @return int One of the Redis::SERIALIZER_* constants
|
||||
*/
|
||||
protected function getSerializerValue()
|
||||
{
|
||||
if (defined('Redis::SERIALIZER_IGBINARY') && extension_loaded('igbinary')) {
|
||||
return Redis::SERIALIZER_IGBINARY;
|
||||
}
|
||||
|
||||
return Redis::SERIALIZER_PHP;
|
||||
}
|
||||
}
|
206
vendor/doctrine/cache/lib/Doctrine/Common/Cache/SQLite3Cache.php
vendored
Normal file
206
vendor/doctrine/cache/lib/Doctrine/Common/Cache/SQLite3Cache.php
vendored
Normal file
@ -0,0 +1,206 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
use SQLite3;
|
||||
use SQLite3Result;
|
||||
use const SQLITE3_ASSOC;
|
||||
use const SQLITE3_BLOB;
|
||||
use const SQLITE3_TEXT;
|
||||
use function array_search;
|
||||
use function implode;
|
||||
use function serialize;
|
||||
use function sprintf;
|
||||
use function time;
|
||||
use function unserialize;
|
||||
|
||||
/**
|
||||
* SQLite3 cache provider.
|
||||
*/
|
||||
class SQLite3Cache extends CacheProvider
|
||||
{
|
||||
/**
|
||||
* The ID field will store the cache key.
|
||||
*/
|
||||
public const ID_FIELD = 'k';
|
||||
|
||||
/**
|
||||
* The data field will store the serialized PHP value.
|
||||
*/
|
||||
public const DATA_FIELD = 'd';
|
||||
|
||||
/**
|
||||
* The expiration field will store a date value indicating when the
|
||||
* cache entry should expire.
|
||||
*/
|
||||
public const EXPIRATION_FIELD = 'e';
|
||||
|
||||
/** @var SQLite3 */
|
||||
private $sqlite;
|
||||
|
||||
/** @var string */
|
||||
private $table;
|
||||
|
||||
/**
|
||||
* Calling the constructor will ensure that the database file and table
|
||||
* exist and will create both if they don't.
|
||||
*
|
||||
* @param string $table
|
||||
*/
|
||||
public function __construct(SQLite3 $sqlite, $table)
|
||||
{
|
||||
$this->sqlite = $sqlite;
|
||||
$this->table = (string) $table;
|
||||
|
||||
$this->ensureTableExists();
|
||||
}
|
||||
|
||||
private function ensureTableExists() : void
|
||||
{
|
||||
$this->sqlite->exec(
|
||||
sprintf(
|
||||
'CREATE TABLE IF NOT EXISTS %s(%s TEXT PRIMARY KEY NOT NULL, %s BLOB, %s INTEGER)',
|
||||
$this->table,
|
||||
static::ID_FIELD,
|
||||
static::DATA_FIELD,
|
||||
static::EXPIRATION_FIELD
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFetch($id)
|
||||
{
|
||||
$item = $this->findById($id);
|
||||
|
||||
if (! $item) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return unserialize($item[self::DATA_FIELD]);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doContains($id)
|
||||
{
|
||||
return $this->findById($id, false) !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doSave($id, $data, $lifeTime = 0)
|
||||
{
|
||||
$statement = $this->sqlite->prepare(sprintf(
|
||||
'INSERT OR REPLACE INTO %s (%s) VALUES (:id, :data, :expire)',
|
||||
$this->table,
|
||||
implode(',', $this->getFields())
|
||||
));
|
||||
|
||||
$statement->bindValue(':id', $id);
|
||||
$statement->bindValue(':data', serialize($data), SQLITE3_BLOB);
|
||||
$statement->bindValue(':expire', $lifeTime > 0 ? time() + $lifeTime : null);
|
||||
|
||||
return $statement->execute() instanceof SQLite3Result;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doDelete($id)
|
||||
{
|
||||
[$idField] = $this->getFields();
|
||||
|
||||
$statement = $this->sqlite->prepare(sprintf(
|
||||
'DELETE FROM %s WHERE %s = :id',
|
||||
$this->table,
|
||||
$idField
|
||||
));
|
||||
|
||||
$statement->bindValue(':id', $id);
|
||||
|
||||
return $statement->execute() instanceof SQLite3Result;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFlush()
|
||||
{
|
||||
return $this->sqlite->exec(sprintf('DELETE FROM %s', $this->table));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doGetStats()
|
||||
{
|
||||
// no-op.
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a single row by ID.
|
||||
*
|
||||
* @param mixed $id
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
private function findById($id, bool $includeData = true) : ?array
|
||||
{
|
||||
[$idField] = $fields = $this->getFields();
|
||||
|
||||
if (! $includeData) {
|
||||
$key = array_search(static::DATA_FIELD, $fields);
|
||||
unset($fields[$key]);
|
||||
}
|
||||
|
||||
$statement = $this->sqlite->prepare(sprintf(
|
||||
'SELECT %s FROM %s WHERE %s = :id LIMIT 1',
|
||||
implode(',', $fields),
|
||||
$this->table,
|
||||
$idField
|
||||
));
|
||||
|
||||
$statement->bindValue(':id', $id, SQLITE3_TEXT);
|
||||
|
||||
$item = $statement->execute()->fetchArray(SQLITE3_ASSOC);
|
||||
|
||||
if ($item === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($this->isExpired($item)) {
|
||||
$this->doDelete($id);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an array of the fields in our table.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getFields() : array
|
||||
{
|
||||
return [static::ID_FIELD, static::DATA_FIELD, static::EXPIRATION_FIELD];
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the item is expired.
|
||||
*
|
||||
* @param array $item
|
||||
*/
|
||||
private function isExpired(array $item) : bool
|
||||
{
|
||||
return isset($item[static::EXPIRATION_FIELD]) &&
|
||||
$item[self::EXPIRATION_FIELD] !== null &&
|
||||
$item[self::EXPIRATION_FIELD] < time();
|
||||
}
|
||||
}
|
8
vendor/doctrine/cache/lib/Doctrine/Common/Cache/Version.php
vendored
Normal file
8
vendor/doctrine/cache/lib/Doctrine/Common/Cache/Version.php
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
class Version
|
||||
{
|
||||
public const VERSION = '1.9.0-DEV';
|
||||
}
|
59
vendor/doctrine/cache/lib/Doctrine/Common/Cache/VoidCache.php
vendored
Normal file
59
vendor/doctrine/cache/lib/Doctrine/Common/Cache/VoidCache.php
vendored
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
/**
|
||||
* Void cache driver. The cache could be of use in tests where you don`t need to cache anything.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
*/
|
||||
class VoidCache extends CacheProvider
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function doFetch($id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function doContains($id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function doSave($id, $data, $lifeTime = 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function doDelete($id)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function doFlush()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function doGetStats()
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
106
vendor/doctrine/cache/lib/Doctrine/Common/Cache/WinCacheCache.php
vendored
Normal file
106
vendor/doctrine/cache/lib/Doctrine/Common/Cache/WinCacheCache.php
vendored
Normal file
@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
use function count;
|
||||
use function is_array;
|
||||
use function wincache_ucache_clear;
|
||||
use function wincache_ucache_delete;
|
||||
use function wincache_ucache_exists;
|
||||
use function wincache_ucache_get;
|
||||
use function wincache_ucache_info;
|
||||
use function wincache_ucache_meminfo;
|
||||
use function wincache_ucache_set;
|
||||
|
||||
/**
|
||||
* WinCache cache provider.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
*/
|
||||
class WinCacheCache extends CacheProvider
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFetch($id)
|
||||
{
|
||||
return wincache_ucache_get($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doContains($id)
|
||||
{
|
||||
return wincache_ucache_exists($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doSave($id, $data, $lifeTime = 0)
|
||||
{
|
||||
return wincache_ucache_set($id, $data, $lifeTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doDelete($id)
|
||||
{
|
||||
return wincache_ucache_delete($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFlush()
|
||||
{
|
||||
return wincache_ucache_clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFetchMultiple(array $keys)
|
||||
{
|
||||
return wincache_ucache_get($keys);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doSaveMultiple(array $keysAndValues, $lifetime = 0)
|
||||
{
|
||||
$result = wincache_ucache_set($keysAndValues, null, $lifetime);
|
||||
|
||||
return empty($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doDeleteMultiple(array $keys)
|
||||
{
|
||||
$result = wincache_ucache_delete($keys);
|
||||
|
||||
return is_array($result) && count($result) !== count($keys);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doGetStats()
|
||||
{
|
||||
$info = wincache_ucache_info();
|
||||
$meminfo = wincache_ucache_meminfo();
|
||||
|
||||
return [
|
||||
Cache::STATS_HITS => $info['total_hit_count'],
|
||||
Cache::STATS_MISSES => $info['total_miss_count'],
|
||||
Cache::STATS_UPTIME => $info['total_cache_uptime'],
|
||||
Cache::STATS_MEMORY_USAGE => $meminfo['memory_total'],
|
||||
Cache::STATS_MEMORY_AVAILABLE => $meminfo['memory_free'],
|
||||
];
|
||||
}
|
||||
}
|
104
vendor/doctrine/cache/lib/Doctrine/Common/Cache/XcacheCache.php
vendored
Normal file
104
vendor/doctrine/cache/lib/Doctrine/Common/Cache/XcacheCache.php
vendored
Normal file
@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
use BadMethodCallException;
|
||||
use const XC_TYPE_VAR;
|
||||
use function ini_get;
|
||||
use function serialize;
|
||||
use function unserialize;
|
||||
use function xcache_clear_cache;
|
||||
use function xcache_get;
|
||||
use function xcache_info;
|
||||
use function xcache_isset;
|
||||
use function xcache_set;
|
||||
use function xcache_unset;
|
||||
|
||||
/**
|
||||
* Xcache cache driver.
|
||||
*
|
||||
* @deprecated
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
*/
|
||||
class XcacheCache extends CacheProvider
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFetch($id)
|
||||
{
|
||||
return $this->doContains($id) ? unserialize(xcache_get($id)) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doContains($id)
|
||||
{
|
||||
return xcache_isset($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doSave($id, $data, $lifeTime = 0)
|
||||
{
|
||||
return xcache_set($id, serialize($data), (int) $lifeTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doDelete($id)
|
||||
{
|
||||
return xcache_unset($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFlush()
|
||||
{
|
||||
$this->checkAuthorization();
|
||||
|
||||
xcache_clear_cache(XC_TYPE_VAR);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that xcache.admin.enable_auth is Off.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws BadMethodCallException When xcache.admin.enable_auth is On.
|
||||
*/
|
||||
protected function checkAuthorization()
|
||||
{
|
||||
if (ini_get('xcache.admin.enable_auth')) {
|
||||
throw new BadMethodCallException(
|
||||
'To use all features of \Doctrine\Common\Cache\XcacheCache, '
|
||||
. 'you must set "xcache.admin.enable_auth" to "Off" in your php.ini.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doGetStats()
|
||||
{
|
||||
$this->checkAuthorization();
|
||||
|
||||
$info = xcache_info(XC_TYPE_VAR, 0);
|
||||
|
||||
return [
|
||||
Cache::STATS_HITS => $info['hits'],
|
||||
Cache::STATS_MISSES => $info['misses'],
|
||||
Cache::STATS_UPTIME => null,
|
||||
Cache::STATS_MEMORY_USAGE => $info['size'],
|
||||
Cache::STATS_MEMORY_AVAILABLE => $info['avail'],
|
||||
];
|
||||
}
|
||||
}
|
69
vendor/doctrine/cache/lib/Doctrine/Common/Cache/ZendDataCache.php
vendored
Normal file
69
vendor/doctrine/cache/lib/Doctrine/Common/Cache/ZendDataCache.php
vendored
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
use function zend_shm_cache_clear;
|
||||
use function zend_shm_cache_delete;
|
||||
use function zend_shm_cache_fetch;
|
||||
use function zend_shm_cache_store;
|
||||
|
||||
/**
|
||||
* Zend Data Cache cache driver.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
*/
|
||||
class ZendDataCache extends CacheProvider
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFetch($id)
|
||||
{
|
||||
return zend_shm_cache_fetch($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doContains($id)
|
||||
{
|
||||
return zend_shm_cache_fetch($id) !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doSave($id, $data, $lifeTime = 0)
|
||||
{
|
||||
return zend_shm_cache_store($id, $data, $lifeTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doDelete($id)
|
||||
{
|
||||
return zend_shm_cache_delete($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFlush()
|
||||
{
|
||||
$namespace = $this->getNamespace();
|
||||
if (empty($namespace)) {
|
||||
return zend_shm_cache_clear();
|
||||
}
|
||||
|
||||
return zend_shm_cache_clear($namespace);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doGetStats()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
17
vendor/doctrine/collections/.doctrine-project.json
vendored
Normal file
17
vendor/doctrine/collections/.doctrine-project.json
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"active": true,
|
||||
"name": "Collections",
|
||||
"slug": "collections",
|
||||
"docsSlug": "doctrine-collections",
|
||||
"versions": [
|
||||
{
|
||||
"name": "master",
|
||||
"branchName": "master",
|
||||
"slug": "latest",
|
||||
"aliases": [
|
||||
"current",
|
||||
"stable"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
54
vendor/doctrine/collections/CONTRIBUTING.md
vendored
Normal file
54
vendor/doctrine/collections/CONTRIBUTING.md
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
# Contribute to Doctrine
|
||||
|
||||
Thank you for contributing to Doctrine!
|
||||
|
||||
Before we can merge your Pull-Request here are some guidelines that you need to follow.
|
||||
These guidelines exist not to annoy you, but to keep the code base clean,
|
||||
unified and future proof.
|
||||
|
||||
## We only accept PRs to "master"
|
||||
|
||||
Our branching strategy is "everything to master first", even
|
||||
bugfixes and we then merge them into the stable branches. You should only
|
||||
open pull requests against the master branch. Otherwise we cannot accept the PR.
|
||||
|
||||
There is one exception to the rule, when we merged a bug into some stable branches
|
||||
we do occasionally accept pull requests that merge the same bug fix into earlier
|
||||
branches.
|
||||
|
||||
## Coding Standard
|
||||
|
||||
We use the [Doctrine Coding Standard](https://github.com/doctrine/coding-standard).
|
||||
|
||||
## Unit-Tests
|
||||
|
||||
Please try to add a test for your pull-request.
|
||||
|
||||
* If you want to contribute new functionality add unit- or functional tests
|
||||
depending on the scope of the feature.
|
||||
|
||||
You can run the unit-tests by calling ``vendor/bin/phpunit`` from the root of the project.
|
||||
It will run all the project tests.
|
||||
|
||||
In order to do that, you will need a fresh copy of doctrine/collections, and you
|
||||
will have to run a composer installation in the project:
|
||||
|
||||
```sh
|
||||
git clone git@github.com:doctrine/collections.git
|
||||
cd collections
|
||||
curl -sS https://getcomposer.org/installer | php --
|
||||
./composer.phar install
|
||||
```
|
||||
|
||||
## Travis
|
||||
|
||||
We automatically run your pull request through [Travis CI](https://www.travis-ci.org)
|
||||
against supported PHP versions. If you break the tests, we cannot merge your code,
|
||||
so please make sure that your code is working before opening up a Pull-Request.
|
||||
|
||||
## Getting merged
|
||||
|
||||
Please allow us time to review your pull requests. We will give our best to review
|
||||
everything as fast as possible, but cannot always live up to our own expectations.
|
||||
|
||||
Thank you very much again for your contribution!
|
19
vendor/doctrine/collections/LICENSE
vendored
Normal file
19
vendor/doctrine/collections/LICENSE
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
Copyright (c) 2006-2013 Doctrine Project
|
||||
|
||||
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.
|
93
vendor/doctrine/collections/README.md
vendored
Normal file
93
vendor/doctrine/collections/README.md
vendored
Normal file
@ -0,0 +1,93 @@
|
||||
# Doctrine Collections
|
||||
|
||||
[](https://travis-ci.org/doctrine/collections)
|
||||
[](https://scrutinizer-ci.com/g/doctrine/collections/?branch=master)
|
||||
[](https://scrutinizer-ci.com/g/doctrine/collections/?branch=master)
|
||||
|
||||
Collections Abstraction library
|
||||
|
||||
## Changelog
|
||||
|
||||
### v1.6.1
|
||||
|
||||
This release, combined with the release of [`doctrine/collections` `v1.6.1`](https://github.com/doctrine/collections/releases/tag/v1.6.1),
|
||||
fixes an issue where parsing annotations was not possible
|
||||
for classes within `doctrine/collections`.
|
||||
|
||||
Specifically, `v1.6.0` introduced Psalm-specific annotations
|
||||
such as (for example) `@template` and `@template-implements`,
|
||||
which were both incorrectly recognized as `@template`.
|
||||
|
||||
`@template` has therefore been removed, and instead we use
|
||||
the prefixed `@psalm-template`, which is no longer parsed
|
||||
by `doctrine/collections` `v1.6.1`
|
||||
|
||||
Total issues resolved: **1**
|
||||
|
||||
- [186: Use `@psalm-template` annotation to avoid clashes](https://github.com/doctrine/collections/pull/186) thanks to @muglug
|
||||
|
||||
### v1.6.0
|
||||
|
||||
This release bumps the minimum required PHP version to 7.1.3.
|
||||
|
||||
Following improvements were introduced:
|
||||
|
||||
* `ArrayCollection#filter()` now allows filtering by key, value or both.
|
||||
* When using the `ClosureExpressionVisitor` over objects with a defined
|
||||
accessor and property, the accessor is prioritised.
|
||||
* Updated testing tools and coding standards, autoloading, which also
|
||||
led to marginal performance improvements
|
||||
* Introduced generic type docblock declarations from [psalm](https://github.com/vimeo/psalm),
|
||||
which should allow users to declare `/** @var Collection<KeyType, ValueType> */`
|
||||
in their code, and leverage the type propagation deriving from that.
|
||||
|
||||
Total issues resolved: **16**
|
||||
|
||||
- [127: Use PSR-4](https://github.com/doctrine/collections/pull/127) thanks to @Nyholm
|
||||
- [129: Remove space in method declaration](https://github.com/doctrine/collections/pull/129) thanks to @bounoable
|
||||
- [130: Update build to add PHPCS and PHPStan](https://github.com/doctrine/collections/pull/130) thanks to @lcobucci
|
||||
- [131: ClosureExpressionVisitor > Don't duplicate the accessor when the field already starts with it](https://github.com/doctrine/collections/pull/131) thanks to @ruudk
|
||||
- [139: Apply Doctrine CS 2.1](https://github.com/doctrine/collections/pull/139) thanks to @Majkl578
|
||||
- [142: CS 4.0, version composer.lock, merge stages](https://github.com/doctrine/collections/pull/142) thanks to @Majkl578
|
||||
- [144: Update to PHPUnit 7](https://github.com/doctrine/collections/pull/144) thanks to @carusogabriel
|
||||
- [146: Update changelog for v1.4.0 and v1.5.0](https://github.com/doctrine/collections/pull/146) thanks to @GromNaN
|
||||
- [154: Update index.rst](https://github.com/doctrine/collections/pull/154) thanks to @chraiet
|
||||
- [158: Extract Selectable method into own documentation section](https://github.com/doctrine/collections/pull/158) thanks to @SenseException
|
||||
- [160: Update homepage](https://github.com/doctrine/collections/pull/160) thanks to @Majkl578
|
||||
- [165: Allow `ArrayCollection#filter()` to filter by key, value or both](https://github.com/doctrine/collections/issues/165) thanks to @0x13a
|
||||
- [167: Allow `ArrayCollection#filter()` to filter by key and also value](https://github.com/doctrine/collections/pull/167) thanks to @0x13a
|
||||
- [175: CI: Test against PHP 7.4snapshot instead of nightly (8.0)](https://github.com/doctrine/collections/pull/175) thanks to @Majkl578
|
||||
- [177: Generify collections using Psalm](https://github.com/doctrine/collections/pull/177) thanks to @nschoellhorn
|
||||
- [178: Updated doctrine/coding-standard to 6.0](https://github.com/doctrine/collections/pull/178) thanks to @patrickjahns
|
||||
|
||||
### v1.5.0
|
||||
|
||||
* [Require PHP 7.1+](https://github.com/doctrine/collections/pull/105)
|
||||
* [Drop HHVM support](https://github.com/doctrine/collections/pull/118)
|
||||
|
||||
### v1.4.0
|
||||
|
||||
* [Require PHP 5.6+](https://github.com/doctrine/collections/pull/105)
|
||||
* [Add `ArrayCollection::createFrom()`](https://github.com/doctrine/collections/pull/91)
|
||||
* [Support non-camel-case naming](https://github.com/doctrine/collections/pull/57)
|
||||
* [Comparison `START_WITH`, `END_WITH`](https://github.com/doctrine/collections/pull/78)
|
||||
* [Comparison `MEMBER_OF`](https://github.com/doctrine/collections/pull/66)
|
||||
* [Add Contributing guide](https://github.com/doctrine/collections/pull/103)
|
||||
|
||||
### v1.3.0
|
||||
|
||||
* [Explicit casting of first and max results in criteria API](https://github.com/doctrine/collections/pull/26)
|
||||
* [Keep keys when using `ArrayCollection#matching()` with sorting](https://github.com/doctrine/collections/pull/49)
|
||||
* [Made `AbstractLazyCollection#$initialized` protected for extensibility](https://github.com/doctrine/collections/pull/52)
|
||||
|
||||
### v1.2.0
|
||||
|
||||
* Add a new ``AbstractLazyCollection``
|
||||
|
||||
### v1.1.0
|
||||
|
||||
* Deprecated ``Comparison::IS``, because it's only there for SQL semantics.
|
||||
These are fixed in the ORM instead.
|
||||
* Add ``Comparison::CONTAINS`` to perform partial string matches:
|
||||
|
||||
$criteria->andWhere($criteria->expr()->contains('property', 'Foo'));
|
26
vendor/doctrine/collections/docs/en/derived-collections.rst
vendored
Normal file
26
vendor/doctrine/collections/docs/en/derived-collections.rst
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
Derived Collections
|
||||
===================
|
||||
|
||||
You can create custom collection classes by extending the
|
||||
``Doctrine\Common\Collections\ArrayCollection`` class. If the
|
||||
``__construct`` semantics are different from the default ``ArrayCollection``
|
||||
you can override the ``createFrom`` method:
|
||||
|
||||
.. code-block:: php
|
||||
final class DerivedArrayCollection extends ArrayCollection
|
||||
{
|
||||
/** @var \stdClass */
|
||||
private $foo;
|
||||
|
||||
public function __construct(\stdClass $foo, array $elements = [])
|
||||
{
|
||||
$this->foo = $foo;
|
||||
|
||||
parent::__construct($elements);
|
||||
}
|
||||
|
||||
protected function createFrom(array $elements) : self
|
||||
{
|
||||
return new static($this->foo, $elements);
|
||||
}
|
||||
}
|
173
vendor/doctrine/collections/docs/en/expression-builder.rst
vendored
Normal file
173
vendor/doctrine/collections/docs/en/expression-builder.rst
vendored
Normal file
@ -0,0 +1,173 @@
|
||||
Expression Builder
|
||||
==================
|
||||
|
||||
The Expression Builder is a convenient fluent interface for
|
||||
building expressions to be used with the ``Doctrine\Common\Collections\Criteria``
|
||||
class:
|
||||
|
||||
.. code-block:: php
|
||||
$expressionBuilder = Criteria::expr();
|
||||
|
||||
$criteria = new Criteria();
|
||||
$criteria->where($expressionBuilder->eq('name', 'jwage'));
|
||||
$criteria->orWhere($expressionBuilder->eq('name', 'romanb'));
|
||||
|
||||
$collection->matching($criteria);
|
||||
|
||||
The ``ExpressionBuilder`` has the following API:
|
||||
|
||||
andX
|
||||
----
|
||||
|
||||
.. code-block:: php
|
||||
$expressionBuilder = Criteria::expr();
|
||||
|
||||
$expression = $expressionBuilder->andX(
|
||||
$expressionBuilder->eq('foo', 1),
|
||||
$expressionBuilder->eq('bar', 1)
|
||||
);
|
||||
|
||||
$collection->matching(new Criteria($expression));
|
||||
|
||||
orX
|
||||
---
|
||||
|
||||
.. code-block:: php
|
||||
$expressionBuilder = Criteria::expr();
|
||||
|
||||
$expression = $expressionBuilder->orX(
|
||||
$expressionBuilder->eq('foo', 1),
|
||||
$expressionBuilder->eq('bar', 1)
|
||||
);
|
||||
|
||||
$collection->matching(new Criteria($expression));
|
||||
|
||||
eq
|
||||
---
|
||||
|
||||
.. code-block:: php
|
||||
$expressionBuilder = Criteria::expr();
|
||||
|
||||
$expression = $expressionBuilder->eq('foo', 1);
|
||||
|
||||
$collection->matching(new Criteria($expression));
|
||||
|
||||
gt
|
||||
---
|
||||
|
||||
.. code-block:: php
|
||||
$expressionBuilder = Criteria::expr();
|
||||
|
||||
$expression = $expressionBuilder->gt('foo', 1);
|
||||
|
||||
$collection->matching(new Criteria($expression));
|
||||
|
||||
lt
|
||||
---
|
||||
|
||||
.. code-block:: php
|
||||
$expressionBuilder = Criteria::expr();
|
||||
|
||||
$expression = $expressionBuilder->lt('foo', 1);
|
||||
|
||||
$collection->matching(new Criteria($expression));
|
||||
|
||||
gte
|
||||
---
|
||||
|
||||
.. code-block:: php
|
||||
$expressionBuilder = Criteria::expr();
|
||||
|
||||
$expression = $expressionBuilder->gte('foo', 1);
|
||||
|
||||
$collection->matching(new Criteria($expression));
|
||||
|
||||
lte
|
||||
---
|
||||
|
||||
.. code-block:: php
|
||||
$expressionBuilder = Criteria::expr();
|
||||
|
||||
$expression = $expressionBuilder->lte('foo', 1);
|
||||
|
||||
$collection->matching(new Criteria($expression));
|
||||
|
||||
neq
|
||||
---
|
||||
|
||||
.. code-block:: php
|
||||
$expressionBuilder = Criteria::expr();
|
||||
|
||||
$expression = $expressionBuilder->neq('foo', 1);
|
||||
|
||||
$collection->matching(new Criteria($expression));
|
||||
|
||||
isNull
|
||||
------
|
||||
|
||||
.. code-block:: php
|
||||
$expressionBuilder = Criteria::expr();
|
||||
|
||||
$expression = $expressionBuilder->isNull('foo');
|
||||
|
||||
$collection->matching(new Criteria($expression));
|
||||
|
||||
in
|
||||
---
|
||||
|
||||
.. code-block:: php
|
||||
$expressionBuilder = Criteria::expr();
|
||||
|
||||
$expression = $expressionBuilder->in('foo', ['value1', 'value2']);
|
||||
|
||||
$collection->matching(new Criteria($expression));
|
||||
|
||||
notIn
|
||||
-----
|
||||
|
||||
.. code-block:: php
|
||||
$expressionBuilder = Criteria::expr();
|
||||
|
||||
$expression = $expressionBuilder->notIn('foo', ['value1', 'value2']);
|
||||
|
||||
$collection->matching(new Criteria($expression));
|
||||
|
||||
contains
|
||||
--------
|
||||
|
||||
.. code-block:: php
|
||||
$expressionBuilder = Criteria::expr();
|
||||
|
||||
$expression = $expressionBuilder->contains('foo', 'value1');
|
||||
|
||||
$collection->matching(new Criteria($expression));
|
||||
|
||||
memberOf
|
||||
--------
|
||||
|
||||
.. code-block:: php
|
||||
$expressionBuilder = Criteria::expr();
|
||||
|
||||
$expression = $expressionBuilder->memberOf('foo', ['value1', 'value2']);
|
||||
|
||||
$collection->matching(new Criteria($expression));
|
||||
|
||||
startsWith
|
||||
----------
|
||||
|
||||
.. code-block:: php
|
||||
$expressionBuilder = Criteria::expr();
|
||||
|
||||
$expression = $expressionBuilder->startsWith('foo', 'hello');
|
||||
|
||||
$collection->matching(new Criteria($expression));
|
||||
|
||||
endsWith
|
||||
--------
|
||||
|
||||
.. code-block:: php
|
||||
$expressionBuilder = Criteria::expr();
|
||||
|
||||
$expression = $expressionBuilder->endsWith('foo', 'world');
|
||||
|
||||
$collection->matching(new Criteria($expression));
|
102
vendor/doctrine/collections/docs/en/expressions.rst
vendored
Normal file
102
vendor/doctrine/collections/docs/en/expressions.rst
vendored
Normal file
@ -0,0 +1,102 @@
|
||||
Expressions
|
||||
===========
|
||||
|
||||
The ``Doctrine\Common\Collections\Expr\Comparison`` class
|
||||
can be used to create expressions to be used with the
|
||||
``Doctrine\Common\Collections\Criteria`` class. It has the
|
||||
following operator constants:
|
||||
|
||||
- ``Comparison::EQ``
|
||||
- ``Comparison::NEQ``
|
||||
- ``Comparison::LT``
|
||||
- ``Comparison::LTE``
|
||||
- ``Comparison::GT``
|
||||
- ``Comparison::GTE``
|
||||
- ``Comparison::IS``
|
||||
- ``Comparison::IN``
|
||||
- ``Comparison::NIN``
|
||||
- ``Comparison::CONTAINS``
|
||||
- ``Comparison::MEMBER_OF``
|
||||
- ``Comparison::STARTS_WITH``
|
||||
- ``Comparison::ENDS_WITH``
|
||||
|
||||
The ``Doctrine\Common\Collections\Criteria`` class has the following
|
||||
API to be used with expressions:
|
||||
|
||||
where
|
||||
-----
|
||||
|
||||
Sets the where expression to evaluate when this Criteria is searched for.
|
||||
|
||||
.. code-block:: php
|
||||
$expr = new Comparison('key', Comparison::EQ, 'value');
|
||||
|
||||
$criteria->where($expr);
|
||||
|
||||
andWhere
|
||||
--------
|
||||
|
||||
Appends the where expression to evaluate when this Criteria is searched for
|
||||
using an AND with previous expression.
|
||||
|
||||
.. code-block:: php
|
||||
$expr = new Comparison('key', Comparison::EQ, 'value');
|
||||
|
||||
$criteria->andWhere($expr);
|
||||
|
||||
orWhere
|
||||
-------
|
||||
|
||||
Appends the where expression to evaluate when this Criteria is searched for
|
||||
using an OR with previous expression.
|
||||
|
||||
.. code-block:: php
|
||||
$expr1 = new Comparison('key', Comparison::EQ, 'value1');
|
||||
$expr2 = new Comparison('key', Comparison::EQ, 'value2');
|
||||
|
||||
$criteria->where($expr1);
|
||||
$criteria->orWhere($expr2);
|
||||
|
||||
orderBy
|
||||
-------
|
||||
|
||||
Sets the ordering of the result of this Criteria.
|
||||
|
||||
.. code-block:: php
|
||||
$criteria->orderBy(['name' => Criteria::ASC]);
|
||||
|
||||
setFirstResult
|
||||
--------------
|
||||
|
||||
Set the number of first result that this Criteria should return.
|
||||
|
||||
.. code-block:: php
|
||||
$criteria->setFirstResult(0);
|
||||
|
||||
getFirstResult
|
||||
--------------
|
||||
|
||||
Gets the current first result option of this Criteria.
|
||||
|
||||
.. code-block:: php
|
||||
$criteria->setFirstResult(10);
|
||||
|
||||
echo $criteria->getFirstResult(); // 10
|
||||
|
||||
setMaxResults
|
||||
-------------
|
||||
|
||||
Sets the max results that this Criteria should return.
|
||||
|
||||
.. code-block:: php
|
||||
$criteria->setMaxResults(20);
|
||||
|
||||
getMaxResults
|
||||
-------------
|
||||
|
||||
Gets the current max results option of this Criteria.
|
||||
|
||||
.. code-block:: php
|
||||
$criteria->setMaxResults(20);
|
||||
|
||||
echo $criteria->getMaxResults(); // 20
|
327
vendor/doctrine/collections/docs/en/index.rst
vendored
Normal file
327
vendor/doctrine/collections/docs/en/index.rst
vendored
Normal file
@ -0,0 +1,327 @@
|
||||
Introduction
|
||||
============
|
||||
|
||||
Doctrine Collections is a library that contains classes for working with
|
||||
arrays of data. Here is an example using the simple
|
||||
``Doctrine\Common\Collections\ArrayCollection`` class:
|
||||
|
||||
.. code-block:: php
|
||||
<?php
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
$collection = new ArrayCollection([1, 2, 3]);
|
||||
|
||||
$filteredCollection = $collection->filter(function($count) {
|
||||
return $count > 1;
|
||||
}); // [2, 3]
|
||||
|
||||
Collection Methods
|
||||
==================
|
||||
|
||||
Doctrine Collections provides an interface named ``Doctrine\Common\Collections\Collection``
|
||||
that resembles the nature of a regular PHP array. That is,
|
||||
it is essentially an **ordered map** that can also be used
|
||||
like a list.
|
||||
|
||||
A Collection has an internal iterator just like a PHP array. In addition,
|
||||
a Collection can be iterated with external iterators, which is preferable.
|
||||
To use an external iterator simply use the foreach language construct to
|
||||
iterate over the collection, which calls ``getIterator()`` internally, or
|
||||
explicitly retrieve an iterator though ``getIterator()`` which can then be
|
||||
used to iterate over the collection. You can not rely on the internal iterator
|
||||
of the collection being at a certain position unless you explicitly positioned it before.
|
||||
|
||||
The methods available on the interface are:
|
||||
|
||||
add
|
||||
---
|
||||
|
||||
Adds an element at the end of the collection.
|
||||
|
||||
.. code-block:: php
|
||||
$collection->add('test');
|
||||
|
||||
clear
|
||||
-----
|
||||
|
||||
Clears the collection, removing all elements.
|
||||
|
||||
.. code-block:: php
|
||||
$collection->clear();
|
||||
|
||||
contains
|
||||
--------
|
||||
|
||||
Checks whether an element is contained in the collection. This is an O(n) operation, where n is the size of the collection.
|
||||
|
||||
.. code-block:: php
|
||||
$collection = new Collection(['test']);
|
||||
|
||||
$contains = $collection->contains('test'); // true
|
||||
|
||||
containsKey
|
||||
-----------
|
||||
|
||||
Checks whether the collection contains an element with the specified key/index.
|
||||
|
||||
.. code-block:: php
|
||||
$collection = new Collection(['test' => true]);
|
||||
|
||||
$contains = $collection->containsKey('test'); // true
|
||||
|
||||
current
|
||||
-------
|
||||
|
||||
Gets the element of the collection at the current iterator position.
|
||||
|
||||
.. code-block:: php
|
||||
$collection = new Collection(['first', 'second', 'third']);
|
||||
|
||||
$current = $collection->current(); // first
|
||||
|
||||
get
|
||||
---
|
||||
|
||||
Gets the element at the specified key/index.
|
||||
|
||||
.. code-block:: php
|
||||
$collection = new Collection([
|
||||
'key' => 'value',
|
||||
]);
|
||||
|
||||
$value = $collection->get('key'); // value
|
||||
|
||||
getKeys
|
||||
-------
|
||||
|
||||
Gets all keys/indices of the collection.
|
||||
|
||||
.. code-block:: php
|
||||
$collection = new Collection(['a', 'b', 'c']);
|
||||
|
||||
$keys = $collection->getKeys(); // [0, 1, 2]
|
||||
|
||||
getValues
|
||||
---------
|
||||
|
||||
Gets all values of the collection.
|
||||
|
||||
.. code-block:: php
|
||||
$collection = new Collection([
|
||||
'key1' => 'value1',
|
||||
'key2' => 'value2',
|
||||
'key3' => 'value3',
|
||||
]);
|
||||
|
||||
$values = $collection->getValues(); // ['value1', 'value2', 'value3']
|
||||
|
||||
isEmpty
|
||||
-------
|
||||
|
||||
Checks whether the collection is empty (contains no elements).
|
||||
|
||||
.. code-block:: php
|
||||
$collection = new Collection(['a', 'b', 'c']);
|
||||
|
||||
$isEmpty = $collection->isEmpty(); // false
|
||||
|
||||
first
|
||||
-----
|
||||
|
||||
Sets the internal iterator to the first element in the collection and returns this element.
|
||||
|
||||
.. code-block:: php
|
||||
$collection = new Collection(['first', 'second', 'third']);
|
||||
|
||||
$first = $collection->first(); // first
|
||||
|
||||
exists
|
||||
------
|
||||
|
||||
Tests for the existence of an element that satisfies the given predicate.
|
||||
|
||||
.. code-block:: php
|
||||
$collection = new Collection(['first', 'second', 'third']);
|
||||
|
||||
$exists = $collection->exists(function($key, $value) {
|
||||
return $value === 'first';
|
||||
}); // true
|
||||
|
||||
filter
|
||||
------
|
||||
|
||||
Returns all the elements of this collection that satisfy the predicate. The order of the elements is preserved.
|
||||
|
||||
.. code-block:: php
|
||||
$collection = new ArrayCollection([1, 2, 3]);
|
||||
|
||||
$filteredCollection = $collection->filter(function($count) {
|
||||
return $count > 1;
|
||||
}); // [2, 3]
|
||||
|
||||
forAll
|
||||
------
|
||||
|
||||
Tests whether the given predicate holds for all elements of this collection.
|
||||
|
||||
.. code-block:: php
|
||||
$collection = new ArrayCollection([1, 2, 3]);
|
||||
|
||||
$forAll = $collection->forAll(function($key, $value) {
|
||||
return $value > 1;
|
||||
}); // false
|
||||
|
||||
indexOf
|
||||
-------
|
||||
|
||||
Gets the index/key of a given element. The comparison of two elements is strict, that means not only the value but also the type must match. For objects this means reference equality.
|
||||
|
||||
.. code-block:: php
|
||||
$collection = new ArrayCollection([1, 2, 3]);
|
||||
|
||||
$indexOf = $collection->indexOf(3); // 2
|
||||
|
||||
key
|
||||
---
|
||||
|
||||
Gets the key/index of the element at the current iterator position.
|
||||
|
||||
.. code-block:: php
|
||||
$collection = new ArrayCollection([1, 2, 3]);
|
||||
|
||||
$collection->next();
|
||||
|
||||
$key = $collection->key(); // 1
|
||||
|
||||
last
|
||||
----
|
||||
|
||||
Sets the internal iterator to the last element in the collection and returns this element.
|
||||
|
||||
.. code-block:: php
|
||||
$collection = new ArrayCollection([1, 2, 3]);
|
||||
|
||||
$last = $collection->last(); // 3
|
||||
|
||||
map
|
||||
---
|
||||
|
||||
Applies the given function to each element in the collection and returns a new collection with the elements returned by the function.
|
||||
|
||||
.. code-block:: php
|
||||
$collection = new ArrayCollection([1, 2, 3]);
|
||||
|
||||
$mappedCollection = $collection->map(function($value) {
|
||||
return $value + 1;
|
||||
}); // [2, 3, 4]
|
||||
|
||||
next
|
||||
----
|
||||
|
||||
Moves the internal iterator position to the next element and returns this element.
|
||||
|
||||
.. code-block:: php
|
||||
$collection = new ArrayCollection([1, 2, 3]);
|
||||
|
||||
$next = $collection->next(); // 2
|
||||
|
||||
partition
|
||||
---------
|
||||
|
||||
Partitions this collection in two collections according to a predicate. Keys are preserved in the resulting collections.
|
||||
|
||||
.. code-block:: php
|
||||
$collection = new ArrayCollection([1, 2, 3]);
|
||||
|
||||
$mappedCollection = $collection->partition(function($key, $value) {
|
||||
return $value > 1
|
||||
}); // [[2, 3], [1]]
|
||||
|
||||
remove
|
||||
------
|
||||
|
||||
Removes the element at the specified index from the collection.
|
||||
|
||||
.. code-block:: php
|
||||
$collection = new ArrayCollection([1, 2, 3]);
|
||||
|
||||
$collection->remove(0); // [2, 3]
|
||||
|
||||
removeElement
|
||||
-------------
|
||||
|
||||
Removes the specified element from the collection, if it is found.
|
||||
|
||||
.. code-block:: php
|
||||
$collection = new ArrayCollection([1, 2, 3]);
|
||||
|
||||
$collection->removeElement(3); // [1, 2]
|
||||
|
||||
set
|
||||
---
|
||||
|
||||
Sets an element in the collection at the specified key/index.
|
||||
|
||||
.. code-block:: php
|
||||
$collection = new ArrayCollection();
|
||||
|
||||
$collection->set('name', 'jwage');
|
||||
|
||||
slice
|
||||
-----
|
||||
|
||||
Extracts a slice of $length elements starting at position $offset from the Collection. If $length is null it returns all elements from $offset to the end of the Collection. Keys have to be preserved by this method. Calling this method will only return the selected slice and NOT change the elements contained in the collection slice is called on.
|
||||
|
||||
.. code-block:: php
|
||||
$collection = new ArrayCollection([0, 1, 2, 3, 4, 5]);
|
||||
|
||||
$slice = $collection->slice(1, 2); // [1, 2]
|
||||
|
||||
toArray
|
||||
-------
|
||||
|
||||
Gets a native PHP array representation of the collection.
|
||||
|
||||
.. code-block:: php
|
||||
$collection = new ArrayCollection([0, 1, 2, 3, 4, 5]);
|
||||
|
||||
$array = $collection->toArray(); // [0, 1, 2, 3, 4, 5]
|
||||
|
||||
Selectable Methods
|
||||
==================
|
||||
|
||||
Some Doctrine Collections, like ``Doctrine\Common\Collections\ArrayCollection``,
|
||||
implement an interface named ``Doctrine\Common\Collections\Selectable``
|
||||
that offers the usage of a powerful expressions API, where conditions
|
||||
can be applied to a collection to get a result with matching elements
|
||||
only.
|
||||
|
||||
matching
|
||||
--------
|
||||
|
||||
Selects all elements from a selectable that match the expression and
|
||||
returns a new collection containing these elements.
|
||||
|
||||
.. code-block:: php
|
||||
use Doctrine\Common\Collections\Criteria;
|
||||
use Doctrine\Common\Collections\Expr\Comparison;
|
||||
|
||||
$collection = new ArrayCollection([
|
||||
[
|
||||
'name' => 'jwage',
|
||||
],
|
||||
[
|
||||
'name' => 'romanb',
|
||||
],
|
||||
]);
|
||||
|
||||
$expr = new Comparison('name', '=', 'jwage');
|
||||
|
||||
$criteria = new Criteria();
|
||||
|
||||
$criteria->where($expr);
|
||||
|
||||
$matched = $collection->matching($criteria); // ['jwage']
|
||||
|
||||
You can read more about expressions :ref:`here <expressions>`.
|
26
vendor/doctrine/collections/docs/en/lazy-collections.rst
vendored
Normal file
26
vendor/doctrine/collections/docs/en/lazy-collections.rst
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
Lazy Collections
|
||||
================
|
||||
|
||||
To create a lazy collection you can extend the
|
||||
``Doctrine\Common\Collections\AbstractLazyCollection`` class
|
||||
and define the ``doInitialize`` method. Here is an example where
|
||||
we lazily query the database for a collection of user records:
|
||||
|
||||
.. code-block:: php
|
||||
use Doctrine\DBAL\Connection;
|
||||
|
||||
class UsersLazyCollection extends AbstractLazyCollection
|
||||
{
|
||||
/** @var Connection */
|
||||
private $connection;
|
||||
|
||||
public function __construct(Connection $connection)
|
||||
{
|
||||
$this->connection = $connection;
|
||||
}
|
||||
|
||||
protected function doInitialize() : void
|
||||
{
|
||||
$this->collection = $this->connection->fetchAll('SELECT * FROM users');
|
||||
}
|
||||
}
|
8
vendor/doctrine/collections/docs/en/sidebar.rst
vendored
Normal file
8
vendor/doctrine/collections/docs/en/sidebar.rst
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
.. toctree::
|
||||
:depth: 3
|
||||
|
||||
index
|
||||
expressions
|
||||
expression-builder
|
||||
derived-collections
|
||||
lazy-collections
|
354
vendor/doctrine/collections/lib/Doctrine/Common/Collections/AbstractLazyCollection.php
vendored
Normal file
354
vendor/doctrine/collections/lib/Doctrine/Common/Collections/AbstractLazyCollection.php
vendored
Normal file
@ -0,0 +1,354 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Collections;
|
||||
|
||||
use Closure;
|
||||
|
||||
/**
|
||||
* Lazy collection that is backed by a concrete collection
|
||||
*
|
||||
* @psalm-template TKey of array-key
|
||||
* @psalm-template T
|
||||
* @template-implements Collection<TKey,T>
|
||||
*/
|
||||
abstract class AbstractLazyCollection implements Collection
|
||||
{
|
||||
/**
|
||||
* The backed collection to use
|
||||
*
|
||||
* @psalm-var Collection<TKey,T>
|
||||
* @var Collection
|
||||
*/
|
||||
protected $collection;
|
||||
|
||||
/** @var bool */
|
||||
protected $initialized = false;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function add($element)
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->add($element);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
$this->initialize();
|
||||
$this->collection->clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function contains($element)
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->contains($element);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function isEmpty()
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function remove($key)
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->remove($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function removeElement($element)
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->removeElement($element);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function containsKey($key)
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->containsKey($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function get($key)
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->get($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getKeys()
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->getKeys();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getValues()
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->getValues();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function set($key, $value)
|
||||
{
|
||||
$this->initialize();
|
||||
$this->collection->set($key, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function first()
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function last()
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->last();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function key()
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->key();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function current()
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->current();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function next()
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->next();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function exists(Closure $p)
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->exists($p);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function filter(Closure $p)
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->filter($p);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function forAll(Closure $p)
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->forAll($p);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function map(Closure $func)
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->map($func);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function partition(Closure $p)
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->partition($p);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function indexOf($element)
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->indexOf($element);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function slice($offset, $length = null)
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->slice($offset, $length);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getIterator()
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->getIterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->offsetExists($offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->offsetGet($offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
$this->initialize();
|
||||
$this->collection->offsetSet($offset, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
$this->initialize();
|
||||
$this->collection->offsetUnset($offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the lazy collection already initialized?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isInitialized()
|
||||
{
|
||||
return $this->initialized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the collection
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function initialize()
|
||||
{
|
||||
if ($this->initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->doInitialize();
|
||||
$this->initialized = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do the initialization logic
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
abstract protected function doInitialize();
|
||||
}
|
429
vendor/doctrine/collections/lib/Doctrine/Common/Collections/ArrayCollection.php
vendored
Normal file
429
vendor/doctrine/collections/lib/Doctrine/Common/Collections/ArrayCollection.php
vendored
Normal file
@ -0,0 +1,429 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Collections;
|
||||
|
||||
use ArrayIterator;
|
||||
use Closure;
|
||||
use Doctrine\Common\Collections\Expr\ClosureExpressionVisitor;
|
||||
use const ARRAY_FILTER_USE_BOTH;
|
||||
use function array_filter;
|
||||
use function array_key_exists;
|
||||
use function array_keys;
|
||||
use function array_map;
|
||||
use function array_reverse;
|
||||
use function array_search;
|
||||
use function array_slice;
|
||||
use function array_values;
|
||||
use function count;
|
||||
use function current;
|
||||
use function end;
|
||||
use function in_array;
|
||||
use function key;
|
||||
use function next;
|
||||
use function reset;
|
||||
use function spl_object_hash;
|
||||
use function uasort;
|
||||
|
||||
/**
|
||||
* An ArrayCollection is a Collection implementation that wraps a regular PHP array.
|
||||
*
|
||||
* Warning: Using (un-)serialize() on a collection is not a supported use-case
|
||||
* and may break when we change the internals in the future. If you need to
|
||||
* serialize a collection use {@link toArray()} and reconstruct the collection
|
||||
* manually.
|
||||
*
|
||||
* @psalm-template TKey of array-key
|
||||
* @psalm-template T
|
||||
* @template-implements Collection<TKey,T>
|
||||
* @template-implements Selectable<TKey,T>
|
||||
*/
|
||||
class ArrayCollection implements Collection, Selectable
|
||||
{
|
||||
/**
|
||||
* An array containing the entries of this collection.
|
||||
*
|
||||
* @psalm-var array<TKey,T>
|
||||
* @var array
|
||||
*/
|
||||
private $elements;
|
||||
|
||||
/**
|
||||
* Initializes a new ArrayCollection.
|
||||
*
|
||||
* @param array $elements
|
||||
*
|
||||
* @psalm-param array<TKey,T> $elements
|
||||
*/
|
||||
public function __construct(array $elements = [])
|
||||
{
|
||||
$this->elements = $elements;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
return $this->elements;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function first()
|
||||
{
|
||||
return reset($this->elements);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance from the specified elements.
|
||||
*
|
||||
* This method is provided for derived classes to specify how a new
|
||||
* instance should be created when constructor semantics have changed.
|
||||
*
|
||||
* @param array $elements Elements.
|
||||
*
|
||||
* @return static
|
||||
*
|
||||
* @psalm-param array<TKey,T> $elements
|
||||
* @psalm-return static<TKey,T>
|
||||
*/
|
||||
protected function createFrom(array $elements)
|
||||
{
|
||||
return new static($elements);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function last()
|
||||
{
|
||||
return end($this->elements);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function key()
|
||||
{
|
||||
return key($this->elements);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function next()
|
||||
{
|
||||
return next($this->elements);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function current()
|
||||
{
|
||||
return current($this->elements);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function remove($key)
|
||||
{
|
||||
if (! isset($this->elements[$key]) && ! array_key_exists($key, $this->elements)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$removed = $this->elements[$key];
|
||||
unset($this->elements[$key]);
|
||||
|
||||
return $removed;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function removeElement($element)
|
||||
{
|
||||
$key = array_search($element, $this->elements, true);
|
||||
|
||||
if ($key === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
unset($this->elements[$key]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Required by interface ArrayAccess.
|
||||
*
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
return $this->containsKey($offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Required by interface ArrayAccess.
|
||||
*
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
return $this->get($offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Required by interface ArrayAccess.
|
||||
*
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
if (! isset($offset)) {
|
||||
$this->add($value);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->set($offset, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Required by interface ArrayAccess.
|
||||
*
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
$this->remove($offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function containsKey($key)
|
||||
{
|
||||
return isset($this->elements[$key]) || array_key_exists($key, $this->elements);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function contains($element)
|
||||
{
|
||||
return in_array($element, $this->elements, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function exists(Closure $p)
|
||||
{
|
||||
foreach ($this->elements as $key => $element) {
|
||||
if ($p($key, $element)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function indexOf($element)
|
||||
{
|
||||
return array_search($element, $this->elements, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function get($key)
|
||||
{
|
||||
return $this->elements[$key] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getKeys()
|
||||
{
|
||||
return array_keys($this->elements);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getValues()
|
||||
{
|
||||
return array_values($this->elements);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
return count($this->elements);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function set($key, $value)
|
||||
{
|
||||
$this->elements[$key] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function add($element)
|
||||
{
|
||||
$this->elements[] = $element;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function isEmpty()
|
||||
{
|
||||
return empty($this->elements);
|
||||
}
|
||||
|
||||
/**
|
||||
* Required by interface IteratorAggregate.
|
||||
*
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getIterator()
|
||||
{
|
||||
return new ArrayIterator($this->elements);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @return static
|
||||
*
|
||||
* @psalm-template U
|
||||
* @psalm-param Closure(T=):U $func
|
||||
* @psalm-return static<TKey, U>
|
||||
*/
|
||||
public function map(Closure $func)
|
||||
{
|
||||
return $this->createFrom(array_map($func, $this->elements));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @return static
|
||||
*
|
||||
* @psalm-return static<TKey,T>
|
||||
*/
|
||||
public function filter(Closure $p)
|
||||
{
|
||||
return $this->createFrom(array_filter($this->elements, $p, ARRAY_FILTER_USE_BOTH));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function forAll(Closure $p)
|
||||
{
|
||||
foreach ($this->elements as $key => $element) {
|
||||
if (! $p($key, $element)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function partition(Closure $p)
|
||||
{
|
||||
$matches = $noMatches = [];
|
||||
|
||||
foreach ($this->elements as $key => $element) {
|
||||
if ($p($key, $element)) {
|
||||
$matches[$key] = $element;
|
||||
} else {
|
||||
$noMatches[$key] = $element;
|
||||
}
|
||||
}
|
||||
|
||||
return [$this->createFrom($matches), $this->createFrom($noMatches)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this object.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return self::class . '@' . spl_object_hash($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
$this->elements = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function slice($offset, $length = null)
|
||||
{
|
||||
return array_slice($this->elements, $offset, $length, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function matching(Criteria $criteria)
|
||||
{
|
||||
$expr = $criteria->getWhereExpression();
|
||||
$filtered = $this->elements;
|
||||
|
||||
if ($expr) {
|
||||
$visitor = new ClosureExpressionVisitor();
|
||||
$filter = $visitor->dispatch($expr);
|
||||
$filtered = array_filter($filtered, $filter);
|
||||
}
|
||||
|
||||
$orderings = $criteria->getOrderings();
|
||||
|
||||
if ($orderings) {
|
||||
$next = null;
|
||||
foreach (array_reverse($orderings) as $field => $ordering) {
|
||||
$next = ClosureExpressionVisitor::sortByField($field, $ordering === Criteria::DESC ? -1 : 1, $next);
|
||||
}
|
||||
|
||||
uasort($filtered, $next);
|
||||
}
|
||||
|
||||
$offset = $criteria->getFirstResult();
|
||||
$length = $criteria->getMaxResults();
|
||||
|
||||
if ($offset || $length) {
|
||||
$filtered = array_slice($filtered, (int) $offset, $length);
|
||||
}
|
||||
|
||||
return $this->createFrom($filtered);
|
||||
}
|
||||
}
|
296
vendor/doctrine/collections/lib/Doctrine/Common/Collections/Collection.php
vendored
Normal file
296
vendor/doctrine/collections/lib/Doctrine/Common/Collections/Collection.php
vendored
Normal file
@ -0,0 +1,296 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Collections;
|
||||
|
||||
use ArrayAccess;
|
||||
use Closure;
|
||||
use Countable;
|
||||
use IteratorAggregate;
|
||||
|
||||
/**
|
||||
* The missing (SPL) Collection/Array/OrderedMap interface.
|
||||
*
|
||||
* A Collection resembles the nature of a regular PHP array. That is,
|
||||
* it is essentially an <b>ordered map</b> that can also be used
|
||||
* like a list.
|
||||
*
|
||||
* A Collection has an internal iterator just like a PHP array. In addition,
|
||||
* a Collection can be iterated with external iterators, which is preferable.
|
||||
* To use an external iterator simply use the foreach language construct to
|
||||
* iterate over the collection (which calls {@link getIterator()} internally) or
|
||||
* explicitly retrieve an iterator though {@link getIterator()} which can then be
|
||||
* used to iterate over the collection.
|
||||
* You can not rely on the internal iterator of the collection being at a certain
|
||||
* position unless you explicitly positioned it before. Prefer iteration with
|
||||
* external iterators.
|
||||
*
|
||||
* @psalm-template TKey of array-key
|
||||
* @psalm-template T
|
||||
* @template-extends IteratorAggregate<TKey, T>
|
||||
* @template-extends ArrayAccess<TKey|null, T>
|
||||
*/
|
||||
interface Collection extends Countable, IteratorAggregate, ArrayAccess
|
||||
{
|
||||
/**
|
||||
* Adds an element at the end of the collection.
|
||||
*
|
||||
* @param mixed $element The element to add.
|
||||
*
|
||||
* @return true Always TRUE.
|
||||
*
|
||||
* @psalm-param T $element
|
||||
*/
|
||||
public function add($element);
|
||||
|
||||
/**
|
||||
* Clears the collection, removing all elements.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function clear();
|
||||
|
||||
/**
|
||||
* Checks whether an element is contained in the collection.
|
||||
* This is an O(n) operation, where n is the size of the collection.
|
||||
*
|
||||
* @param mixed $element The element to search for.
|
||||
*
|
||||
* @return bool TRUE if the collection contains the element, FALSE otherwise.
|
||||
*
|
||||
* @psalm-param T $element
|
||||
*/
|
||||
public function contains($element);
|
||||
|
||||
/**
|
||||
* Checks whether the collection is empty (contains no elements).
|
||||
*
|
||||
* @return bool TRUE if the collection is empty, FALSE otherwise.
|
||||
*/
|
||||
public function isEmpty();
|
||||
|
||||
/**
|
||||
* Removes the element at the specified index from the collection.
|
||||
*
|
||||
* @param string|int $key The key/index of the element to remove.
|
||||
*
|
||||
* @return mixed The removed element or NULL, if the collection did not contain the element.
|
||||
*
|
||||
* @psalm-param TKey $key
|
||||
* @psalm-return T|null
|
||||
*/
|
||||
public function remove($key);
|
||||
|
||||
/**
|
||||
* Removes the specified element from the collection, if it is found.
|
||||
*
|
||||
* @param mixed $element The element to remove.
|
||||
*
|
||||
* @return bool TRUE if this collection contained the specified element, FALSE otherwise.
|
||||
*
|
||||
* @psalm-param T $element
|
||||
*/
|
||||
public function removeElement($element);
|
||||
|
||||
/**
|
||||
* Checks whether the collection contains an element with the specified key/index.
|
||||
*
|
||||
* @param string|int $key The key/index to check for.
|
||||
*
|
||||
* @return bool TRUE if the collection contains an element with the specified key/index,
|
||||
* FALSE otherwise.
|
||||
*
|
||||
* @psalm-param TKey $key
|
||||
*/
|
||||
public function containsKey($key);
|
||||
|
||||
/**
|
||||
* Gets the element at the specified key/index.
|
||||
*
|
||||
* @param string|int $key The key/index of the element to retrieve.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @psalm-param TKey $key
|
||||
* @psalm-return T|null
|
||||
*/
|
||||
public function get($key);
|
||||
|
||||
/**
|
||||
* Gets all keys/indices of the collection.
|
||||
*
|
||||
* @return int[]|string[] The keys/indices of the collection, in the order of the corresponding
|
||||
* elements in the collection.
|
||||
*
|
||||
* @psalm-return TKey[]
|
||||
*/
|
||||
public function getKeys();
|
||||
|
||||
/**
|
||||
* Gets all values of the collection.
|
||||
*
|
||||
* @return array The values of all elements in the collection, in the order they
|
||||
* appear in the collection.
|
||||
*
|
||||
* @psalm-return T[]
|
||||
*/
|
||||
public function getValues();
|
||||
|
||||
/**
|
||||
* Sets an element in the collection at the specified key/index.
|
||||
*
|
||||
* @param string|int $key The key/index of the element to set.
|
||||
* @param mixed $value The element to set.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @psalm-param TKey $key
|
||||
* @psalm-param T $value
|
||||
*/
|
||||
public function set($key, $value);
|
||||
|
||||
/**
|
||||
* Gets a native PHP array representation of the collection.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @psalm-return array<TKey,T>
|
||||
*/
|
||||
public function toArray();
|
||||
|
||||
/**
|
||||
* Sets the internal iterator to the first element in the collection and returns this element.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @psalm-return T|false
|
||||
*/
|
||||
public function first();
|
||||
|
||||
/**
|
||||
* Sets the internal iterator to the last element in the collection and returns this element.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @psalm-return T|false
|
||||
*/
|
||||
public function last();
|
||||
|
||||
/**
|
||||
* Gets the key/index of the element at the current iterator position.
|
||||
*
|
||||
* @return int|string
|
||||
*
|
||||
* @psalm-return TKey
|
||||
*/
|
||||
public function key();
|
||||
|
||||
/**
|
||||
* Gets the element of the collection at the current iterator position.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @psalm-return T|false
|
||||
*/
|
||||
public function current();
|
||||
|
||||
/**
|
||||
* Moves the internal iterator position to the next element and returns this element.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @psalm-return T|false
|
||||
*/
|
||||
public function next();
|
||||
|
||||
/**
|
||||
* Tests for the existence of an element that satisfies the given predicate.
|
||||
*
|
||||
* @param Closure $p The predicate.
|
||||
*
|
||||
* @return bool TRUE if the predicate is TRUE for at least one element, FALSE otherwise.
|
||||
*
|
||||
* @psalm-param Closure(TKey=, T=):bool $p
|
||||
*/
|
||||
public function exists(Closure $p);
|
||||
|
||||
/**
|
||||
* Returns all the elements of this collection that satisfy the predicate p.
|
||||
* The order of the elements is preserved.
|
||||
*
|
||||
* @param Closure $p The predicate used for filtering.
|
||||
*
|
||||
* @return Collection A collection with the results of the filter operation.
|
||||
*
|
||||
* @psalm-param Closure(T=):bool $p
|
||||
* @psalm-return Collection<TKey, T>
|
||||
*/
|
||||
public function filter(Closure $p);
|
||||
|
||||
/**
|
||||
* Tests whether the given predicate p holds for all elements of this collection.
|
||||
*
|
||||
* @param Closure $p The predicate.
|
||||
*
|
||||
* @return bool TRUE, if the predicate yields TRUE for all elements, FALSE otherwise.
|
||||
*
|
||||
* @psalm-param Closure(TKey=, T=):bool $p
|
||||
*/
|
||||
public function forAll(Closure $p);
|
||||
|
||||
/**
|
||||
* Applies the given function to each element in the collection and returns
|
||||
* a new collection with the elements returned by the function.
|
||||
*
|
||||
* @return Collection
|
||||
*
|
||||
* @psalm-template U
|
||||
* @psalm-param Closure(T=):U $func
|
||||
* @psalm-return Collection<TKey, U>
|
||||
*/
|
||||
public function map(Closure $func);
|
||||
|
||||
/**
|
||||
* Partitions this collection in two collections according to a predicate.
|
||||
* Keys are preserved in the resulting collections.
|
||||
*
|
||||
* @param Closure $p The predicate on which to partition.
|
||||
*
|
||||
* @return Collection[] An array with two elements. The first element contains the collection
|
||||
* of elements where the predicate returned TRUE, the second element
|
||||
* contains the collection of elements where the predicate returned FALSE.
|
||||
*
|
||||
* @psalm-param Closure(TKey=, T=):bool $p
|
||||
* @psalm-return array{0: Collection<TKey, T>, 1: Collection<TKey, T>}
|
||||
*/
|
||||
public function partition(Closure $p);
|
||||
|
||||
/**
|
||||
* Gets the index/key of a given element. The comparison of two elements is strict,
|
||||
* that means not only the value but also the type must match.
|
||||
* For objects this means reference equality.
|
||||
*
|
||||
* @param mixed $element The element to search for.
|
||||
*
|
||||
* @return int|string|bool The key/index of the element or FALSE if the element was not found.
|
||||
*
|
||||
* @psalm-param T $element
|
||||
* @psalm-return TKey|false
|
||||
*/
|
||||
public function indexOf($element);
|
||||
|
||||
/**
|
||||
* Extracts a slice of $length elements starting at position $offset from the Collection.
|
||||
*
|
||||
* If $length is null it returns all elements from $offset to the end of the Collection.
|
||||
* Keys have to be preserved by this method. Calling this method will only return the
|
||||
* selected slice and NOT change the elements contained in the collection slice is called on.
|
||||
*
|
||||
* @param int $offset The offset to start from.
|
||||
* @param int|null $length The maximum number of elements to return, or null for no limit.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @psalm-return array<TKey,T>
|
||||
*/
|
||||
public function slice($offset, $length = null);
|
||||
}
|
222
vendor/doctrine/collections/lib/Doctrine/Common/Collections/Criteria.php
vendored
Normal file
222
vendor/doctrine/collections/lib/Doctrine/Common/Collections/Criteria.php
vendored
Normal file
@ -0,0 +1,222 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Collections;
|
||||
|
||||
use Doctrine\Common\Collections\Expr\CompositeExpression;
|
||||
use Doctrine\Common\Collections\Expr\Expression;
|
||||
use function array_map;
|
||||
use function strtoupper;
|
||||
|
||||
/**
|
||||
* Criteria for filtering Selectable collections.
|
||||
*/
|
||||
class Criteria
|
||||
{
|
||||
public const ASC = 'ASC';
|
||||
|
||||
public const DESC = 'DESC';
|
||||
|
||||
/** @var ExpressionBuilder|null */
|
||||
private static $expressionBuilder;
|
||||
|
||||
/** @var Expression|null */
|
||||
private $expression;
|
||||
|
||||
/** @var string[] */
|
||||
private $orderings = [];
|
||||
|
||||
/** @var int|null */
|
||||
private $firstResult;
|
||||
|
||||
/** @var int|null */
|
||||
private $maxResults;
|
||||
|
||||
/**
|
||||
* Creates an instance of the class.
|
||||
*
|
||||
* @return Criteria
|
||||
*/
|
||||
public static function create()
|
||||
{
|
||||
return new static();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the expression builder.
|
||||
*
|
||||
* @return ExpressionBuilder
|
||||
*/
|
||||
public static function expr()
|
||||
{
|
||||
if (self::$expressionBuilder === null) {
|
||||
self::$expressionBuilder = new ExpressionBuilder();
|
||||
}
|
||||
|
||||
return self::$expressionBuilder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new Criteria.
|
||||
*
|
||||
* @param string[]|null $orderings
|
||||
* @param int|null $firstResult
|
||||
* @param int|null $maxResults
|
||||
*/
|
||||
public function __construct(?Expression $expression = null, ?array $orderings = null, $firstResult = null, $maxResults = null)
|
||||
{
|
||||
$this->expression = $expression;
|
||||
|
||||
$this->setFirstResult($firstResult);
|
||||
$this->setMaxResults($maxResults);
|
||||
|
||||
if ($orderings === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->orderBy($orderings);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the where expression to evaluate when this Criteria is searched for.
|
||||
*
|
||||
* @return Criteria
|
||||
*/
|
||||
public function where(Expression $expression)
|
||||
{
|
||||
$this->expression = $expression;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends the where expression to evaluate when this Criteria is searched for
|
||||
* using an AND with previous expression.
|
||||
*
|
||||
* @return Criteria
|
||||
*/
|
||||
public function andWhere(Expression $expression)
|
||||
{
|
||||
if ($this->expression === null) {
|
||||
return $this->where($expression);
|
||||
}
|
||||
|
||||
$this->expression = new CompositeExpression(
|
||||
CompositeExpression::TYPE_AND,
|
||||
[$this->expression, $expression]
|
||||
);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends the where expression to evaluate when this Criteria is searched for
|
||||
* using an OR with previous expression.
|
||||
*
|
||||
* @return Criteria
|
||||
*/
|
||||
public function orWhere(Expression $expression)
|
||||
{
|
||||
if ($this->expression === null) {
|
||||
return $this->where($expression);
|
||||
}
|
||||
|
||||
$this->expression = new CompositeExpression(
|
||||
CompositeExpression::TYPE_OR,
|
||||
[$this->expression, $expression]
|
||||
);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the expression attached to this Criteria.
|
||||
*
|
||||
* @return Expression|null
|
||||
*/
|
||||
public function getWhereExpression()
|
||||
{
|
||||
return $this->expression;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current orderings of this Criteria.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getOrderings()
|
||||
{
|
||||
return $this->orderings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the ordering of the result of this Criteria.
|
||||
*
|
||||
* Keys are field and values are the order, being either ASC or DESC.
|
||||
*
|
||||
* @see Criteria::ASC
|
||||
* @see Criteria::DESC
|
||||
*
|
||||
* @param string[] $orderings
|
||||
*
|
||||
* @return Criteria
|
||||
*/
|
||||
public function orderBy(array $orderings)
|
||||
{
|
||||
$this->orderings = array_map(
|
||||
static function (string $ordering) : string {
|
||||
return strtoupper($ordering) === Criteria::ASC ? Criteria::ASC : Criteria::DESC;
|
||||
},
|
||||
$orderings
|
||||
);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current first result option of this Criteria.
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function getFirstResult()
|
||||
{
|
||||
return $this->firstResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the number of first result that this Criteria should return.
|
||||
*
|
||||
* @param int|null $firstResult The value to set.
|
||||
*
|
||||
* @return Criteria
|
||||
*/
|
||||
public function setFirstResult($firstResult)
|
||||
{
|
||||
$this->firstResult = $firstResult === null ? null : (int) $firstResult;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets maxResults.
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function getMaxResults()
|
||||
{
|
||||
return $this->maxResults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets maxResults.
|
||||
*
|
||||
* @param int|null $maxResults The value to set.
|
||||
*
|
||||
* @return Criteria
|
||||
*/
|
||||
public function setMaxResults($maxResults)
|
||||
{
|
||||
$this->maxResults = $maxResults === null ? null : (int) $maxResults;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
257
vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/ClosureExpressionVisitor.php
vendored
Normal file
257
vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/ClosureExpressionVisitor.php
vendored
Normal file
@ -0,0 +1,257 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Collections\Expr;
|
||||
|
||||
use ArrayAccess;
|
||||
use Closure;
|
||||
use RuntimeException;
|
||||
use function in_array;
|
||||
use function is_array;
|
||||
use function iterator_to_array;
|
||||
use function method_exists;
|
||||
use function preg_match;
|
||||
use function preg_replace_callback;
|
||||
use function strlen;
|
||||
use function strpos;
|
||||
use function strtoupper;
|
||||
use function substr;
|
||||
|
||||
/**
|
||||
* Walks an expression graph and turns it into a PHP closure.
|
||||
*
|
||||
* This closure can be used with {@Collection#filter()} and is used internally
|
||||
* by {@ArrayCollection#select()}.
|
||||
*/
|
||||
class ClosureExpressionVisitor extends ExpressionVisitor
|
||||
{
|
||||
/**
|
||||
* Accesses the field of a given object. This field has to be public
|
||||
* directly or indirectly (through an accessor get*, is*, or a magic
|
||||
* method, __get, __call).
|
||||
*
|
||||
* @param object|array $object
|
||||
* @param string $field
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function getObjectFieldValue($object, $field)
|
||||
{
|
||||
if (is_array($object)) {
|
||||
return $object[$field];
|
||||
}
|
||||
|
||||
$accessors = ['get', 'is'];
|
||||
|
||||
foreach ($accessors as $accessor) {
|
||||
$accessor .= $field;
|
||||
|
||||
if (method_exists($object, $accessor)) {
|
||||
return $object->$accessor();
|
||||
}
|
||||
}
|
||||
|
||||
if (preg_match('/^is[A-Z]+/', $field) === 1 && method_exists($object, $field)) {
|
||||
return $object->$field();
|
||||
}
|
||||
|
||||
// __call should be triggered for get.
|
||||
$accessor = $accessors[0] . $field;
|
||||
|
||||
if (method_exists($object, '__call')) {
|
||||
return $object->$accessor();
|
||||
}
|
||||
|
||||
if ($object instanceof ArrayAccess) {
|
||||
return $object[$field];
|
||||
}
|
||||
|
||||
if (isset($object->$field)) {
|
||||
return $object->$field;
|
||||
}
|
||||
|
||||
// camelcase field name to support different variable naming conventions
|
||||
$ccField = preg_replace_callback('/_(.?)/', static function ($matches) {
|
||||
return strtoupper($matches[1]);
|
||||
}, $field);
|
||||
|
||||
foreach ($accessors as $accessor) {
|
||||
$accessor .= $ccField;
|
||||
|
||||
if (method_exists($object, $accessor)) {
|
||||
return $object->$accessor();
|
||||
}
|
||||
}
|
||||
|
||||
return $object->$field;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper for sorting arrays of objects based on multiple fields + orientations.
|
||||
*
|
||||
* @param string $name
|
||||
* @param int $orientation
|
||||
*
|
||||
* @return Closure
|
||||
*/
|
||||
public static function sortByField($name, $orientation = 1, ?Closure $next = null)
|
||||
{
|
||||
if (! $next) {
|
||||
$next = static function () : int {
|
||||
return 0;
|
||||
};
|
||||
}
|
||||
|
||||
return static function ($a, $b) use ($name, $next, $orientation) : int {
|
||||
$aValue = ClosureExpressionVisitor::getObjectFieldValue($a, $name);
|
||||
|
||||
$bValue = ClosureExpressionVisitor::getObjectFieldValue($b, $name);
|
||||
|
||||
if ($aValue === $bValue) {
|
||||
return $next($a, $b);
|
||||
}
|
||||
|
||||
return ($aValue > $bValue ? 1 : -1) * $orientation;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function walkComparison(Comparison $comparison)
|
||||
{
|
||||
$field = $comparison->getField();
|
||||
$value = $comparison->getValue()->getValue(); // shortcut for walkValue()
|
||||
|
||||
switch ($comparison->getOperator()) {
|
||||
case Comparison::EQ:
|
||||
return static function ($object) use ($field, $value) : bool {
|
||||
return ClosureExpressionVisitor::getObjectFieldValue($object, $field) === $value;
|
||||
};
|
||||
|
||||
case Comparison::NEQ:
|
||||
return static function ($object) use ($field, $value) : bool {
|
||||
return ClosureExpressionVisitor::getObjectFieldValue($object, $field) !== $value;
|
||||
};
|
||||
|
||||
case Comparison::LT:
|
||||
return static function ($object) use ($field, $value) : bool {
|
||||
return ClosureExpressionVisitor::getObjectFieldValue($object, $field) < $value;
|
||||
};
|
||||
|
||||
case Comparison::LTE:
|
||||
return static function ($object) use ($field, $value) : bool {
|
||||
return ClosureExpressionVisitor::getObjectFieldValue($object, $field) <= $value;
|
||||
};
|
||||
|
||||
case Comparison::GT:
|
||||
return static function ($object) use ($field, $value) : bool {
|
||||
return ClosureExpressionVisitor::getObjectFieldValue($object, $field) > $value;
|
||||
};
|
||||
|
||||
case Comparison::GTE:
|
||||
return static function ($object) use ($field, $value) : bool {
|
||||
return ClosureExpressionVisitor::getObjectFieldValue($object, $field) >= $value;
|
||||
};
|
||||
|
||||
case Comparison::IN:
|
||||
return static function ($object) use ($field, $value) : bool {
|
||||
return in_array(ClosureExpressionVisitor::getObjectFieldValue($object, $field), $value, true);
|
||||
};
|
||||
|
||||
case Comparison::NIN:
|
||||
return static function ($object) use ($field, $value) : bool {
|
||||
return ! in_array(ClosureExpressionVisitor::getObjectFieldValue($object, $field), $value, true);
|
||||
};
|
||||
|
||||
case Comparison::CONTAINS:
|
||||
return static function ($object) use ($field, $value) {
|
||||
return strpos(ClosureExpressionVisitor::getObjectFieldValue($object, $field), $value) !== false;
|
||||
};
|
||||
|
||||
case Comparison::MEMBER_OF:
|
||||
return static function ($object) use ($field, $value) : bool {
|
||||
$fieldValues = ClosureExpressionVisitor::getObjectFieldValue($object, $field);
|
||||
|
||||
if (! is_array($fieldValues)) {
|
||||
$fieldValues = iterator_to_array($fieldValues);
|
||||
}
|
||||
|
||||
return in_array($value, $fieldValues, true);
|
||||
};
|
||||
|
||||
case Comparison::STARTS_WITH:
|
||||
return static function ($object) use ($field, $value) : bool {
|
||||
return strpos(ClosureExpressionVisitor::getObjectFieldValue($object, $field), $value) === 0;
|
||||
};
|
||||
|
||||
case Comparison::ENDS_WITH:
|
||||
return static function ($object) use ($field, $value) : bool {
|
||||
return $value === substr(ClosureExpressionVisitor::getObjectFieldValue($object, $field), -strlen($value));
|
||||
};
|
||||
|
||||
default:
|
||||
throw new RuntimeException('Unknown comparison operator: ' . $comparison->getOperator());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function walkValue(Value $value)
|
||||
{
|
||||
return $value->getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function walkCompositeExpression(CompositeExpression $expr)
|
||||
{
|
||||
$expressionList = [];
|
||||
|
||||
foreach ($expr->getExpressionList() as $child) {
|
||||
$expressionList[] = $this->dispatch($child);
|
||||
}
|
||||
|
||||
switch ($expr->getType()) {
|
||||
case CompositeExpression::TYPE_AND:
|
||||
return $this->andExpressions($expressionList);
|
||||
case CompositeExpression::TYPE_OR:
|
||||
return $this->orExpressions($expressionList);
|
||||
default:
|
||||
throw new RuntimeException('Unknown composite ' . $expr->getType());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $expressions
|
||||
*/
|
||||
private function andExpressions(array $expressions) : callable
|
||||
{
|
||||
return static function ($object) use ($expressions) : bool {
|
||||
foreach ($expressions as $expression) {
|
||||
if (! $expression($object)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $expressions
|
||||
*/
|
||||
private function orExpressions(array $expressions) : callable
|
||||
{
|
||||
return static function ($object) use ($expressions) : bool {
|
||||
foreach ($expressions as $expression) {
|
||||
if ($expression($object)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
}
|
||||
}
|
80
vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/Comparison.php
vendored
Normal file
80
vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/Comparison.php
vendored
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Collections\Expr;
|
||||
|
||||
/**
|
||||
* Comparison of a field with a value by the given operator.
|
||||
*/
|
||||
class Comparison implements Expression
|
||||
{
|
||||
public const EQ = '=';
|
||||
public const NEQ = '<>';
|
||||
public const LT = '<';
|
||||
public const LTE = '<=';
|
||||
public const GT = '>';
|
||||
public const GTE = '>=';
|
||||
public const IS = '='; // no difference with EQ
|
||||
public const IN = 'IN';
|
||||
public const NIN = 'NIN';
|
||||
public const CONTAINS = 'CONTAINS';
|
||||
public const MEMBER_OF = 'MEMBER_OF';
|
||||
public const STARTS_WITH = 'STARTS_WITH';
|
||||
public const ENDS_WITH = 'ENDS_WITH';
|
||||
|
||||
/** @var string */
|
||||
private $field;
|
||||
|
||||
/** @var string */
|
||||
private $op;
|
||||
|
||||
/** @var Value */
|
||||
private $value;
|
||||
|
||||
/**
|
||||
* @param string $field
|
||||
* @param string $operator
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function __construct($field, $operator, $value)
|
||||
{
|
||||
if (! ($value instanceof Value)) {
|
||||
$value = new Value($value);
|
||||
}
|
||||
|
||||
$this->field = $field;
|
||||
$this->op = $operator;
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getField()
|
||||
{
|
||||
return $this->field;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Value
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getOperator()
|
||||
{
|
||||
return $this->op;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function visit(ExpressionVisitor $visitor)
|
||||
{
|
||||
return $visitor->walkComparison($this);
|
||||
}
|
||||
}
|
68
vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/CompositeExpression.php
vendored
Normal file
68
vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/CompositeExpression.php
vendored
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Collections\Expr;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* Expression of Expressions combined by AND or OR operation.
|
||||
*/
|
||||
class CompositeExpression implements Expression
|
||||
{
|
||||
public const TYPE_AND = 'AND';
|
||||
public const TYPE_OR = 'OR';
|
||||
|
||||
/** @var string */
|
||||
private $type;
|
||||
|
||||
/** @var Expression[] */
|
||||
private $expressions = [];
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
* @param array $expressions
|
||||
*
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function __construct($type, array $expressions)
|
||||
{
|
||||
$this->type = $type;
|
||||
|
||||
foreach ($expressions as $expr) {
|
||||
if ($expr instanceof Value) {
|
||||
throw new RuntimeException('Values are not supported expressions as children of and/or expressions.');
|
||||
}
|
||||
if (! ($expr instanceof Expression)) {
|
||||
throw new RuntimeException('No expression given to CompositeExpression.');
|
||||
}
|
||||
|
||||
$this->expressions[] = $expr;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of expressions nested in this composite.
|
||||
*
|
||||
* @return Expression[]
|
||||
*/
|
||||
public function getExpressionList()
|
||||
{
|
||||
return $this->expressions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function visit(ExpressionVisitor $visitor)
|
||||
{
|
||||
return $visitor->walkCompositeExpression($this);
|
||||
}
|
||||
}
|
14
vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/Expression.php
vendored
Normal file
14
vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/Expression.php
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Collections\Expr;
|
||||
|
||||
/**
|
||||
* Expression for the {@link Selectable} interface.
|
||||
*/
|
||||
interface Expression
|
||||
{
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function visit(ExpressionVisitor $visitor);
|
||||
}
|
55
vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/ExpressionVisitor.php
vendored
Normal file
55
vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/ExpressionVisitor.php
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Collections\Expr;
|
||||
|
||||
use RuntimeException;
|
||||
use function get_class;
|
||||
|
||||
/**
|
||||
* An Expression visitor walks a graph of expressions and turns them into a
|
||||
* query for the underlying implementation.
|
||||
*/
|
||||
abstract class ExpressionVisitor
|
||||
{
|
||||
/**
|
||||
* Converts a comparison expression into the target query language output.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
abstract public function walkComparison(Comparison $comparison);
|
||||
|
||||
/**
|
||||
* Converts a value expression into the target query language part.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
abstract public function walkValue(Value $value);
|
||||
|
||||
/**
|
||||
* Converts a composite expression into the target query language output.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
abstract public function walkCompositeExpression(CompositeExpression $expr);
|
||||
|
||||
/**
|
||||
* Dispatches walking an expression to the appropriate handler.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function dispatch(Expression $expr)
|
||||
{
|
||||
switch (true) {
|
||||
case $expr instanceof Comparison:
|
||||
return $this->walkComparison($expr);
|
||||
case $expr instanceof Value:
|
||||
return $this->walkValue($expr);
|
||||
case $expr instanceof CompositeExpression:
|
||||
return $this->walkCompositeExpression($expr);
|
||||
default:
|
||||
throw new RuntimeException('Unknown Expression ' . get_class($expr));
|
||||
}
|
||||
}
|
||||
}
|
33
vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/Value.php
vendored
Normal file
33
vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/Value.php
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Collections\Expr;
|
||||
|
||||
class Value implements Expression
|
||||
{
|
||||
/** @var mixed */
|
||||
private $value;
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function __construct($value)
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function visit(ExpressionVisitor $visitor)
|
||||
{
|
||||
return $visitor->walkValue($this);
|
||||
}
|
||||
}
|
180
vendor/doctrine/collections/lib/Doctrine/Common/Collections/ExpressionBuilder.php
vendored
Normal file
180
vendor/doctrine/collections/lib/Doctrine/Common/Collections/ExpressionBuilder.php
vendored
Normal file
@ -0,0 +1,180 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Collections;
|
||||
|
||||
use Doctrine\Common\Collections\Expr\Comparison;
|
||||
use Doctrine\Common\Collections\Expr\CompositeExpression;
|
||||
use Doctrine\Common\Collections\Expr\Value;
|
||||
use function func_get_args;
|
||||
|
||||
/**
|
||||
* Builder for Expressions in the {@link Selectable} interface.
|
||||
*
|
||||
* Important Notice for interoperable code: You have to use scalar
|
||||
* values only for comparisons, otherwise the behavior of the comparison
|
||||
* may be different between implementations (Array vs ORM vs ODM).
|
||||
*/
|
||||
class ExpressionBuilder
|
||||
{
|
||||
/**
|
||||
* @param mixed ...$x
|
||||
*
|
||||
* @return CompositeExpression
|
||||
*/
|
||||
public function andX($x = null)
|
||||
{
|
||||
return new CompositeExpression(CompositeExpression::TYPE_AND, func_get_args());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed ...$x
|
||||
*
|
||||
* @return CompositeExpression
|
||||
*/
|
||||
public function orX($x = null)
|
||||
{
|
||||
return new CompositeExpression(CompositeExpression::TYPE_OR, func_get_args());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return Comparison
|
||||
*/
|
||||
public function eq($field, $value)
|
||||
{
|
||||
return new Comparison($field, Comparison::EQ, new Value($value));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return Comparison
|
||||
*/
|
||||
public function gt($field, $value)
|
||||
{
|
||||
return new Comparison($field, Comparison::GT, new Value($value));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return Comparison
|
||||
*/
|
||||
public function lt($field, $value)
|
||||
{
|
||||
return new Comparison($field, Comparison::LT, new Value($value));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return Comparison
|
||||
*/
|
||||
public function gte($field, $value)
|
||||
{
|
||||
return new Comparison($field, Comparison::GTE, new Value($value));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return Comparison
|
||||
*/
|
||||
public function lte($field, $value)
|
||||
{
|
||||
return new Comparison($field, Comparison::LTE, new Value($value));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return Comparison
|
||||
*/
|
||||
public function neq($field, $value)
|
||||
{
|
||||
return new Comparison($field, Comparison::NEQ, new Value($value));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $field
|
||||
*
|
||||
* @return Comparison
|
||||
*/
|
||||
public function isNull($field)
|
||||
{
|
||||
return new Comparison($field, Comparison::EQ, new Value(null));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $field
|
||||
* @param array $values
|
||||
*
|
||||
* @return Comparison
|
||||
*/
|
||||
public function in($field, array $values)
|
||||
{
|
||||
return new Comparison($field, Comparison::IN, new Value($values));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $field
|
||||
* @param array $values
|
||||
*
|
||||
* @return Comparison
|
||||
*/
|
||||
public function notIn($field, array $values)
|
||||
{
|
||||
return new Comparison($field, Comparison::NIN, new Value($values));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return Comparison
|
||||
*/
|
||||
public function contains($field, $value)
|
||||
{
|
||||
return new Comparison($field, Comparison::CONTAINS, new Value($value));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return Comparison
|
||||
*/
|
||||
public function memberOf($field, $value)
|
||||
{
|
||||
return new Comparison($field, Comparison::MEMBER_OF, new Value($value));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return Comparison
|
||||
*/
|
||||
public function startsWith($field, $value)
|
||||
{
|
||||
return new Comparison($field, Comparison::STARTS_WITH, new Value($value));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return Comparison
|
||||
*/
|
||||
public function endsWith($field, $value)
|
||||
{
|
||||
return new Comparison($field, Comparison::ENDS_WITH, new Value($value));
|
||||
}
|
||||
}
|
31
vendor/doctrine/collections/lib/Doctrine/Common/Collections/Selectable.php
vendored
Normal file
31
vendor/doctrine/collections/lib/Doctrine/Common/Collections/Selectable.php
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Collections;
|
||||
|
||||
/**
|
||||
* Interface for collections that allow efficient filtering with an expression API.
|
||||
*
|
||||
* Goal of this interface is a backend independent method to fetch elements
|
||||
* from a collections. {@link Expression} is crafted in a way that you can
|
||||
* implement queries from both in-memory and database-backed collections.
|
||||
*
|
||||
* For database backed collections this allows very efficient access by
|
||||
* utilizing the query APIs, for example SQL in the ORM. Applications using
|
||||
* this API can implement efficient database access without having to ask the
|
||||
* EntityManager or Repositories.
|
||||
*
|
||||
* @psalm-template TKey as array-key
|
||||
* @psalm-template T
|
||||
*/
|
||||
interface Selectable
|
||||
{
|
||||
/**
|
||||
* Selects all elements from a selectable that match the expression and
|
||||
* returns a new collection containing these elements.
|
||||
*
|
||||
* @return Collection
|
||||
*
|
||||
* @psalm-return Collection<TKey,T>
|
||||
*/
|
||||
public function matching(Criteria $criteria);
|
||||
}
|
54
vendor/doctrine/collections/psalm.xml.dist
vendored
Normal file
54
vendor/doctrine/collections/psalm.xml.dist
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
<?xml version="1.0"?>
|
||||
<psalm
|
||||
totallyTyped="false"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="https://getpsalm.org/schema/config"
|
||||
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
|
||||
>
|
||||
<projectFiles>
|
||||
<directory name="lib" />
|
||||
<ignoreFiles>
|
||||
<directory name="vendor" />
|
||||
<directory name="lib/Doctrine/Common/Collections/Expr"/>
|
||||
</ignoreFiles>
|
||||
</projectFiles>
|
||||
|
||||
<issueHandlers>
|
||||
<LessSpecificReturnType errorLevel="info" />
|
||||
|
||||
<!-- level 3 issues - slightly lazy code writing, but provably low false-negatives -->
|
||||
|
||||
<DeprecatedMethod errorLevel="info" />
|
||||
<DeprecatedProperty errorLevel="info" />
|
||||
<DeprecatedClass errorLevel="info" />
|
||||
<DeprecatedConstant errorLevel="info" />
|
||||
<DeprecatedInterface errorLevel="info" />
|
||||
<DeprecatedTrait errorLevel="info" />
|
||||
|
||||
<InternalMethod errorLevel="info" />
|
||||
<InternalProperty errorLevel="info" />
|
||||
<InternalClass errorLevel="info" />
|
||||
|
||||
<MissingClosureReturnType errorLevel="info" />
|
||||
<MissingReturnType errorLevel="info" />
|
||||
<MissingPropertyType errorLevel="info" />
|
||||
<InvalidDocblock errorLevel="info" />
|
||||
<MisplacedRequiredParam errorLevel="info" />
|
||||
|
||||
<PropertyNotSetInConstructor errorLevel="info" />
|
||||
<MissingConstructor errorLevel="info" />
|
||||
<MissingClosureParamType errorLevel="info" />
|
||||
<MissingParamType errorLevel="info" />
|
||||
|
||||
<RedundantCondition errorLevel="info" />
|
||||
|
||||
<DocblockTypeContradiction errorLevel="info" />
|
||||
<RedundantConditionGivenDocblockType errorLevel="info" />
|
||||
|
||||
<UnresolvableInclude errorLevel="info" />
|
||||
|
||||
<RawObjectIteration errorLevel="info" />
|
||||
|
||||
<InvalidStringClass errorLevel="info" />
|
||||
</issueHandlers>
|
||||
</psalm>
|
Reference in New Issue
Block a user