Skip to content

Commit abb85cd

Browse files
committed
Leverage non-capturing catches
1 parent e0ec901 commit abb85cd

File tree

7 files changed

+14
-14
lines changed

7 files changed

+14
-14
lines changed

Lock.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function acquire(bool $blocking = false): bool
8484
try {
8585
$this->store->save($this->key);
8686
break;
87-
} catch (LockConflictedException $e) {
87+
} catch (LockConflictedException) {
8888
usleep((100 + random_int(-10, 10)) * 1000);
8989
}
9090
}
@@ -105,7 +105,7 @@ public function acquire(bool $blocking = false): bool
105105
if ($this->key->isExpired()) {
106106
try {
107107
$this->release();
108-
} catch (\Exception $e) {
108+
} catch (\Exception) {
109109
// swallow exception to not hide the original issue
110110
}
111111
throw new LockExpiredException(sprintf('Failed to store the "%s" lock.', $this->key));
@@ -145,7 +145,7 @@ public function acquireRead(bool $blocking = false): bool
145145
try {
146146
$this->store->saveRead($this->key);
147147
break;
148-
} catch (LockConflictedException $e) {
148+
} catch (LockConflictedException) {
149149
usleep((100 + random_int(-10, 10)) * 1000);
150150
}
151151
}
@@ -166,7 +166,7 @@ public function acquireRead(bool $blocking = false): bool
166166
if ($this->key->isExpired()) {
167167
try {
168168
$this->release();
169-
} catch (\Exception $e) {
169+
} catch (\Exception) {
170170
// swallow exception to not hide the original issue
171171
}
172172
throw new LockExpiredException(sprintf('Failed to store the "%s" lock.', $this->key));
@@ -208,7 +208,7 @@ public function refresh(float $ttl = null)
208208
if ($this->key->isExpired()) {
209209
try {
210210
$this->release();
211-
} catch (\Exception $e) {
211+
} catch (\Exception) {
212212
// swallow exception to not hide the original issue
213213
}
214214
throw new LockExpiredException(sprintf('Failed to put off the expiration of the "%s" lock within the specified time.', $this->key));

Store/DoctrineDbalPostgreSqlStore.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public function delete(Key $key)
141141
// If lock acquired = there is no other ReadLock
142142
$store->save($key);
143143
$this->unlockShared($key);
144-
} catch (LockConflictedException $e) {
144+
} catch (LockConflictedException) {
145145
// an other key exists in this ReadLock
146146
}
147147

Store/DoctrineDbalStore.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function save(Key $key)
8989
ParameterType::STRING,
9090
ParameterType::STRING,
9191
]);
92-
} catch (TableNotFoundException $e) {
92+
} catch (TableNotFoundException) {
9393
if (!$this->conn->isTransactionActive() || $this->platformSupportsTableCreationInTransaction()) {
9494
$this->createTable();
9595
}
@@ -102,10 +102,10 @@ public function save(Key $key)
102102
ParameterType::STRING,
103103
ParameterType::STRING,
104104
]);
105-
} catch (DBALException $e) {
105+
} catch (DBALException) {
106106
$this->putOffExpiration($key, $this->initialTtl);
107107
}
108-
} catch (DBALException $e) {
108+
} catch (DBALException) {
109109
// the lock is already acquired. It could be us. Let's try to put off.
110110
$this->putOffExpiration($key, $this->initialTtl);
111111
}

Store/ExpiringStoreTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ private function checkNotExpired(Key $key)
2121
if ($key->isExpired()) {
2222
try {
2323
$this->delete($key);
24-
} catch (\Exception $e) {
24+
} catch (\Exception) {
2525
// swallow exception to not hide the original issue
2626
}
2727
throw new LockExpiredException(sprintf('Failed to store the "%s" lock.', $key));

Store/PdoStore.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function save(Key $key)
9494
$conn = $this->getConnection();
9595
try {
9696
$stmt = $conn->prepare($sql);
97-
} catch (\PDOException $e) {
97+
} catch (\PDOException) {
9898
if (!$conn->inTransaction() || \in_array($this->driver, ['pgsql', 'sqlite', 'sqlsrv'], true)) {
9999
$this->createTable();
100100
}
@@ -106,7 +106,7 @@ public function save(Key $key)
106106

107107
try {
108108
$stmt->execute();
109-
} catch (\PDOException $e) {
109+
} catch (\PDOException) {
110110
// the lock is already acquired. It could be us. Let's try to put off.
111111
$this->putOffExpiration($key, $this->initialTtl);
112112
}

Store/PostgreSqlStore.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public function delete(Key $key)
156156
// If lock acquired = there is no other ReadLock
157157
$store->save($key);
158158
$this->unlockShared($key);
159-
} catch (LockConflictedException $e) {
159+
} catch (LockConflictedException) {
160160
// an other key exists in this ReadLock
161161
}
162162

Store/ZookeeperStore.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function exists(Key $key): bool
100100
$resource = $this->getKeyResource($key);
101101
try {
102102
return $this->zookeeper->get($resource) === $this->getUniqueToken($key);
103-
} catch (\ZookeeperException $ex) {
103+
} catch (\ZookeeperException) {
104104
return false;
105105
}
106106
}

0 commit comments

Comments
 (0)