diff --git a/lib/Command/Lock.php b/lib/Command/Lock.php index ee20d73..46c1eba 100644 --- a/lib/Command/Lock.php +++ b/lib/Command/Lock.php @@ -62,7 +62,7 @@ class Lock extends Base { */ public function __construct( IUserManager $userManager, LocksRequest $locksRequest, FileService $fileService, - LockService $lockService, ConfigService $configService + LockService $lockService, ConfigService $configService, ) { parent::__construct(); @@ -80,14 +80,14 @@ public function __construct( protected function configure() { parent::configure(); $this->setName('files:lock') - ->addOption('unlock', 'u', InputOption::VALUE_NONE, 'unlock a file') - ->addOption( - 'uninstall', '', InputOption::VALUE_NONE, 'fully uninstall the app from your Nextcloud' - ) - ->addOption('status', 's', InputOption::VALUE_NONE, 'returns lock status of the file') - ->addArgument('file_id', InputArgument::OPTIONAL, 'Id of the locked file', 0) - ->addArgument('user_id', InputArgument::OPTIONAL, 'owner of the lock', '') - ->setDescription('lock a file to a user'); + ->addOption('unlock', 'u', InputOption::VALUE_NONE, 'unlock a file') + ->addOption( + 'uninstall', '', InputOption::VALUE_NONE, 'fully uninstall the app from your Nextcloud' + ) + ->addOption('status', 's', InputOption::VALUE_NONE, 'returns lock status of the file') + ->addArgument('file_id', InputArgument::OPTIONAL, 'Id of the locked file', 0) + ->addArgument('user_id', InputArgument::OPTIONAL, 'owner of the lock', '') + ->setDescription('lock a file to a user'); } diff --git a/lib/Controller/LockController.php b/lib/Controller/LockController.php index 745d5ab..4387749 100644 --- a/lib/Controller/LockController.php +++ b/lib/Controller/LockController.php @@ -159,7 +159,7 @@ protected function fail( Exception $e, array $more = [], int $status = Http::STATUS_INTERNAL_SERVER_ERROR, - bool $log = true + bool $log = true, ): DataResponse { $data = array_merge( $more, diff --git a/lib/DAV/LockBackend.php b/lib/DAV/LockBackend.php index f72a56d..9cfebd8 100644 --- a/lib/DAV/LockBackend.php +++ b/lib/DAV/LockBackend.php @@ -26,7 +26,7 @@ class LockBackend implements BackendInterface { public function __construct( private FileService $fileService, private LockService $lockService, - private bool $absolute + private bool $absolute, ) { } diff --git a/lib/DAV/LockPlugin.php b/lib/DAV/LockPlugin.php index de0bdc7..21008be 100644 --- a/lib/DAV/LockPlugin.php +++ b/lib/DAV/LockPlugin.php @@ -84,7 +84,7 @@ private function cacheDirectory(Directory $directory): void { $ids[] = (string)$id; } - $ids[] = (string) $directory->getId(); + $ids[] = (string)$directory->getId(); // the lock service will take care of the caching $this->lockService->getLockForNodeIds($ids); } diff --git a/lib/Db/LocksRequest.php b/lib/Db/LocksRequest.php index 97dc611..5680c04 100644 --- a/lib/Db/LocksRequest.php +++ b/lib/Db/LocksRequest.php @@ -27,11 +27,11 @@ class LocksRequest extends LocksRequestBuilder { public function save(FileLock $lock) { $qb = $this->getLocksInsertSql(); $qb->setValue('user_id', $qb->createNamedParameter($lock->getOwner())) - ->setValue('file_id', $qb->createNamedParameter($lock->getFileId())) - ->setValue('token', $qb->createNamedParameter($lock->getToken())) - ->setValue('creation', $qb->createNamedParameter($lock->getCreatedAt())) - ->setValue('type', $qb->createNamedParameter($lock->getType())) - ->setValue('ttl', $qb->createNamedParameter($lock->getTimeout())); + ->setValue('file_id', $qb->createNamedParameter($lock->getFileId())) + ->setValue('token', $qb->createNamedParameter($lock->getToken())) + ->setValue('creation', $qb->createNamedParameter($lock->getCreatedAt())) + ->setValue('type', $qb->createNamedParameter($lock->getType())) + ->setValue('ttl', $qb->createNamedParameter($lock->getTimeout())); try { $qb->execute(); diff --git a/lib/Db/LocksRequestBuilder.php b/lib/Db/LocksRequestBuilder.php index 2fb3170..60bd110 100644 --- a/lib/Db/LocksRequestBuilder.php +++ b/lib/Db/LocksRequestBuilder.php @@ -67,7 +67,7 @@ protected function getLocksSelectSql(): CoreQueryBuilder { $qb = $this->getQueryBuilder(); $qb->select('l.id', 'l.user_id', 'l.file_id', 'l.token', 'l.creation', 'l.type', 'l.ttl', 'l.owner') - ->from(self::TABLE_LOCKS, 'l'); + ->from(self::TABLE_LOCKS, 'l'); $qb->setDefaultSelectAlias('l'); diff --git a/lib/Service/FileService.php b/lib/Service/FileService.php index 7f31b84..a8fe025 100644 --- a/lib/Service/FileService.php +++ b/lib/Service/FileService.php @@ -45,7 +45,7 @@ public function __construct(IUserSession $userSession, IRootFolder $rootFolder) */ public function getFileFromId(string $userId, int $fileId): Node { $files = $this->rootFolder->getUserFolder($userId) - ->getById($fileId); + ->getById($fileId); if (sizeof($files) === 0) { throw new NotFoundException(); @@ -71,7 +71,7 @@ public function getFileFromPath(string $userId, string $path): Node { $path = '/' . substr($path, 6); $file = $this->rootFolder->getUserFolder($userId) - ->get($path); + ->get($path); return $file; } @@ -93,7 +93,7 @@ public function getFileFromUri(string $uri): Node { $path = '/' . $uri; $file = $this->rootFolder->getUserFolder($userId) - ->get($path); + ->get($path); return $file; } @@ -114,7 +114,7 @@ public function getFileFromAbsoluteUri(string $uri): Node { } $path = '/' . $path; $file = $this->rootFolder->getUserFolder($userId) - ->get($path); + ->get($path); return $file; } diff --git a/lib/Storage/LockWrapper.php b/lib/Storage/LockWrapper.php index 83aa2ad..4e35c7d 100644 --- a/lib/Storage/LockWrapper.php +++ b/lib/Storage/LockWrapper.php @@ -120,7 +120,7 @@ protected function isLocked(string $ownerId, string $path, string $viewerId, &$l return true; } } - } catch (NoLockProviderException | LockNotFoundException | InvalidPathException | NotFoundException $e) { + } catch (NoLockProviderException|LockNotFoundException|InvalidPathException|NotFoundException $e) { } return false; diff --git a/lib/Tools/Db/ExtendedQueryBuilder.php b/lib/Tools/Db/ExtendedQueryBuilder.php index 51f3072..7f45f40 100644 --- a/lib/Tools/Db/ExtendedQueryBuilder.php +++ b/lib/Tools/Db/ExtendedQueryBuilder.php @@ -183,7 +183,7 @@ public function searchInDBField(string $field, string $value): void { * @deprecated - should be removed */ public function exprFieldWithinJsonFormat( - IQueryBuilder $qb, string $field, string $fieldRight, string $alias = '' + IQueryBuilder $qb, string $field, string $fieldRight, string $alias = '', ): string { $func = $qb->func(); $expr = $qb->expr(); @@ -212,7 +212,7 @@ public function exprFieldWithinJsonFormat( * @deprecated - should be removed */ public function exprValueWithinJsonFormat( - IQueryBuilder $qb, string $field, string $value, bool $eq = true, bool $cs = true + IQueryBuilder $qb, string $field, string $value, bool $eq = true, bool $cs = true, ): string { $dbConn = $this->getConnection(); $expr = $qb->expr(); @@ -434,7 +434,7 @@ public function exprLimitBool(string $field, bool $value, string $alias = ''): s public function exprLimitEmpty( string $field, bool $orNull = false, - string $alias = '' + string $alias = '', ): ICompositeExpression { if ($this->getType() === DBALQueryBuilder::SELECT) { $field = (($alias === '') ? $this->getDefaultSelectAlias() : $alias) . '.' . $field; @@ -460,7 +460,7 @@ public function exprLimitEmpty( public function exprLimitNull( string $field, bool $orEmpty = false, - string $alias = '' + string $alias = '', ): ICompositeExpression { if ($this->getType() === DBALQueryBuilder::SELECT) { $field = (($alias === '') ? $this->getDefaultSelectAlias() : $alias) . '.' . $field; @@ -489,7 +489,7 @@ public function exprLimitArray( string $field, array $values, string $alias = '', - bool $cs = true + bool $cs = true, ): ICompositeExpression { if ($this->getType() === DBALQueryBuilder::SELECT) { $field = (($alias === '') ? $this->getDefaultSelectAlias() : $alias) . '.' . $field; @@ -785,7 +785,7 @@ public function exprFilterBool(string $field, bool $value, string $alias = ''): public function exprFilterEmpty( string $field, bool $norNull = false, - string $alias = '' + string $alias = '', ): ICompositeExpression { if ($this->getType() === DBALQueryBuilder::SELECT) { $field = (($alias === '') ? $this->getDefaultSelectAlias() : $alias) . '.' . $field; @@ -811,7 +811,7 @@ public function exprFilterEmpty( public function exprFilterNull( string $field, bool $norEmpty = false, - string $alias = '' + string $alias = '', ): ICompositeExpression { if ($this->getType() === DBALQueryBuilder::SELECT) { $field = (($alias === '') ? $this->getDefaultSelectAlias() : $alias) . '.' . $field; @@ -840,7 +840,7 @@ public function exprFilterArray( string $field, array $values, string $alias = '', - bool $cs = true + bool $cs = true, ): ICompositeExpression { if ($this->getType() === DBALQueryBuilder::SELECT) { $field = (($alias === '') ? $this->getDefaultSelectAlias() : $alias) . '.' . $field; @@ -933,7 +933,7 @@ private function parseSimpleSelectSql( array $data, ExtendedQueryBuilder $qb, string $object, - array $params + array $params, ): IQueryRow { $fromField = $this->get('modelFromField', $params); if ($fromField !== '') { @@ -1010,7 +1010,7 @@ public function generateSelect( string $table, array $fields, string $alias = '', - bool $distinct = false + bool $distinct = false, ): self { $selectFields = array_map( function (string $item) use ($alias) { @@ -1029,7 +1029,7 @@ function (string $item) use ($alias) { } $this->from($table, $alias) - ->setDefaultSelectAlias($alias); + ->setDefaultSelectAlias($alias); return $this; } @@ -1047,7 +1047,7 @@ public function generateSelectAlias( array $fields, string $alias, string $prefix, - array $default = [] + array $default = [], ): self { $prefix = trim($prefix) . '_'; $grouping = true; diff --git a/lib/Tools/Traits/TLogger.php b/lib/Tools/Traits/TLogger.php index 8722ea2..4d74ba0 100644 --- a/lib/Tools/Traits/TLogger.php +++ b/lib/Tools/Traits/TLogger.php @@ -51,14 +51,14 @@ public function throwable(Throwable $t, int $level = 3, array $serializable = [] } $this->logger() - ->log( - $level, - $message, - [ - 'app' => $this->setup('app'), - 'exception' => $t - ] - ); + ->log( + $level, + $message, + [ + 'app' => $this->setup('app'), + 'exception' => $t + ] + ); } @@ -91,14 +91,14 @@ public function exception(Exception $e, $level = 3, array $serializable = []): v } $this->logger() - ->log( - $level, - $message, - [ - 'app' => $this->setup('app'), - 'exception' => $e - ] - ); + ->log( + $level, + $message, + [ + 'app' => $this->setup('app'), + 'exception' => $e + ] + ); } @@ -164,7 +164,7 @@ public function log(int $level, string $message, bool $trace = false, array $ser } $this->logger() - ->log($level, $message, $opts); + ->log($level, $message, $opts); } diff --git a/tests/Feature/LockFeatureTest.php b/tests/Feature/LockFeatureTest.php index 386b2cf..cfc1818 100644 --- a/tests/Feature/LockFeatureTest.php +++ b/tests/Feature/LockFeatureTest.php @@ -27,8 +27,8 @@ * @group DB */ class LockFeatureTest extends TestCase { - public const TEST_USER1 = "test-user1"; - public const TEST_USER2 = "test-user2"; + public const TEST_USER1 = 'test-user1'; + public const TEST_USER2 = 'test-user2'; protected LockManager $lockManager; protected IRootFolder $rootFolder;