Skip to content

Commit 684533e

Browse files
Use ??= more
1 parent a6d9dd0 commit 684533e

File tree

4 files changed

+4
-10
lines changed

4 files changed

+4
-10
lines changed

Lock.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,7 @@ public function acquireRead(bool $blocking = false): bool
184184

185185
public function refresh(float $ttl = null)
186186
{
187-
if (null === $ttl) {
188-
$ttl = $this->ttl;
189-
}
190-
if (!$ttl) {
187+
if (!$ttl ??= $this->ttl) {
191188
throw new InvalidArgumentException('You have to define an expiration duration.');
192189
}
193190

Store/DoctrineDbalPostgreSqlStore.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,6 @@ private function getInternalStore(): SharedLockStoreInterface
262262
{
263263
$namespace = spl_object_hash($this->conn);
264264

265-
return self::$storeRegistry[$namespace] ?? self::$storeRegistry[$namespace] = new InMemoryStore();
265+
return self::$storeRegistry[$namespace] ??= new InMemoryStore();
266266
}
267267
}

Store/FlockStore.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,7 @@ class FlockStore implements BlockingStoreInterface, SharedLockStoreInterface
3939
*/
4040
public function __construct(string $lockPath = null)
4141
{
42-
if (null === $lockPath) {
43-
$lockPath = sys_get_temp_dir();
44-
}
45-
if (!is_dir($lockPath)) {
42+
if (!is_dir($lockPath ??= sys_get_temp_dir())) {
4643
if (false === @mkdir($lockPath, 0777, true) && !is_dir($lockPath)) {
4744
throw new InvalidArgumentException(sprintf('The FlockStore directory "%s" does not exists and cannot be created.', $lockPath));
4845
}

Store/PostgreSqlStore.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,6 @@ private function getInternalStore(): SharedLockStoreInterface
285285
{
286286
$namespace = spl_object_hash($this->getConnection());
287287

288-
return self::$storeRegistry[$namespace] ?? self::$storeRegistry[$namespace] = new InMemoryStore();
288+
return self::$storeRegistry[$namespace] ??= new InMemoryStore();
289289
}
290290
}

0 commit comments

Comments
 (0)