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

@@ -19,10 +19,6 @@ use Symfony\Component\Cache\Adapter\AdapterInterface;
use Symfony\Component\Cache\Exception\InvalidArgumentException;
use Symfony\Component\Cache\Traits\ProxyTrait;
if (null !== (new \ReflectionMethod(CacheInterface::class, 'get'))->getReturnType()) {
throw new \LogicException('psr/simple-cache 3.0+ is not compatible with this version of symfony/cache. Please upgrade symfony/cache to 6.0+ or downgrade psr/simple-cache to 1.x or 2.x.');
}
/**
* Turns a PSR-6 cache into a PSR-16 one.
*
@@ -32,10 +28,9 @@ class Psr16Cache implements CacheInterface, PruneableInterface, ResettableInterf
{
use ProxyTrait;
private const METADATA_EXPIRY_OFFSET = 1527506807;
private $createCacheItem;
private $cacheItemPrototype;
private ?\Closure $createCacheItem = null;
private ?CacheItem $cacheItemPrototype = null;
private static \Closure $packCacheItem;
public function __construct(CacheItemPoolInterface $pool)
{
@@ -71,14 +66,18 @@ class Psr16Cache implements CacheInterface, PruneableInterface, ResettableInterf
return $createCacheItem($key, null, $allowInt)->set($value);
};
self::$packCacheItem ??= \Closure::bind(
static function (CacheItem $item) {
$item->newMetadata = $item->metadata;
return $item->pack();
},
null,
CacheItem::class
);
}
/**
* {@inheritdoc}
*
* @return mixed
*/
public function get($key, $default = null)
public function get($key, $default = null): mixed
{
try {
$item = $this->pool->getItem($key);
@@ -95,12 +94,7 @@ class Psr16Cache implements CacheInterface, PruneableInterface, ResettableInterf
return $item->isHit() ? $item->get() : $default;
}
/**
* {@inheritdoc}
*
* @return bool
*/
public function set($key, $value, $ttl = null)
public function set($key, $value, $ttl = null): bool
{
try {
if (null !== $f = $this->createCacheItem) {
@@ -120,12 +114,7 @@ class Psr16Cache implements CacheInterface, PruneableInterface, ResettableInterf
return $this->pool->save($item);
}
/**
* {@inheritdoc}
*
* @return bool
*/
public function delete($key)
public function delete($key): bool
{
try {
return $this->pool->deleteItem($key);
@@ -136,22 +125,12 @@ class Psr16Cache implements CacheInterface, PruneableInterface, ResettableInterf
}
}
/**
* {@inheritdoc}
*
* @return bool
*/
public function clear()
public function clear(): bool
{
return $this->pool->clear();
}
/**
* {@inheritdoc}
*
* @return iterable
*/
public function getMultiple($keys, $default = null)
public function getMultiple($keys, $default = null): iterable
{
if ($keys instanceof \Traversable) {
$keys = iterator_to_array($keys, false);
@@ -177,31 +156,13 @@ class Psr16Cache implements CacheInterface, PruneableInterface, ResettableInterf
}
foreach ($items as $key => $item) {
if (!$item->isHit()) {
$values[$key] = $default;
continue;
}
$values[$key] = $item->get();
if (!$metadata = $item->getMetadata()) {
continue;
}
unset($metadata[CacheItem::METADATA_TAGS]);
if ($metadata) {
$values[$key] = ["\x9D".pack('VN', (int) (0.1 + $metadata[CacheItem::METADATA_EXPIRY] - self::METADATA_EXPIRY_OFFSET), $metadata[CacheItem::METADATA_CTIME])."\x5F" => $values[$key]];
}
$values[$key] = $item->isHit() ? (self::$packCacheItem)($item) : $default;
}
return $values;
}
/**
* {@inheritdoc}
*
* @return bool
*/
public function setMultiple($values, $ttl = null)
public function setMultiple($values, $ttl = null): bool
{
$valuesIsArray = \is_array($values);
if (!$valuesIsArray && !$values instanceof \Traversable) {
@@ -249,12 +210,7 @@ class Psr16Cache implements CacheInterface, PruneableInterface, ResettableInterf
return $this->pool->commit() && $ok;
}
/**
* {@inheritdoc}
*
* @return bool
*/
public function deleteMultiple($keys)
public function deleteMultiple($keys): bool
{
if ($keys instanceof \Traversable) {
$keys = iterator_to_array($keys, false);
@@ -271,12 +227,7 @@ class Psr16Cache implements CacheInterface, PruneableInterface, ResettableInterf
}
}
/**
* {@inheritdoc}
*
* @return bool
*/
public function has($key)
public function has($key): bool
{
try {
return $this->pool->hasItem($key);