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

@@ -33,11 +33,11 @@ class ChainAdapter implements AdapterInterface, CacheInterface, PruneableInterfa
{
use ContractsTrait;
private $adapters = [];
private $adapterCount;
private $defaultLifetime;
private array $adapters = [];
private int $adapterCount;
private int $defaultLifetime;
private static $syncItem;
private static \Closure $syncItem;
/**
* @param CacheItemPoolInterface[] $adapters The ordered list of adapters used to fetch cached items
@@ -53,7 +53,7 @@ class ChainAdapter implements AdapterInterface, CacheInterface, PruneableInterfa
if (!$adapter instanceof CacheItemPoolInterface) {
throw new InvalidArgumentException(sprintf('The class "%s" does not implement the "%s" interface.', get_debug_type($adapter), CacheItemPoolInterface::class));
}
if (\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && $adapter instanceof ApcuAdapter && !filter_var(\ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN)) {
if ('cli' === \PHP_SAPI && $adapter instanceof ApcuAdapter && !filter_var(\ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOL)) {
continue; // skip putting APCu in the chain when the backend is disabled
}
@@ -66,18 +66,17 @@ class ChainAdapter implements AdapterInterface, CacheInterface, PruneableInterfa
$this->adapterCount = \count($this->adapters);
$this->defaultLifetime = $defaultLifetime;
self::$syncItem ?? self::$syncItem = \Closure::bind(
self::$syncItem ??= \Closure::bind(
static function ($sourceItem, $item, $defaultLifetime, $sourceMetadata = null) {
$sourceItem->isTaggable = false;
$sourceMetadata = $sourceMetadata ?? $sourceItem->metadata;
unset($sourceMetadata[CacheItem::METADATA_TAGS]);
$sourceMetadata ??= $sourceItem->metadata;
$item->value = $sourceItem->value;
$item->isHit = $sourceItem->isHit;
$item->metadata = $item->newMetadata = $sourceItem->metadata = $sourceMetadata;
if (isset($item->metadata[CacheItem::METADATA_EXPIRY])) {
$item->expiresAt(\DateTime::createFromFormat('U.u', sprintf('%.6F', $item->metadata[CacheItem::METADATA_EXPIRY])));
$item->expiresAt(\DateTimeImmutable::createFromFormat('U.u', sprintf('%.6F', $item->metadata[CacheItem::METADATA_EXPIRY])));
} elseif (0 < $defaultLifetime) {
$item->expiresAfter($defaultLifetime);
}
@@ -89,10 +88,7 @@ class ChainAdapter implements AdapterInterface, CacheInterface, PruneableInterfa
);
}
/**
* {@inheritdoc}
*/
public function get(string $key, callable $callback, float $beta = null, array &$metadata = null)
public function get(string $key, callable $callback, float $beta = null, array &$metadata = null): mixed
{
$doSave = true;
$callback = static function (CacheItem $item, bool &$save) use ($callback, &$doSave) {
@@ -102,9 +98,9 @@ class ChainAdapter implements AdapterInterface, CacheInterface, PruneableInterfa
return $value;
};
$lastItem = null;
$i = 0;
$wrap = function (CacheItem $item = null, bool &$save = true) use ($key, $callback, $beta, &$wrap, &$i, &$doSave, &$lastItem, &$metadata) {
$wrap = function (CacheItem $item = null, bool &$save = true) use ($key, $callback, $beta, &$wrap, &$doSave, &$metadata) {
static $lastItem;
static $i = 0;
$adapter = $this->adapters[$i];
if (isset($this->adapters[++$i])) {
$callback = $wrap;
@@ -116,7 +112,7 @@ class ChainAdapter implements AdapterInterface, CacheInterface, PruneableInterfa
$value = $this->doGet($adapter, $key, $callback, $beta, $metadata);
}
if (null !== $item) {
(self::$syncItem)($lastItem = $lastItem ?? $item, $item, $this->defaultLifetime, $metadata);
(self::$syncItem)($lastItem ??= $item, $item, $this->defaultLifetime, $metadata);
}
$save = $doSave;
@@ -126,10 +122,7 @@ class ChainAdapter implements AdapterInterface, CacheInterface, PruneableInterfa
return $wrap();
}
/**
* {@inheritdoc}
*/
public function getItem($key)
public function getItem(mixed $key): CacheItem
{
$syncItem = self::$syncItem;
$misses = [];
@@ -151,10 +144,7 @@ class ChainAdapter implements AdapterInterface, CacheInterface, PruneableInterfa
return $item;
}
/**
* {@inheritdoc}
*/
public function getItems(array $keys = [])
public function getItems(array $keys = []): iterable
{
return $this->generateItems($this->adapters[0]->getItems($keys), 0);
}
@@ -190,12 +180,7 @@ class ChainAdapter implements AdapterInterface, CacheInterface, PruneableInterfa
}
}
/**
* {@inheritdoc}
*
* @return bool
*/
public function hasItem($key)
public function hasItem(mixed $key): bool
{
foreach ($this->adapters as $adapter) {
if ($adapter->hasItem($key)) {
@@ -206,12 +191,7 @@ class ChainAdapter implements AdapterInterface, CacheInterface, PruneableInterfa
return false;
}
/**
* {@inheritdoc}
*
* @return bool
*/
public function clear(string $prefix = '')
public function clear(string $prefix = ''): bool
{
$cleared = true;
$i = $this->adapterCount;
@@ -227,12 +207,7 @@ class ChainAdapter implements AdapterInterface, CacheInterface, PruneableInterfa
return $cleared;
}
/**
* {@inheritdoc}
*
* @return bool
*/
public function deleteItem($key)
public function deleteItem(mixed $key): bool
{
$deleted = true;
$i = $this->adapterCount;
@@ -244,12 +219,7 @@ class ChainAdapter implements AdapterInterface, CacheInterface, PruneableInterfa
return $deleted;
}
/**
* {@inheritdoc}
*
* @return bool
*/
public function deleteItems(array $keys)
public function deleteItems(array $keys): bool
{
$deleted = true;
$i = $this->adapterCount;
@@ -261,12 +231,7 @@ class ChainAdapter implements AdapterInterface, CacheInterface, PruneableInterfa
return $deleted;
}
/**
* {@inheritdoc}
*
* @return bool
*/
public function save(CacheItemInterface $item)
public function save(CacheItemInterface $item): bool
{
$saved = true;
$i = $this->adapterCount;
@@ -278,12 +243,7 @@ class ChainAdapter implements AdapterInterface, CacheInterface, PruneableInterfa
return $saved;
}
/**
* {@inheritdoc}
*
* @return bool
*/
public function saveDeferred(CacheItemInterface $item)
public function saveDeferred(CacheItemInterface $item): bool
{
$saved = true;
$i = $this->adapterCount;
@@ -295,12 +255,7 @@ class ChainAdapter implements AdapterInterface, CacheInterface, PruneableInterfa
return $saved;
}
/**
* {@inheritdoc}
*
* @return bool
*/
public function commit()
public function commit(): bool
{
$committed = true;
$i = $this->adapterCount;
@@ -312,10 +267,7 @@ class ChainAdapter implements AdapterInterface, CacheInterface, PruneableInterfa
return $committed;
}
/**
* {@inheritdoc}
*/
public function prune()
public function prune(): bool
{
$pruned = true;
@@ -329,7 +281,7 @@ class ChainAdapter implements AdapterInterface, CacheInterface, PruneableInterfa
}
/**
* {@inheritdoc}
* @return void
*/
public function reset()
{