diff --git a/composer.lock b/composer.lock index 7a6fcc63..bb95c00c 100644 --- a/composer.lock +++ b/composer.lock @@ -77,6 +77,52 @@ ], "time": "2022-12-30T00:23:10+00:00" }, + { + "name": "kubawerlos/php-cs-fixer-custom-fixers", + "version": "v3.22.0", + "source": { + "type": "git", + "url": "https://github.com/kubawerlos/php-cs-fixer-custom-fixers.git", + "reference": "8701394f0c7cd450ac4fa577d24589122c1d5d5e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/kubawerlos/php-cs-fixer-custom-fixers/zipball/8701394f0c7cd450ac4fa577d24589122c1d5d5e", + "reference": "8701394f0c7cd450ac4fa577d24589122c1d5d5e", + "shasum": "" + }, + "require": { + "ext-filter": "*", + "ext-tokenizer": "*", + "friendsofphp/php-cs-fixer": "^3.61.1", + "php": "^7.4 || ^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.6.4 || ^10.5.29" + }, + "type": "library", + "autoload": { + "psr-4": { + "PhpCsFixerCustomFixers\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kuba Werłos", + "email": "werlos@gmail.com" + } + ], + "description": "A set of custom fixers for PHP CS Fixer", + "support": { + "issues": "https://github.com/kubawerlos/php-cs-fixer-custom-fixers/issues", + "source": "https://github.com/kubawerlos/php-cs-fixer-custom-fixers/tree/v3.22.0" + }, + "time": "2024-08-16T20:44:35+00:00" + }, { "name": "myclabs/deep-copy", "version": "1.12.0", @@ -139,19 +185,20 @@ }, { "name": "nextcloud/coding-standard", - "version": "v1.2.1", + "version": "v1.3.2", "source": { "type": "git", "url": "https://github.com/nextcloud/coding-standard.git", - "reference": "cf5f18d989ec62fb4cdc7fc92a36baf34b3d829e" + "reference": "9c719c4747fa26efc12f2e8b21c14a9a75c6ba6d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nextcloud/coding-standard/zipball/cf5f18d989ec62fb4cdc7fc92a36baf34b3d829e", - "reference": "cf5f18d989ec62fb4cdc7fc92a36baf34b3d829e", + "url": "https://api.github.com/repos/nextcloud/coding-standard/zipball/9c719c4747fa26efc12f2e8b21c14a9a75c6ba6d", + "reference": "9c719c4747fa26efc12f2e8b21c14a9a75c6ba6d", "shasum": "" }, "require": { + "kubawerlos/php-cs-fixer-custom-fixers": "^3.22", "php": "^7.3|^8.0", "php-cs-fixer/shim": "^3.17" }, @@ -174,9 +221,9 @@ "description": "Nextcloud coding standards for the php cs fixer", "support": { "issues": "https://github.com/nextcloud/coding-standard/issues", - "source": "https://github.com/nextcloud/coding-standard/tree/v1.2.1" + "source": "https://github.com/nextcloud/coding-standard/tree/v1.3.2" }, - "time": "2024-02-01T14:54:37+00:00" + "time": "2024-10-14T16:49:05+00:00" }, { "name": "nextcloud/ocp", @@ -401,16 +448,16 @@ }, { "name": "php-cs-fixer/shim", - "version": "v3.62.0", + "version": "v3.64.0", "source": { "type": "git", "url": "https://github.com/PHP-CS-Fixer/shim.git", - "reference": "7a91d5ce45c486f5b445d95901228507a02f60ae" + "reference": "81ccfd24baf3a10810dab1152c403981a790b837" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/shim/zipball/7a91d5ce45c486f5b445d95901228507a02f60ae", - "reference": "7a91d5ce45c486f5b445d95901228507a02f60ae", + "url": "https://api.github.com/repos/PHP-CS-Fixer/shim/zipball/81ccfd24baf3a10810dab1152c403981a790b837", + "reference": "81ccfd24baf3a10810dab1152c403981a790b837", "shasum": "" }, "require": { @@ -447,9 +494,9 @@ "description": "A tool to automatically fix PHP code style", "support": { "issues": "https://github.com/PHP-CS-Fixer/shim/issues", - "source": "https://github.com/PHP-CS-Fixer/shim/tree/v3.62.0" + "source": "https://github.com/PHP-CS-Fixer/shim/tree/v3.64.0" }, - "time": "2024-08-07T17:03:46+00:00" + "time": "2024-08-30T23:10:11+00:00" }, { "name": "phpunit/php-code-coverage", diff --git a/lib/Command/Lock.php b/lib/Command/Lock.php index ee20d734..46c1eba7 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 745d5abe..4387749c 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 f72a56d8..9cfebd88 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 de0bdc76..21008bed 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 97dc6114..5680c044 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 2fb3170d..60bd110b 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 7f31b845..a8fe025b 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 83aa2adc..4e35c7dd 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 51f30728..7f45f405 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 8722ea25..4d74ba0f 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 386b2cf4..cfc1818d 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;