diff options
author | Louis Chemineau <louis@chmn.me> | 2024-08-28 10:44:18 +0200 |
---|---|---|
committer | Louis Chemineau <louis@chmn.me> | 2024-08-28 10:44:18 +0200 |
commit | 2574cbfa619bc8650e865f6fda064cd22c6b2d0e (patch) | |
tree | a14ce0f2303e7e309225a403c8cfeb9b753ce124 /lib | |
parent | 9d0248545d85d6a680f2c9507f1bcfe13e889535 (diff) | |
download | nextcloud-server-2574cbfa619bc8650e865f6fda064cd22c6b2d0e.tar.gz nextcloud-server-2574cbfa619bc8650e865f6fda064cd22c6b2d0e.zip |
chore: Apply php:cs recommendations
Signed-off-by: Louis Chemineau <louis@chmn.me>
Diffstat (limited to 'lib')
9 files changed, 39 insertions, 39 deletions
diff --git a/lib/private/DB/ArrayResult.php b/lib/private/DB/ArrayResult.php index 5d094533a3f..b567ad23d57 100644 --- a/lib/private/DB/ArrayResult.php +++ b/lib/private/DB/ArrayResult.php @@ -37,7 +37,7 @@ class ArrayResult implements IResult { PDO::FETCH_ASSOC => $row, PDO::FETCH_NUM => array_values($row), PDO::FETCH_COLUMN => current($row), - default => throw new \InvalidArgumentException("Fetch mode not supported for array result"), + default => throw new \InvalidArgumentException('Fetch mode not supported for array result'), }; } @@ -51,7 +51,7 @@ class ArrayResult implements IResult { PDO::FETCH_COLUMN => array_map(function ($row) { return current($row); }, $this->rows), - default => throw new \InvalidArgumentException("Fetch mode not supported for array result"), + default => throw new \InvalidArgumentException('Fetch mode not supported for array result'), }; } diff --git a/lib/private/DB/QueryBuilder/Partitioned/JoinCondition.php b/lib/private/DB/QueryBuilder/Partitioned/JoinCondition.php index ff4e1da70b9..a08858d1d6b 100644 --- a/lib/private/DB/QueryBuilder/Partitioned/JoinCondition.php +++ b/lib/private/DB/QueryBuilder/Partitioned/JoinCondition.php @@ -37,8 +37,8 @@ class JoinCondition { * @return JoinCondition */ public static function merge(array $conditions): JoinCondition { - $fromColumn = ""; - $toColumn = ""; + $fromColumn = ''; + $toColumn = ''; $fromAlias = null; $toAlias = null; $fromConditions = []; @@ -99,9 +99,9 @@ class JoinCondition { $isSubCondition = self::isExtraCondition($condition); if ($isSubCondition) { if (self::mentionsAlias($condition, $fromAlias)) { - return new JoinCondition("", null, "", null, [$condition], []); + return new JoinCondition('', null, '', null, [$condition], []); } else { - return new JoinCondition("", null, "", null, [], [$condition]); + return new JoinCondition('', null, '', null, [], [$condition]); } } diff --git a/lib/private/DB/QueryBuilder/Partitioned/PartitionedQueryBuilder.php b/lib/private/DB/QueryBuilder/Partitioned/PartitionedQueryBuilder.php index 8fcde0d24ae..175b7c1a42e 100644 --- a/lib/private/DB/QueryBuilder/Partitioned/PartitionedQueryBuilder.php +++ b/lib/private/DB/QueryBuilder/Partitioned/PartitionedQueryBuilder.php @@ -391,10 +391,10 @@ class PartitionedQueryBuilder extends ShardedQueryBuilder { }, false); if ($hasNonLeftJoins) { if (is_int($this->limit)) { - throw new InvalidPartitionedQueryException("Limit is not allowed in partitioned queries"); + throw new InvalidPartitionedQueryException('Limit is not allowed in partitioned queries'); } if (is_int($this->offset)) { - throw new InvalidPartitionedQueryException("Offset is not allowed in partitioned queries"); + throw new InvalidPartitionedQueryException('Offset is not allowed in partitioned queries'); } } } diff --git a/lib/private/DB/QueryBuilder/Sharded/AutoIncrementHandler.php b/lib/private/DB/QueryBuilder/Sharded/AutoIncrementHandler.php index 553644def4e..d40934669d7 100644 --- a/lib/private/DB/QueryBuilder/Sharded/AutoIncrementHandler.php +++ b/lib/private/DB/QueryBuilder/Sharded/AutoIncrementHandler.php @@ -29,13 +29,13 @@ class AutoIncrementHandler { private ShardConnectionManager $shardConnectionManager, ) { if (PHP_INT_SIZE < 8) { - throw new \Exception("sharding is only supported with 64bit php"); + throw new \Exception('sharding is only supported with 64bit php'); } } private function getCache(): IMemcache { if(is_null($this->cache)) { - $cache = $this->cacheFactory->createDistributed("shared_autoincrement"); + $cache = $this->cacheFactory->createDistributed('shared_autoincrement'); if ($cache instanceof IMemcache) { $this->cache = $cache; } else { @@ -61,7 +61,7 @@ class AutoIncrementHandler { $next = $this->getNextInner($shardDefinition); if ($next !== null) { if ($next > ShardDefinition::MAX_PRIMARY_KEY) { - throw new \Exception("Max primary key of " . ShardDefinition::MAX_PRIMARY_KEY . " exceeded"); + throw new \Exception('Max primary key of ' . ShardDefinition::MAX_PRIMARY_KEY . ' exceeded'); } // we encode the shard the primary key was originally inserted into to allow guessing the shard by primary key later on return ($next << 8) | $shard; @@ -69,7 +69,7 @@ class AutoIncrementHandler { $retries++; } } - throw new \Exception("Failed to get next primary key"); + throw new \Exception('Failed to get next primary key'); } /** @@ -88,7 +88,7 @@ class AutoIncrementHandler { // if that is not the case we find the highest used id in the database increment it, and save it in the cache // prevent inc from returning `1` if the key doesn't exist by setting it to a non-numeric value - $cache->add($shardDefinition->table, "empty-placeholder", self::TTL); + $cache->add($shardDefinition->table, 'empty-placeholder', self::TTL); $next = $cache->inc($shardDefinition->table); if ($cache instanceof IMemcacheTTL) { @@ -101,7 +101,7 @@ class AutoIncrementHandler { return $next; } elseif (is_int($next)) { // we hit the edge case, so invalidate the cached value - if (!$cache->cas($shardDefinition->table, $next, "empty-placeholder")) { + if (!$cache->cas($shardDefinition->table, $next, 'empty-placeholder')) { // someone else is changing the value concurrently, give up and retry return null; } @@ -110,7 +110,7 @@ class AutoIncrementHandler { // discard the encoded initial shard $current = $this->getMaxFromDb($shardDefinition) >> 8; $next = max($current, self::MIN_VALID_KEY) + 1; - if ($cache->cas($shardDefinition->table, "empty-placeholder", $next)) { + if ($cache->cas($shardDefinition->table, 'empty-placeholder', $next)) { return $next; } @@ -120,11 +120,11 @@ class AutoIncrementHandler { return $next; } elseif(is_int($next)) { // key got cleared, invalidate and retry - $cache->cas($shardDefinition->table, $next, "empty-placeholder"); + $cache->cas($shardDefinition->table, $next, 'empty-placeholder'); return null; } else { // cleanup any non-numeric value other than the placeholder if that got stored somehow - $cache->ncad($shardDefinition->table, "empty-placeholder"); + $cache->ncad($shardDefinition->table, 'empty-placeholder'); // retry return null; } @@ -140,7 +140,7 @@ class AutoIncrementHandler { $query = $connection->getQueryBuilder(); $query->select($shardDefinition->primaryKey) ->from($shardDefinition->table) - ->orderBy($shardDefinition->primaryKey, "DESC") + ->orderBy($shardDefinition->primaryKey, 'DESC') ->setMaxResults(1); $result = $query->executeQuery()->fetchOne(); if ($result) { diff --git a/lib/private/DB/QueryBuilder/Sharded/CrossShardMoveHelper.php b/lib/private/DB/QueryBuilder/Sharded/CrossShardMoveHelper.php index ffc95e4e54c..45f24e32685 100644 --- a/lib/private/DB/QueryBuilder/Sharded/CrossShardMoveHelper.php +++ b/lib/private/DB/QueryBuilder/Sharded/CrossShardMoveHelper.php @@ -83,13 +83,13 @@ class CrossShardMoveHelper { $query = $connection->getQueryBuilder(); $query->select('*') ->from($table) - ->where($query->expr()->in($primaryColumn, $query->createParameter("keys"))); + ->where($query->expr()->in($primaryColumn, $query->createParameter('keys'))); $chunks = array_chunk($primaryKeys, 1000); $results = []; foreach ($chunks as $chunk) { - $query->setParameter("keys", $chunk, IQueryBuilder::PARAM_INT_ARRAY); + $query->setParameter('keys', $chunk, IQueryBuilder::PARAM_INT_ARRAY); $results = array_merge($results, $query->execute()->fetchAll()); } @@ -151,11 +151,11 @@ class CrossShardMoveHelper { public function deleteItems(IDBConnection $connection, string $table, string $primaryColumn, array $primaryKeys): void { $query = $connection->getQueryBuilder(); $query->delete($table) - ->where($query->expr()->in($primaryColumn, $query->createParameter("keys"))); + ->where($query->expr()->in($primaryColumn, $query->createParameter('keys'))); $chunks = array_chunk($primaryKeys, 1000); foreach ($chunks as $chunk) { - $query->setParameter("keys", $chunk, IQueryBuilder::PARAM_INT_ARRAY); + $query->setParameter('keys', $chunk, IQueryBuilder::PARAM_INT_ARRAY); $query->executeStatement(); } } diff --git a/lib/private/DB/QueryBuilder/Sharded/ShardDefinition.php b/lib/private/DB/QueryBuilder/Sharded/ShardDefinition.php index 5661ca079e1..ebccbb639a6 100644 --- a/lib/private/DB/QueryBuilder/Sharded/ShardDefinition.php +++ b/lib/private/DB/QueryBuilder/Sharded/ShardDefinition.php @@ -41,7 +41,7 @@ class ShardDefinition { public array $shards = [], ) { if (count($this->shards) >= self::MAX_SHARDS) { - throw new \Exception("Only allowed maximum of " . self::MAX_SHARDS . " shards allowed"); + throw new \Exception('Only allowed maximum of ' . self::MAX_SHARDS . ' shards allowed'); } } diff --git a/lib/private/DB/QueryBuilder/Sharded/ShardQueryRunner.php b/lib/private/DB/QueryBuilder/Sharded/ShardQueryRunner.php index 22b86a018b3..51cd055e801 100644 --- a/lib/private/DB/QueryBuilder/Sharded/ShardQueryRunner.php +++ b/lib/private/DB/QueryBuilder/Sharded/ShardQueryRunner.php @@ -135,7 +135,7 @@ class ShardQueryRunner { if ($cmp === 0) { continue; } - if ($sort['order'] === "DESC") { + if ($sort['order'] === 'DESC') { $cmp = -$cmp; } return $cmp; @@ -166,7 +166,7 @@ class ShardQueryRunner { */ public function executeStatement(IQueryBuilder $query, bool $allShards, array $shardKeys, array $primaryKeys): int { if ($query->getType() === \Doctrine\DBAL\Query\QueryBuilder::INSERT) { - throw new \Exception("insert queries need special handling"); + throw new \Exception('insert queries need special handling'); } $shards = $this->getShards($allShards, $shardKeys); diff --git a/lib/private/DB/QueryBuilder/Sharded/ShardedQueryBuilder.php b/lib/private/DB/QueryBuilder/Sharded/ShardedQueryBuilder.php index 650e414096e..e7bc70ce440 100644 --- a/lib/private/DB/QueryBuilder/Sharded/ShardedQueryBuilder.php +++ b/lib/private/DB/QueryBuilder/Sharded/ShardedQueryBuilder.php @@ -36,7 +36,7 @@ class ShardedQueryBuilder extends ExtendedQueryBuilder { private ?int $updateShardKey = null; private ?int $limit = null; private ?int $offset = null; - /** @var array{column: string, order: string}[] */ + /** @var array{column: string, order: string}[] */ private array $sortList = []; private string $mainTable = ''; @@ -276,13 +276,13 @@ class ShardedQueryBuilder extends ExtendedQueryBuilder { } public function addOrderBy($sort, $order = null) { - $this->registerOrder((string) $sort, (string)$order ?? "ASC"); + $this->registerOrder((string)$sort, (string)$order ?? 'ASC'); return parent::orderBy($sort, $order); } public function orderBy($sort, $order = null) { $this->sortList = []; - $this->registerOrder((string) $sort, (string)$order ?? "ASC"); + $this->registerOrder((string)$sort, (string)$order ?? 'ASC'); return parent::orderBy($sort, $order); } @@ -329,7 +329,7 @@ class ShardedQueryBuilder extends ExtendedQueryBuilder { } if ($this->shardDefinition && !$this->allShards) { if (empty($this->getShardKeys()) && empty($this->getPrimaryKeys())) { - throw new InvalidShardedQueryException("No shard key or primary key set for query"); + throw new InvalidShardedQueryException('No shard key or primary key set for query'); } } if ($this->shardDefinition && $this->updateShardKey) { @@ -347,7 +347,7 @@ class ShardedQueryBuilder extends ExtendedQueryBuilder { }, $oldShardKeys))); $newShard = $this->shardDefinition->getShardForKey((int)$newShardKey); if ($oldShards === [$newShard]) { - throw new InvalidShardedQueryException("Update statement would move rows to a different shard"); + throw new InvalidShardedQueryException('Update statement would move rows to a different shard'); } } } diff --git a/lib/private/Files/Cache/Cache.php b/lib/private/Files/Cache/Cache.php index 8cb203ab2bc..a8d9067050d 100644 --- a/lib/private/Files/Cache/Cache.php +++ b/lib/private/Files/Cache/Cache.php @@ -1220,9 +1220,9 @@ class Cache implements ICache { $sourceConnection = $helper->getConnection($shardDefinition, $sourceCache->getNumericStorageId()); $targetConnection = $helper->getConnection($shardDefinition, $this->getNumericStorageId()); - $cacheItems = $helper->loadItems($sourceConnection, "filecache", "fileid", $fileIds); - $extendedItems = $helper->loadItems($sourceConnection, "filecache_extended", "fileid", $fileIds); - $metadataItems = $helper->loadItems($sourceConnection, "files_metadata", "file_id", $fileIds); + $cacheItems = $helper->loadItems($sourceConnection, 'filecache', 'fileid', $fileIds); + $extendedItems = $helper->loadItems($sourceConnection, 'filecache_extended', 'fileid', $fileIds); + $metadataItems = $helper->loadItems($sourceConnection, 'files_metadata', 'file_id', $fileIds); // when moving from an encrypted storage to a non-encrypted storage remove the `encrypted` mark $removeEncryptedFlag = ($sourceCache instanceof Cache && $sourceCache->hasEncryptionWrapper()) && !$this->hasEncryptionWrapper(); @@ -1246,9 +1246,9 @@ class Cache implements ICache { $targetConnection->beginTransaction(); try { - $helper->saveItems($targetConnection, "filecache", $cacheItems); - $helper->saveItems($targetConnection, "filecache_extended", $extendedItems); - $helper->saveItems($targetConnection, "files_metadata", $metadataItems); + $helper->saveItems($targetConnection, 'filecache', $cacheItems); + $helper->saveItems($targetConnection, 'filecache_extended', $extendedItems); + $helper->saveItems($targetConnection, 'files_metadata', $metadataItems); } catch (\Exception $e) { $targetConnection->rollback(); throw $e; @@ -1257,9 +1257,9 @@ class Cache implements ICache { $sourceConnection->beginTransaction(); try { - $helper->deleteItems($sourceConnection, "filecache", "fileid", $fileIds); - $helper->deleteItems($sourceConnection, "filecache_extended", "fileid", $fileIds); - $helper->deleteItems($sourceConnection, "files_metadata", "file_id", $fileIds); + $helper->deleteItems($sourceConnection, 'filecache', 'fileid', $fileIds); + $helper->deleteItems($sourceConnection, 'filecache_extended', 'fileid', $fileIds); + $helper->deleteItems($sourceConnection, 'files_metadata', 'file_id', $fileIds); } catch (\Exception $e) { $targetConnection->rollback(); $sourceConnection->rollBack(); |