diff --git a/composer.lock b/composer.lock index d750bbe..6c203e5 100644 --- a/composer.lock +++ b/composer.lock @@ -69,16 +69,16 @@ }, { "name": "nextcloud/coding-standard", - "version": "v1.2.1", + "version": "v1.2.3", "source": { "type": "git", "url": "https://github.com/nextcloud/coding-standard.git", - "reference": "cf5f18d989ec62fb4cdc7fc92a36baf34b3d829e" + "reference": "bc9c53a5306114b60c4363057aff9c2ed10a54da" }, "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/bc9c53a5306114b60c4363057aff9c2ed10a54da", + "reference": "bc9c53a5306114b60c4363057aff9c2ed10a54da", "shasum": "" }, "require": { @@ -104,9 +104,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.2.3" }, - "time": "2024-02-01T14:54:37+00:00" + "time": "2024-08-23T14:32:32+00:00" }, { "name": "nextcloud/ocp", @@ -331,16 +331,16 @@ }, { "name": "php-cs-fixer/shim", - "version": "v3.60.0", + "version": "v3.62.0", "source": { "type": "git", "url": "https://github.com/PHP-CS-Fixer/shim.git", - "reference": "11f328afa9768eed89bacffab02f56263185058c" + "reference": "7a91d5ce45c486f5b445d95901228507a02f60ae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/shim/zipball/11f328afa9768eed89bacffab02f56263185058c", - "reference": "11f328afa9768eed89bacffab02f56263185058c", + "url": "https://api.github.com/repos/PHP-CS-Fixer/shim/zipball/7a91d5ce45c486f5b445d95901228507a02f60ae", + "reference": "7a91d5ce45c486f5b445d95901228507a02f60ae", "shasum": "" }, "require": { @@ -377,9 +377,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.60.0" + "source": "https://github.com/PHP-CS-Fixer/shim/tree/v3.62.0" }, - "time": "2024-07-25T09:27:32+00:00" + "time": "2024-08-07T17:03:46+00:00" }, { "name": "phpunit/php-code-coverage", diff --git a/lib/Operation.php b/lib/Operation.php index afb6d0d..ce4cf35 100644 --- a/lib/Operation.php +++ b/lib/Operation.php @@ -138,7 +138,7 @@ protected function translatePath(IStorage $storage, string $path): string { return 'files/' . $innerPath; } elseif ($folder === 'thumbnails') { [$fileId,] = explode('/', $innerPath, 2); - $innerPath = $storage->getCache()->getPathById((int) $fileId); + $innerPath = $storage->getCache()->getPathById((int)$fileId); if ($innerPath !== null) { return 'files/' . $innerPath; diff --git a/tests/Integration/features/bootstrap/FeatureContext.php b/tests/Integration/features/bootstrap/FeatureContext.php index 5845fe3..14c5db3 100644 --- a/tests/Integration/features/bootstrap/FeatureContext.php +++ b/tests/Integration/features/bootstrap/FeatureContext.php @@ -124,7 +124,7 @@ public function theWebdavResponseShouldHaveAStatusCode($statusCode) { if (str_contains($statusCode, '|')) { $statusCodes = array_map('intval', explode('|', $statusCode)); } else { - $statusCodes = [(int) $statusCode]; + $statusCodes = [(int)$statusCode]; } if (!in_array($this->response->getStatusCode(), $statusCodes, true)) { throw new \Exception("Expected $statusCode, got ".$this->response->getStatusCode()); diff --git a/tests/Integration/features/bootstrap/WebDav.php b/tests/Integration/features/bootstrap/WebDav.php index adb2ead..3ba070d 100644 --- a/tests/Integration/features/bootstrap/WebDav.php +++ b/tests/Integration/features/bootstrap/WebDav.php @@ -11,7 +11,7 @@ trait WebDav { /** @var string */ - private $davPath = "remote.php/webdav"; + private $davPath = 'remote.php/webdav'; /** @var boolean */ private $usingOldDavPath = true; /** @var array map with user as key and another map as value, which has path as key and etag as value */ @@ -30,7 +30,7 @@ public function usingDavPath($davPath) { * @Given /^using old dav path$/ */ public function usingOldDavPath() { - $this->davPath = "remote.php/webdav"; + $this->davPath = 'remote.php/webdav'; $this->usingOldDavPath = true; } @@ -38,7 +38,7 @@ public function usingOldDavPath() { * @Given /^using new dav path$/ */ public function usingNewDavPath() { - $this->davPath = "remote.php/dav"; + $this->davPath = 'remote.php/dav'; $this->usingOldDavPath = false; } @@ -50,10 +50,10 @@ public function getDavFilesPath($user) { } } - public function makeDavRequest($user, $method, $path, $headers, $body = null, $type = "files") { - if ($type === "files") { + public function makeDavRequest($user, $method, $path, $headers, $body = null, $type = 'files') { + if ($type === 'files') { $fullUrl = $this->baseUrl . $this->getDavFilesPath($user) . "$path"; - } elseif ($type === "uploads") { + } elseif ($type === 'uploads') { $fullUrl = $this->baseUrl . $this->davPath . "$path"; } else { $fullUrl = $this->baseUrl . $this->davPath . '/' . $type . "$path"; @@ -80,7 +80,7 @@ public function makeDavRequest($user, $method, $path, $headers, $body = null, $t public function userMovedFile($user, $entry, $fileSource, $fileDestination) { $fullUrl = $this->baseUrl . $this->getDavFilesPath($user); $headers['Destination'] = $fullUrl . $fileDestination; - $this->response = $this->makeDavRequest($user, "MOVE", $fileSource, $headers); + $this->response = $this->makeDavRequest($user, 'MOVE', $fileSource, $headers); Assert::assertEquals(201, $this->response->getStatusCode()); } @@ -94,7 +94,7 @@ public function userMovesFile($user, $entry, $fileSource, $fileDestination) { $fullUrl = $this->baseUrl . $this->getDavFilesPath($user); $headers['Destination'] = $fullUrl . $fileDestination; try { - $this->response = $this->makeDavRequest($user, "MOVE", $fileSource, $headers); + $this->response = $this->makeDavRequest($user, 'MOVE', $fileSource, $headers); } catch (\GuzzleHttp\Exception\ClientException $e) { $this->response = $e->getResponse(); } @@ -126,7 +126,7 @@ public function userCopiesFileTo($user, $entry, $fileSource, $fileDestination) { public function downloadFileWithRange($fileSource, $range) { $headers['Range'] = $range; try { - $this->response = $this->makeDavRequest($this->currentUser, "GET", $fileSource, $headers); + $this->response = $this->makeDavRequest($this->currentUser, 'GET', $fileSource, $headers); } catch (\GuzzleHttp\Exception\ClientException $e) { $this->response = $e->getResponse(); } @@ -138,16 +138,16 @@ public function downloadFileWithRange($fileSource, $range) { */ public function downloadPublicFileWithRange($range) { $token = $this->lastShareData->data->token; - $fullUrl = $this->baseUrl . "public.php/webdav"; + $fullUrl = $this->baseUrl . 'public.php/webdav'; $client = new GClient(); $options = []; - $options['auth'] = [$token, ""]; + $options['auth'] = [$token, '']; $options['headers'] = [ 'Range' => $range ]; - $this->response = $client->request("GET", $fullUrl, $options); + $this->response = $client->request('GET', $fullUrl, $options); } /** @@ -156,7 +156,7 @@ public function downloadPublicFileWithRange($range) { */ public function downloadPublicFileInsideAFolderWithRange($path, $range) { $token = $this->lastShareData->data->token; - $fullUrl = $this->baseUrl . "public.php/webdav" . "$path"; + $fullUrl = $this->baseUrl . 'public.php/webdav' . "$path"; $client = new GClient(); $options = [ @@ -164,9 +164,9 @@ public function downloadPublicFileInsideAFolderWithRange($path, $range) { 'Range' => $range ] ]; - $options['auth'] = [$token, ""]; + $options['auth'] = [$token, '']; - $this->response = $client->request("GET", $fullUrl, $options); + $this->response = $client->request('GET', $fullUrl, $options); } /** @@ -314,7 +314,7 @@ public function theSingleResponseShouldContainAPropertyWithValue($key, $expected public function theResponseShouldContainAShareTypesPropertyWith($table) { $keys = $this->response; if (!array_key_exists('{http://owncloud.org/ns}share-types', $keys)) { - throw new \Exception("Cannot find property \"{http://owncloud.org/ns}share-types\""); + throw new \Exception('Cannot find property "{http://owncloud.org/ns}share-types"'); } $foundTypes = []; @@ -481,7 +481,7 @@ public function searchFile(string $user, ?string $properties = null, ?string $sc '; try { - $this->response = $this->makeDavRequest($user, "SEARCH", '', [ + $this->response = $this->makeDavRequest($user, 'SEARCH', '', [ 'Content-Type' => 'text/xml' ], $body, ''); } catch (\GuzzleHttp\Exception\ServerException $e) { @@ -555,9 +555,9 @@ public function checkElementList($user, $expectedElements) { $elementRows = $expectedElements->getRows(); $elementsSimplified = $this->simplifyArray($elementRows); foreach ($elementsSimplified as $expectedElement) { - $webdavPath = "/" . $this->getDavFilesPath($user) . $expectedElement; + $webdavPath = '/' . $this->getDavFilesPath($user) . $expectedElement; if (!array_key_exists($webdavPath, $elementList)) { - Assert::fail("$webdavPath" . " is not in propfind answer"); + Assert::fail("$webdavPath" . ' is not in propfind answer'); } } } @@ -572,7 +572,7 @@ public function checkElementList($user, $expectedElements) { public function userUploadsAFileTo($user, $source, $destination) { $file = \GuzzleHttp\Psr7\Utils::streamFor(fopen($source, 'r')); try { - $this->response = $this->makeDavRequest($user, "PUT", $destination, [], $file); + $this->response = $this->makeDavRequest($user, 'PUT', $destination, [], $file); } catch (\GuzzleHttp\Exception\ServerException $e) { // 5xx responses cause a server exception $this->response = $e->getResponse(); @@ -589,11 +589,11 @@ public function userUploadsAFileTo($user, $source, $destination) { * @param string $destination */ public function userAddsAFileTo($user, $bytes, $destination) { - $filename = "filespecificSize.txt"; + $filename = 'filespecificSize.txt'; $this->createFileSpecificSize($filename, $bytes); Assert::assertEquals(1, file_exists("work/$filename")); $this->userUploadsAFileTo($user, "work/$filename", $destination); - $this->removeFile("work/", $filename); + $this->removeFile('work/', $filename); $expectedElements = new \Behat\Gherkin\Node\TableNode([["$destination"]]); $this->checkElementList($user, $expectedElements); } @@ -604,7 +604,7 @@ public function userAddsAFileTo($user, $bytes, $destination) { public function userUploadsAFileWithContentTo($user, $content, $destination) { $file = \GuzzleHttp\Psr7\Utils::streamFor($content); try { - $this->response = $this->makeDavRequest($user, "PUT", $destination, [], $file); + $this->response = $this->makeDavRequest($user, 'PUT', $destination, [], $file); } catch (\GuzzleHttp\Exception\ServerException $e) { // 5xx responses cause a server exception $this->response = $e->getResponse(); @@ -650,7 +650,7 @@ public function emptyTrashbin($user) { public function userCreatedAFolder($user, $destination) { try { $destination = '/' . ltrim($destination, '/'); - $this->response = $this->makeDavRequest($user, "MKCOL", $destination, []); + $this->response = $this->makeDavRequest($user, 'MKCOL', $destination, []); } catch (\GuzzleHttp\Exception\ServerException $e) { // 5xx responses cause a server exception $this->response = $e->getResponse(); @@ -672,7 +672,7 @@ public function userUploadsChunkFileOfWithToWithChecksum($user, $num, $total, $d $num -= 1; $data = \GuzzleHttp\Psr7\Utils::streamFor($data); $file = $destination . '-chunking-42-' . $total . '-' . $num; - $this->makeDavRequest($user, 'PUT', $file, ['OC-Chunked' => '1'], $data, "uploads"); + $this->makeDavRequest($user, 'PUT', $file, ['OC-Chunked' => '1'], $data, 'uploads'); } /** @@ -686,28 +686,28 @@ public function userUploadsChunkFileOfWithToWithChecksum($user, $num, $total, $d * @param string $content3 */ public function userUploadsBulkedFiles($user, $name1, $content1, $name2, $content2, $name3, $content3) { - $boundary = "boundary_azertyuiop"; + $boundary = 'boundary_azertyuiop'; - $body = ""; + $body = ''; $body .= '--'.$boundary."\r\n"; - $body .= "X-File-Path: ".$name1."\r\n"; + $body .= 'X-File-Path: '.$name1."\r\n"; $body .= "X-File-MD5: f6a6263167c92de8644ac998b3c4e4d1\r\n"; $body .= "X-OC-Mtime: 1111111111\r\n"; - $body .= "Content-Length: ".strlen($content1)."\r\n"; + $body .= 'Content-Length: '.strlen($content1)."\r\n"; $body .= "\r\n"; $body .= $content1."\r\n"; $body .= '--'.$boundary."\r\n"; - $body .= "X-File-Path: ".$name2."\r\n"; + $body .= 'X-File-Path: '.$name2."\r\n"; $body .= "X-File-MD5: 87c7d4068be07d390a1fffd21bf1e944\r\n"; $body .= "X-OC-Mtime: 2222222222\r\n"; - $body .= "Content-Length: ".strlen($content2)."\r\n"; + $body .= 'Content-Length: '.strlen($content2)."\r\n"; $body .= "\r\n"; $body .= $content2."\r\n"; $body .= '--'.$boundary."\r\n"; - $body .= "X-File-Path: ".$name3."\r\n"; + $body .= 'X-File-Path: '.$name3."\r\n"; $body .= "X-File-MD5: e86a1cf0678099986a901c79086f5617\r\n"; $body .= "X-File-Mtime: 3333333333\r\n"; - $body .= "Content-Length: ".strlen($content3)."\r\n"; + $body .= 'Content-Length: '.strlen($content3)."\r\n"; $body .= "\r\n"; $body .= $content3."\r\n"; $body .= '--'.$boundary."--\r\n"; @@ -726,7 +726,7 @@ public function userUploadsBulkedFiles($user, $name1, $content1, $name2, $conten 'body' => $body ]; - return $client->request("POST", $this->baseUrl . "remote.php/dav/bulk", $options); + return $client->request('POST', $this->baseUrl . 'remote.php/dav/bulk', $options); } /** @@ -734,7 +734,7 @@ public function userUploadsBulkedFiles($user, $name1, $content1, $name2, $conten */ public function userCreatesANewChunkingUploadWithId($user, $id) { $destination = '/uploads/' . $user . '/' . $id; - $this->makeDavRequest($user, 'MKCOL', $destination, [], null, "uploads"); + $this->makeDavRequest($user, 'MKCOL', $destination, [], null, 'uploads'); } /** @@ -743,7 +743,7 @@ public function userCreatesANewChunkingUploadWithId($user, $id) { public function userUploadsNewChunkFileOfWithToId($user, $num, $data, $id) { $data = \GuzzleHttp\Psr7\Utils::streamFor($data); $destination = '/uploads/' . $user . '/' . $id . '/' . $num; - $this->makeDavRequest($user, 'PUT', $destination, [], $data, "uploads"); + $this->makeDavRequest($user, 'PUT', $destination, [], $data, 'uploads'); } /** @@ -754,7 +754,7 @@ public function userMovesNewChunkFileWithIdToMychunkedfile($user, $id, $dest) { $destination = $this->baseUrl . $this->getDavFilesPath($user) . $dest; $this->makeDavRequest($user, 'MOVE', $source, [ 'Destination' => $destination - ], null, "uploads"); + ], null, 'uploads'); } /** @@ -768,7 +768,7 @@ public function userMovesNewChunkFileWithIdToMychunkedfileWithSize($user, $id, $ $this->response = $this->makeDavRequest($user, 'MOVE', $source, [ 'Destination' => $destination, 'OC-Total-Length' => $size - ], null, "uploads"); + ], null, 'uploads'); } catch (\GuzzleHttp\Exception\BadResponseException $ex) { $this->response = $ex->getResponse(); } @@ -906,9 +906,9 @@ public function checkFavoritedElements($user, $folder, $expectedElements) { $elementRows = $expectedElements->getRows(); $elementsSimplified = $this->simplifyArray($elementRows); foreach ($elementsSimplified as $expectedElement) { - $webdavPath = "/" . $this->getDavFilesPath($user) . $expectedElement; + $webdavPath = '/' . $this->getDavFilesPath($user) . $expectedElement; if (!array_key_exists($webdavPath, $elementList)) { - Assert::fail("$webdavPath" . " is not in report answer"); + Assert::fail("$webdavPath" . ' is not in report answer'); } } } @@ -923,12 +923,12 @@ public function userDeletesEverythingInFolder($user, $folder) { $elementList = $this->listFolder($user, $folder, 1); $elementListKeys = array_keys($elementList); array_shift($elementListKeys); - $davPrefix = "/" . $this->getDavFilesPath($user); + $davPrefix = '/' . $this->getDavFilesPath($user); foreach ($elementListKeys as $element) { if (substr($element, 0, strlen($davPrefix)) == $davPrefix) { $element = substr($element, strlen($davPrefix)); } - $this->userDeletesFile($user, "element", $element); + $this->userDeletesFile($user, 'element', $element); } } @@ -963,7 +963,7 @@ public function userSeesNoFilesInTheTrashbin($user) { * @return int */ private function getFileIdForPath($user, $path) { - $propertiesTable = new \Behat\Gherkin\Node\TableNode([["{http://owncloud.org/ns}fileid"]]); + $propertiesTable = new \Behat\Gherkin\Node\TableNode([['{http://owncloud.org/ns}fileid']]); $this->asGetsPropertiesOfFolderWith($user, 'file', $path, $propertiesTable); return (int)$this->response['{http://owncloud.org/ns}fileid']; }