diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2018-01-16 19:34:43 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2018-01-16 21:54:20 +0100 |
commit | 8edbfdb29173a97f6fd265bad234ec458b72bf40 (patch) | |
tree | dd44453cf41fae4d8453ce3738ae9c8dae57d619 /lib/private/Lock/MemcacheLockingProvider.php | |
parent | 13a787e2f5d22e4cd8204f4524ea3e2c4eba4d32 (diff) | |
download | nextcloud-server-8edbfdb29173a97f6fd265bad234ec458b72bf40.tar.gz nextcloud-server-8edbfdb29173a97f6fd265bad234ec458b72bf40.zip |
Made locking providers strict
* Added typehints
* Added return types
* Made strict
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib/private/Lock/MemcacheLockingProvider.php')
-rw-r--r-- | lib/private/Lock/MemcacheLockingProvider.php | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/private/Lock/MemcacheLockingProvider.php b/lib/private/Lock/MemcacheLockingProvider.php index c4b1469b50f..70ad972b46d 100644 --- a/lib/private/Lock/MemcacheLockingProvider.php +++ b/lib/private/Lock/MemcacheLockingProvider.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); /** * @copyright Copyright (c) 2016, ownCloud, Inc. * @@ -36,12 +37,12 @@ class MemcacheLockingProvider extends AbstractLockingProvider { * @param \OCP\IMemcache $memcache * @param int $ttl */ - public function __construct(IMemcache $memcache, $ttl = 3600) { + public function __construct(IMemcache $memcache, int $ttl = 3600) { $this->memcache = $memcache; $this->ttl = $ttl; } - private function setTTL($path) { + private function setTTL(string $path) { if ($this->memcache instanceof IMemcacheTTL) { $this->memcache->setTTL($path, $this->ttl); } @@ -52,7 +53,7 @@ class MemcacheLockingProvider extends AbstractLockingProvider { * @param int $type self::LOCK_SHARED or self::LOCK_EXCLUSIVE * @return bool */ - public function isLocked($path, $type) { + public function isLocked(string $path, int $type): bool { $lockValue = $this->memcache->get($path); if ($type === self::LOCK_SHARED) { return $lockValue > 0; @@ -68,7 +69,7 @@ class MemcacheLockingProvider extends AbstractLockingProvider { * @param int $type self::LOCK_SHARED or self::LOCK_EXCLUSIVE * @throws \OCP\Lock\LockedException */ - public function acquireLock($path, $type) { + public function acquireLock(string $path, int $type) { if ($type === self::LOCK_SHARED) { if (!$this->memcache->inc($path)) { throw new LockedException($path); @@ -87,7 +88,7 @@ class MemcacheLockingProvider extends AbstractLockingProvider { * @param string $path * @param int $type self::LOCK_SHARED or self::LOCK_EXCLUSIVE */ - public function releaseLock($path, $type) { + public function releaseLock(string $path, int $type) { if ($type === self::LOCK_SHARED) { if ($this->getOwnSharedLockCount($path) === 1) { $removed = $this->memcache->cad($path, 1); // if we're the only one having a shared lock we can remove it in one go @@ -111,7 +112,7 @@ class MemcacheLockingProvider extends AbstractLockingProvider { * @param int $targetType self::LOCK_SHARED or self::LOCK_EXCLUSIVE * @throws \OCP\Lock\LockedException */ - public function changeLock($path, $targetType) { + public function changeLock(string $path, int $targetType) { if ($targetType === self::LOCK_SHARED) { if (!$this->memcache->cas($path, 'exclusive', 1)) { throw new LockedException($path); |