Skip to content

Commit 46ede5c

Browse files
CS fixes
1 parent 6c10ec3 commit 46ede5c

16 files changed

+41
-41
lines changed

Lock.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function acquire(bool $blocking = false): bool
9898
} catch (\Exception) {
9999
// swallow exception to not hide the original issue
100100
}
101-
throw new LockExpiredException(sprintf('Failed to store the "%s" lock.', $this->key));
101+
throw new LockExpiredException(\sprintf('Failed to store the "%s" lock.', $this->key));
102102
}
103103

104104
return true;
@@ -113,7 +113,7 @@ public function acquire(bool $blocking = false): bool
113113
return false;
114114
} catch (\Exception $e) {
115115
$this->logger?->notice('Failed to acquire the "{resource}" lock.', ['resource' => $this->key, 'exception' => $e]);
116-
throw new LockAcquiringException(sprintf('Failed to acquire the "%s" lock.', $this->key), 0, $e);
116+
throw new LockAcquiringException(\sprintf('Failed to acquire the "%s" lock.', $this->key), 0, $e);
117117
}
118118
}
119119

@@ -156,7 +156,7 @@ public function acquireRead(bool $blocking = false): bool
156156
} catch (\Exception) {
157157
// swallow exception to not hide the original issue
158158
}
159-
throw new LockExpiredException(sprintf('Failed to store the "%s" lock.', $this->key));
159+
throw new LockExpiredException(\sprintf('Failed to store the "%s" lock.', $this->key));
160160
}
161161

162162
return true;
@@ -171,7 +171,7 @@ public function acquireRead(bool $blocking = false): bool
171171
return false;
172172
} catch (\Exception $e) {
173173
$this->logger?->notice('Failed to acquire the "{resource}" lock.', ['resource' => $this->key, 'exception' => $e]);
174-
throw new LockAcquiringException(sprintf('Failed to acquire the "%s" lock.', $this->key), 0, $e);
174+
throw new LockAcquiringException(\sprintf('Failed to acquire the "%s" lock.', $this->key), 0, $e);
175175
}
176176
}
177177

@@ -192,7 +192,7 @@ public function refresh(?float $ttl = null): void
192192
} catch (\Exception) {
193193
// swallow exception to not hide the original issue
194194
}
195-
throw new LockExpiredException(sprintf('Failed to put off the expiration of the "%s" lock within the specified time.', $this->key));
195+
throw new LockExpiredException(\sprintf('Failed to put off the expiration of the "%s" lock within the specified time.', $this->key));
196196
}
197197

198198
$this->logger?->debug('Expiration defined for "{resource}" lock for "{ttl}" seconds.', ['resource' => $this->key, 'ttl' => $ttl]);
@@ -202,7 +202,7 @@ public function refresh(?float $ttl = null): void
202202
throw $e;
203203
} catch (\Exception $e) {
204204
$this->logger?->notice('Failed to define an expiration for the "{resource}" lock.', ['resource' => $this->key, 'exception' => $e]);
205-
throw new LockAcquiringException(sprintf('Failed to define an expiration for the "%s" lock.', $this->key), 0, $e);
205+
throw new LockAcquiringException(\sprintf('Failed to define an expiration for the "%s" lock.', $this->key), 0, $e);
206206
}
207207
}
208208

@@ -220,11 +220,11 @@ public function release(): void
220220
} catch (LockReleasingException $e) {
221221
throw $e;
222222
} catch (\Exception $e) {
223-
throw new LockReleasingException(sprintf('Failed to release the "%s" lock.', $this->key), 0, $e);
223+
throw new LockReleasingException(\sprintf('Failed to release the "%s" lock.', $this->key), 0, $e);
224224
}
225225

226226
if ($this->store->exists($this->key)) {
227-
throw new LockReleasingException(sprintf('Failed to release the "%s" lock, the resource is still locked.', $this->key));
227+
throw new LockReleasingException(\sprintf('Failed to release the "%s" lock, the resource is still locked.', $this->key));
228228
}
229229

230230
$this->logger?->debug('Successfully released the "{resource}" lock.', ['resource' => $this->key]);

Store/CombinedStore.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function __construct(array $stores, StrategyInterface $strategy)
4343
{
4444
foreach ($stores as $store) {
4545
if (!$store instanceof PersistingStoreInterface) {
46-
throw new InvalidArgumentException(sprintf('The store must implement "%s". Got "%s".', PersistingStoreInterface::class, get_debug_type($store)));
46+
throw new InvalidArgumentException(\sprintf('The store must implement "%s". Got "%s".', PersistingStoreInterface::class, get_debug_type($store)));
4747
}
4848
}
4949

Store/DatabaseTableTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ trait DatabaseTableTrait
3030
private function init(array $options, float $gcProbability, int $initialTtl): void
3131
{
3232
if ($gcProbability < 0 || $gcProbability > 1) {
33-
throw new InvalidArgumentException(sprintf('"%s" requires gcProbability between 0 and 1, "%f" given.', __METHOD__, $gcProbability));
33+
throw new InvalidArgumentException(\sprintf('"%s" requires gcProbability between 0 and 1, "%f" given.', __METHOD__, $gcProbability));
3434
}
3535
if ($initialTtl < 1) {
36-
throw new InvalidTtlException(sprintf('"%s()" expects a strictly positive TTL, "%d" given.', __METHOD__, $initialTtl));
36+
throw new InvalidTtlException(\sprintf('"%s()" expects a strictly positive TTL, "%d" given.', __METHOD__, $initialTtl));
3737
}
3838

3939
$this->table = $options['db_table'] ?? $this->table;

Store/DoctrineDbalPostgreSqlStore.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function __construct(#[\SensitiveParameter] Connection|string $connOrUrl)
4545
{
4646
if ($connOrUrl instanceof Connection) {
4747
if (!$connOrUrl->getDatabasePlatform() instanceof PostgreSQLPlatform) {
48-
throw new InvalidArgumentException(sprintf('The adapter "%s" does not support the "%s" platform.', __CLASS__, $connOrUrl->getDatabasePlatform()::class));
48+
throw new InvalidArgumentException(\sprintf('The adapter "%s" does not support the "%s" platform.', __CLASS__, $connOrUrl->getDatabasePlatform()::class));
4949
}
5050
$this->conn = $connOrUrl;
5151
} else {
@@ -294,10 +294,10 @@ private function filterDsn(#[\SensitiveParameter] string $dsn): string
294294
[$scheme, $rest] = explode(':', $dsn, 2);
295295
$driver = strtok($scheme, '+');
296296
if (!\in_array($driver, ['pgsql', 'postgres', 'postgresql'])) {
297-
throw new InvalidArgumentException(sprintf('The adapter "%s" does not support the "%s" driver.', __CLASS__, $driver));
297+
throw new InvalidArgumentException(\sprintf('The adapter "%s" does not support the "%s" driver.', __CLASS__, $driver));
298298
}
299299

300-
return sprintf('%s:%s', $driver, $rest);
300+
return \sprintf('%s:%s', $driver, $rest);
301301
}
302302

303303
private function getInternalStore(): SharedLockStoreInterface

Store/DoctrineDbalStore.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public function save(Key $key)
144144
public function putOffExpiration(Key $key, $ttl)
145145
{
146146
if ($ttl < 1) {
147-
throw new InvalidTtlException(sprintf('"%s()" expects a TTL greater or equals to 1 second. Got "%s".', __METHOD__, $ttl));
147+
throw new InvalidTtlException(\sprintf('"%s()" expects a TTL greater or equals to 1 second. Got "%s".', __METHOD__, $ttl));
148148
}
149149

150150
$key->reduceLifetime($ttl);

Store/ExpiringStoreTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ private function checkNotExpired(Key $key): void
2424
} catch (\Exception) {
2525
// swallow exception to not hide the original issue
2626
}
27-
throw new LockExpiredException(sprintf('Failed to store the "%s" lock.', $key));
27+
throw new LockExpiredException(\sprintf('Failed to store the "%s" lock.', $key));
2828
}
2929
}
3030
}

Store/FlockStore.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ public function __construct(?string $lockPath = null)
4141
{
4242
if (!is_dir($lockPath ??= sys_get_temp_dir())) {
4343
if (false === @mkdir($lockPath, 0777, true) && !is_dir($lockPath)) {
44-
throw new InvalidArgumentException(sprintf('The FlockStore directory "%s" does not exists and cannot be created.', $lockPath));
44+
throw new InvalidArgumentException(\sprintf('The FlockStore directory "%s" does not exists and cannot be created.', $lockPath));
4545
}
4646
} elseif (!is_writable($lockPath)) {
47-
throw new InvalidArgumentException(sprintf('The FlockStore directory "%s" is not writable.', $lockPath));
47+
throw new InvalidArgumentException(\sprintf('The FlockStore directory "%s" is not writable.', $lockPath));
4848
}
4949

5050
$this->lockPath = $lockPath;
@@ -95,7 +95,7 @@ private function lock(Key $key, bool $read, bool $blocking): void
9595
}
9696

9797
if (!$handle) {
98-
$fileName = sprintf('%s/sf.%s.%s.lock',
98+
$fileName = \sprintf('%s/sf.%s.%s.lock',
9999
$this->lockPath,
100100
substr(preg_replace('/[^a-z0-9\._-]+/i', '-', $key), 0, 50),
101101
strtr(substr(base64_encode(hash('sha256', $key, true)), 0, 7), '/', '_')

Store/MemcachedStore.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function __construct(\Memcached $memcached, int $initialTtl = 300)
4848
}
4949

5050
if ($initialTtl < 1) {
51-
throw new InvalidArgumentException(sprintf('"%s()" expects a strictly positive TTL. Got %d.', __METHOD__, $initialTtl));
51+
throw new InvalidArgumentException(\sprintf('"%s()" expects a strictly positive TTL. Got %d.', __METHOD__, $initialTtl));
5252
}
5353

5454
$this->memcached = $memcached;
@@ -76,7 +76,7 @@ public function save(Key $key)
7676
public function putOffExpiration(Key $key, float $ttl)
7777
{
7878
if ($ttl < 1) {
79-
throw new InvalidTtlException(sprintf('"%s()" expects a TTL greater or equals to 1 second. Got %s.', __METHOD__, $ttl));
79+
throw new InvalidTtlException(\sprintf('"%s()" expects a TTL greater or equals to 1 second. Got %s.', __METHOD__, $ttl));
8080
}
8181

8282
// Interface defines a float value but Store required an integer.

Store/MongoDbStore.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,19 +128,19 @@ public function __construct(Collection|Database|Client|Manager|string $mongo, ar
128128
}
129129

130130
if (null === $this->options['database']) {
131-
throw new InvalidArgumentException(sprintf('"%s()" requires the "database" in the URI path or option.', __METHOD__));
131+
throw new InvalidArgumentException(\sprintf('"%s()" requires the "database" in the URI path or option.', __METHOD__));
132132
}
133133
if (null === $this->options['collection']) {
134-
throw new InvalidArgumentException(sprintf('"%s()" requires the "collection" in the URI querystring or option.', __METHOD__));
134+
throw new InvalidArgumentException(\sprintf('"%s()" requires the "collection" in the URI querystring or option.', __METHOD__));
135135
}
136136
$this->namespace = $this->options['database'].'.'.$this->options['collection'];
137137

138138
if ($this->options['gcProbability'] < 0.0 || $this->options['gcProbability'] > 1.0) {
139-
throw new InvalidArgumentException(sprintf('"%s()" gcProbability must be a float from 0.0 to 1.0, "%f" given.', __METHOD__, $this->options['gcProbability']));
139+
throw new InvalidArgumentException(\sprintf('"%s()" gcProbability must be a float from 0.0 to 1.0, "%f" given.', __METHOD__, $this->options['gcProbability']));
140140
}
141141

142142
if ($this->initialTtl <= 0) {
143-
throw new InvalidTtlException(sprintf('"%s()" expects a strictly positive TTL, got "%d".', __METHOD__, $this->initialTtl));
143+
throw new InvalidTtlException(\sprintf('"%s()" expects a strictly positive TTL, got "%d".', __METHOD__, $this->initialTtl));
144144
}
145145
}
146146

@@ -154,11 +154,11 @@ public function __construct(Collection|Database|Client|Manager|string $mongo, ar
154154
private function skimUri(string $uri): string
155155
{
156156
if (!str_starts_with($uri, 'mongodb://') && !str_starts_with($uri, 'mongodb+srv://')) {
157-
throw new InvalidArgumentException(sprintf('The given MongoDB Connection URI "%s" is invalid. Expecting "mongodb://" or "mongodb+srv://".', $uri));
157+
throw new InvalidArgumentException(\sprintf('The given MongoDB Connection URI "%s" is invalid. Expecting "mongodb://" or "mongodb+srv://".', $uri));
158158
}
159159

160160
if (false === $params = parse_url($uri)) {
161-
throw new InvalidArgumentException(sprintf('The given MongoDB Connection URI "%s" is invalid.', $uri));
161+
throw new InvalidArgumentException(\sprintf('The given MongoDB Connection URI "%s" is invalid.', $uri));
162162
}
163163
$pathDb = ltrim($params['path'] ?? '', '/') ?: null;
164164
if (null !== $pathDb) {

Store/PdoStore.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function __construct(#[\SensitiveParameter] \PDO|string $connOrDsn, #[\Se
7070

7171
if ($connOrDsn instanceof \PDO) {
7272
if (\PDO::ERRMODE_EXCEPTION !== $connOrDsn->getAttribute(\PDO::ATTR_ERRMODE)) {
73-
throw new InvalidArgumentException(sprintf('"%s" requires PDO error mode attribute be set to throw Exceptions (i.e. $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION)).', __METHOD__));
73+
throw new InvalidArgumentException(\sprintf('"%s" requires PDO error mode attribute be set to throw Exceptions (i.e. $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION)).', __METHOD__));
7474
}
7575

7676
$this->conn = $connOrDsn;
@@ -131,7 +131,7 @@ public function save(Key $key)
131131
public function putOffExpiration(Key $key, float $ttl)
132132
{
133133
if ($ttl < 1) {
134-
throw new InvalidTtlException(sprintf('"%s()" expects a TTL greater or equals to 1 second. Got "%s".', __METHOD__, $ttl));
134+
throw new InvalidTtlException(\sprintf('"%s()" expects a TTL greater or equals to 1 second. Got "%s".', __METHOD__, $ttl));
135135
}
136136

137137
$key->reduceLifetime($ttl);
@@ -202,7 +202,7 @@ public function createTable(): void
202202
'pgsql' => "CREATE TABLE $this->table ($this->idCol VARCHAR(64) NOT NULL PRIMARY KEY, $this->tokenCol VARCHAR(64) NOT NULL, $this->expirationCol INTEGER)",
203203
'oci' => "CREATE TABLE $this->table ($this->idCol VARCHAR2(64) NOT NULL PRIMARY KEY, $this->tokenCol VARCHAR2(64) NOT NULL, $this->expirationCol INTEGER)",
204204
'sqlsrv' => "CREATE TABLE $this->table ($this->idCol VARCHAR(64) NOT NULL PRIMARY KEY, $this->tokenCol VARCHAR(64) NOT NULL, $this->expirationCol INTEGER)",
205-
default => throw new \DomainException(sprintf('Creating the lock table is currently not implemented for platform "%s".', $driver)),
205+
default => throw new \DomainException(\sprintf('Creating the lock table is currently not implemented for platform "%s".', $driver)),
206206
};
207207

208208
$this->getConnection()->exec($sql);

0 commit comments

Comments
 (0)