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

@@ -36,8 +36,8 @@ class CouchbaseBucketAdapter extends AbstractAdapter
'durabilityTimeout',
];
private $bucket;
private $marshaller;
private \CouchbaseBucket $bucket;
private MarshallerInterface $marshaller;
public function __construct(\CouchbaseBucket $bucket, string $namespace = '', int $defaultLifetime = 0, MarshallerInterface $marshaller = null)
{
@@ -54,22 +54,17 @@ class CouchbaseBucketAdapter extends AbstractAdapter
$this->marshaller = $marshaller ?? new DefaultMarshaller();
}
/**
* @param array|string $servers
*/
public static function createConnection($servers, array $options = []): \CouchbaseBucket
public static function createConnection(#[\SensitiveParameter] array|string $servers, array $options = []): \CouchbaseBucket
{
if (\is_string($servers)) {
$servers = [$servers];
} elseif (!\is_array($servers)) {
throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be array or string, "%s" given.', __METHOD__, get_debug_type($servers)));
}
if (!static::isSupported()) {
throw new CacheException('Couchbase >= 2.6.0 < 3.0.0 is required.');
}
set_error_handler(function ($type, $msg, $file, $line) { throw new \ErrorException($msg, 0, $type, $file, $line); });
set_error_handler(static fn ($type, $msg, $file, $line) => throw new \ErrorException($msg, 0, $type, $file, $line));
$dsnPattern = '/^(?<protocol>couchbase(?:s)?)\:\/\/(?:(?<username>[^\:]+)\:(?<password>[^\@]{6,})@)?'
.'(?<host>[^\:]+(?:\:\d+)?)(?:\/(?<bucketName>[^\?]+))(?:\?(?<options>.*))?$/i';
@@ -82,8 +77,8 @@ class CouchbaseBucketAdapter extends AbstractAdapter
$password = $options['password'];
foreach ($servers as $dsn) {
if (0 !== strpos($dsn, 'couchbase:')) {
throw new InvalidArgumentException(sprintf('Invalid Couchbase DSN: "%s" does not start with "couchbase:".', $dsn));
if (!str_starts_with($dsn, 'couchbase:')) {
throw new InvalidArgumentException('Invalid Couchbase DSN: it does not start with "couchbase:".');
}
preg_match($dsnPattern, $dsn, $matches);
@@ -146,25 +141,22 @@ class CouchbaseBucketAdapter extends AbstractAdapter
private static function initOptions(array $options): array
{
$options['username'] = $options['username'] ?? '';
$options['password'] = $options['password'] ?? '';
$options['operationTimeout'] = $options['operationTimeout'] ?? 0;
$options['configTimeout'] = $options['configTimeout'] ?? 0;
$options['configNodeTimeout'] = $options['configNodeTimeout'] ?? 0;
$options['n1qlTimeout'] = $options['n1qlTimeout'] ?? 0;
$options['httpTimeout'] = $options['httpTimeout'] ?? 0;
$options['configDelay'] = $options['configDelay'] ?? 0;
$options['htconfigIdleTimeout'] = $options['htconfigIdleTimeout'] ?? 0;
$options['durabilityInterval'] = $options['durabilityInterval'] ?? 0;
$options['durabilityTimeout'] = $options['durabilityTimeout'] ?? 0;
$options['username'] ??= '';
$options['password'] ??= '';
$options['operationTimeout'] ??= 0;
$options['configTimeout'] ??= 0;
$options['configNodeTimeout'] ??= 0;
$options['n1qlTimeout'] ??= 0;
$options['httpTimeout'] ??= 0;
$options['configDelay'] ??= 0;
$options['htconfigIdleTimeout'] ??= 0;
$options['durabilityInterval'] ??= 0;
$options['durabilityTimeout'] ??= 0;
return $options;
}
/**
* {@inheritdoc}
*/
protected function doFetch(array $ids)
protected function doFetch(array $ids): iterable
{
$resultsCouchbase = $this->bucket->get($ids);
@@ -179,17 +171,11 @@ class CouchbaseBucketAdapter extends AbstractAdapter
return $results;
}
/**
* {@inheritdoc}
*/
protected function doHave(string $id): bool
{
return false !== $this->bucket->get($id);
}
/**
* {@inheritdoc}
*/
protected function doClear(string $namespace): bool
{
if ('' === $namespace) {
@@ -201,9 +187,6 @@ class CouchbaseBucketAdapter extends AbstractAdapter
return false;
}
/**
* {@inheritdoc}
*/
protected function doDelete(array $ids): bool
{
$results = $this->bucket->remove(array_values($ids));
@@ -218,10 +201,7 @@ class CouchbaseBucketAdapter extends AbstractAdapter
return 0 === \count($results);
}
/**
* {@inheritdoc}
*/
protected function doSave(array $values, int $lifetime)
protected function doSave(array $values, int $lifetime): array|bool
{
if (!$values = $this->marshaller->marshall($values, $failed)) {
return $failed;