N°6934 - Symfony 6.4 - upgrade Symfony bundles to 6.4 (#580)

* Update Symfony lib to version ~6.4.0
* Update code missing return type
* Add an iTop general configuration entry to store application secret (Symfony mandatory parameter)
* Use dependency injection in ExceptionListener & UserProvider classes
This commit is contained in:
bdalsass
2023-12-05 13:56:56 +01:00
committed by GitHub
parent 863ab4560c
commit 27ce51ab07
1392 changed files with 44869 additions and 27799 deletions

View File

@@ -26,21 +26,21 @@ trait AbstractAdapterTrait
use LoggerAwareTrait;
/**
* @var \Closure needs to be set by class, signature is function(string <key>, mixed <value>, bool <isHit>)
* needs to be set by class, signature is function(string <key>, mixed <value>, bool <isHit>).
*/
private static $createCacheItem;
private static \Closure $createCacheItem;
/**
* @var \Closure needs to be set by class, signature is function(array <deferred>, string <namespace>, array <&expiredIds>)
* needs to be set by class, signature is function(array <deferred>, string <namespace>, array <&expiredIds>).
*/
private static $mergeByLifetime;
private static \Closure $mergeByLifetime;
private $namespace = '';
private $defaultLifetime;
private $namespaceVersion = '';
private $versioningIsEnabled = false;
private $deferred = [];
private $ids = [];
private string $namespace = '';
private int $defaultLifetime;
private string $namespaceVersion = '';
private bool $versioningIsEnabled = false;
private array $deferred = [];
private array $ids = [];
/**
* @var int|null The maximum length to enforce for identifiers or null when no limit applies
@@ -51,37 +51,29 @@ trait AbstractAdapterTrait
* Fetches several cache items.
*
* @param array $ids The cache identifiers to fetch
*
* @return array|\Traversable
*/
abstract protected function doFetch(array $ids);
abstract protected function doFetch(array $ids): iterable;
/**
* Confirms if the cache contains specified cache item.
*
* @param string $id The identifier for which to check existence
*
* @return bool
*/
abstract protected function doHave(string $id);
abstract protected function doHave(string $id): bool;
/**
* Deletes all items in the pool.
*
* @param string $namespace The prefix used for all identifiers managed by this pool
*
* @return bool
*/
abstract protected function doClear(string $namespace);
abstract protected function doClear(string $namespace): bool;
/**
* Removes multiple items from the pool.
*
* @param array $ids An array of identifiers that should be removed from the pool
*
* @return bool
*/
abstract protected function doDelete(array $ids);
abstract protected function doDelete(array $ids): bool;
/**
* Persists several cache items immediately.
@@ -91,14 +83,9 @@ trait AbstractAdapterTrait
*
* @return array|bool The identifiers that failed to be cached or a boolean stating if caching succeeded or not
*/
abstract protected function doSave(array $values, int $lifetime);
abstract protected function doSave(array $values, int $lifetime): array|bool;
/**
* {@inheritdoc}
*
* @return bool
*/
public function hasItem($key)
public function hasItem(mixed $key): bool
{
$id = $this->getId($key);
@@ -115,12 +102,7 @@ trait AbstractAdapterTrait
}
}
/**
* {@inheritdoc}
*
* @return bool
*/
public function clear(string $prefix = '')
public function clear(string $prefix = ''): bool
{
$this->deferred = [];
if ($cleared = $this->versioningIsEnabled) {
@@ -156,22 +138,12 @@ trait AbstractAdapterTrait
}
}
/**
* {@inheritdoc}
*
* @return bool
*/
public function deleteItem($key)
public function deleteItem(mixed $key): bool
{
return $this->deleteItems([$key]);
}
/**
* {@inheritdoc}
*
* @return bool
*/
public function deleteItems(array $keys)
public function deleteItems(array $keys): bool
{
$ids = [];
@@ -184,7 +156,7 @@ trait AbstractAdapterTrait
if ($this->doDelete($ids)) {
return true;
}
} catch (\Exception $e) {
} catch (\Exception) {
}
$ok = true;
@@ -206,10 +178,7 @@ trait AbstractAdapterTrait
return $ok;
}
/**
* {@inheritdoc}
*/
public function getItem($key)
public function getItem(mixed $key): CacheItem
{
$id = $this->getId($key);
@@ -233,10 +202,7 @@ trait AbstractAdapterTrait
return (self::$createCacheItem)($key, null, false);
}
/**
* {@inheritdoc}
*/
public function getItems(array $keys = [])
public function getItems(array $keys = []): iterable
{
$ids = [];
$commit = false;
@@ -261,12 +227,7 @@ trait AbstractAdapterTrait
return $this->generateItems($items, $ids);
}
/**
* {@inheritdoc}
*
* @return bool
*/
public function save(CacheItemInterface $item)
public function save(CacheItemInterface $item): bool
{
if (!$item instanceof CacheItem) {
return false;
@@ -276,12 +237,7 @@ trait AbstractAdapterTrait
return $this->commit();
}
/**
* {@inheritdoc}
*
* @return bool
*/
public function saveDeferred(CacheItemInterface $item)
public function saveDeferred(CacheItemInterface $item): bool
{
if (!$item instanceof CacheItem) {
return false;
@@ -297,11 +253,11 @@ trait AbstractAdapterTrait
* When versioning is enabled, clearing the cache is atomic and doesn't require listing existing keys to proceed,
* but old keys may need garbage collection and extra round-trips to the back-end are required.
*
* Calling this method also clears the memoized namespace version and thus forces a resynchonization of it.
* Calling this method also clears the memoized namespace version and thus forces a resynchronization of it.
*
* @return bool the previous state of versioning
*/
public function enableVersioning(bool $enable = true)
public function enableVersioning(bool $enable = true): bool
{
$wasEnabled = $this->versioningIsEnabled;
$this->versioningIsEnabled = $enable;
@@ -311,10 +267,7 @@ trait AbstractAdapterTrait
return $wasEnabled;
}
/**
* {@inheritdoc}
*/
public function reset()
public function reset(): void
{
if ($this->deferred) {
$this->commit();
@@ -323,14 +276,14 @@ trait AbstractAdapterTrait
$this->ids = [];
}
/**
* @return array
*/
public function __sleep()
public function __sleep(): array
{
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}
/**
* @return void
*/
public function __wakeup()
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
@@ -365,7 +318,10 @@ trait AbstractAdapterTrait
}
}
private function getId($key)
/**
* @internal
*/
protected function getId(mixed $key): string
{
if ($this->versioningIsEnabled && '' === $this->namespaceVersion) {
$this->ids = [];
@@ -394,15 +350,15 @@ trait AbstractAdapterTrait
$this->ids[$key] = $key;
if (\count($this->ids) > 1000) {
array_splice($this->ids, 0, 500); // stop memory leak if there are many keys
$this->ids = \array_slice($this->ids, 500, null, true); // stop memory leak if there are many keys
}
if (null === $this->maxIdLength) {
return $this->namespace.$this->namespaceVersion.$key;
}
if (\strlen($id = $this->namespace.$this->namespaceVersion.$key) > $this->maxIdLength) {
// Use MD5 to favor speed over security, which is not an issue here
$this->ids[$key] = $id = substr_replace(base64_encode(hash('md5', $key, true)), static::NS_SEPARATOR, -(\strlen($this->namespaceVersion) + 2));
// Use xxh128 to favor speed over security, which is not an issue here
$this->ids[$key] = $id = substr_replace(base64_encode(hash('xxh128', $key, true)), static::NS_SEPARATOR, -(\strlen($this->namespaceVersion) + 2));
$id = $this->namespace.$this->namespaceVersion.$id;
}
@@ -412,7 +368,7 @@ trait AbstractAdapterTrait
/**
* @internal
*/
public static function handleUnserializeCallback(string $class)
public static function handleUnserializeCallback(string $class): never
{
throw new \DomainException('Class not found: '.$class);
}