diff --git a/lib/Controller/SettingsController.php b/lib/Controller/SettingsController.php index 9de0c86f2e..d2eebe3a57 100644 --- a/lib/Controller/SettingsController.php +++ b/lib/Controller/SettingsController.php @@ -399,7 +399,7 @@ public function uploadFontFile(): JSONResponse { return new JSONResponse($uploadResult); } return new JSONResponse(['error' => 'No uploaded file'], Http::STATUS_BAD_REQUEST); - } catch (UploadException | NotPermittedException $e) { + } catch (UploadException|NotPermittedException $e) { $this->logger->error('Upload error', ['exception' => $e]); return new JSONResponse(['error' => 'Upload error'], Http::STATUS_BAD_REQUEST); } diff --git a/lib/Controller/TemplateFieldController.php b/lib/Controller/TemplateFieldController.php index 5071ba43b2..92fb3f9b47 100644 --- a/lib/Controller/TemplateFieldController.php +++ b/lib/Controller/TemplateFieldController.php @@ -50,7 +50,7 @@ public function extractFields(int $fileId): DataResponse { return new DataResponse($fields, Http::STATUS_OK); } catch (\Exception $e) { - return new DataResponse(["Unable to extract fields from given file"], Http::STATUS_INTERNAL_SERVER_ERROR); + return new DataResponse(['Unable to extract fields from given file'], Http::STATUS_INTERNAL_SERVER_ERROR); } } @@ -66,7 +66,7 @@ public function fillFields(int $fileId, array $fields, ?string $destination = nu return new DataResponse([], Http::STATUS_OK); } catch (\Exception $e) { - return new DataResponse(["Unable to fill fields into the given file"], Http::STATUS_INTERNAL_SERVER_ERROR); + return new DataResponse(['Unable to fill fields into the given file'], Http::STATUS_INTERNAL_SERVER_ERROR); } } } diff --git a/lib/Controller/WopiController.php b/lib/Controller/WopiController.php index ce8606b1a6..a075a2bc83 100644 --- a/lib/Controller/WopiController.php +++ b/lib/Controller/WopiController.php @@ -179,7 +179,7 @@ public function checkFileInfo($fileId, $access_token) { $share = $this->getShareForWopiToken($wopi); if ($this->permissionManager->shouldWatermark($file, $wopi->getEditorUid(), $share)) { - $email = $user !== null && !$isPublic ? $user->getEMailAddress() : ""; + $email = $user !== null && !$isPublic ? $user->getEMailAddress() : ''; $replacements = [ 'userId' => $wopi->getEditorUid(), 'date' => (new \DateTime())->format('Y-m-d H:i:s'), @@ -335,7 +335,7 @@ public function getFile($fileId, } $fp = $file->fopen('rb'); - $rangeStream = fopen("php://temp", "w+b"); + $rangeStream = fopen('php://temp', 'w+b'); stream_copy_to_stream($fp, $rangeStream, $length, $offset); fclose($fp); @@ -512,7 +512,7 @@ public function postFile(string $fileId, string $access_token): JSONResponse { $wopiLock = $this->request->getHeader('X-WOPI-Lock'); [$fileId, , ] = Helper::parseFileId($fileId); $wopi = $this->wopiMapper->getWopiForToken($access_token); - if ((int) $fileId !== $wopi->getFileid()) { + if ((int)$fileId !== $wopi->getFileid()) { return new JSONResponse([], Http::STATUS_FORBIDDEN); } } catch (UnknownTokenException $e) { diff --git a/lib/Db/WopiMapper.php b/lib/Db/WopiMapper.php index 20968d29f6..de1f640c58 100644 --- a/lib/Db/WopiMapper.php +++ b/lib/Db/WopiMapper.php @@ -158,7 +158,7 @@ public function getWopiForToken( * @return int */ private function calculateNewTokenExpiry(): int { - return $this->timeFactory->getTime() + (int) $this->appConfig->getAppValue('token_ttl'); + return $this->timeFactory->getTime() + (int)$this->appConfig->getAppValue('token_ttl'); } /** diff --git a/lib/Listener/AddContentSecurityPolicyListener.php b/lib/Listener/AddContentSecurityPolicyListener.php index f3c2146be3..62dfec31a2 100644 --- a/lib/Listener/AddContentSecurityPolicyListener.php +++ b/lib/Listener/AddContentSecurityPolicyListener.php @@ -35,7 +35,7 @@ public function handle(Event $event): void { $policy = new EmptyContentSecurityPolicy(); $policy->addAllowedFrameDomain("'self'"); - $policy->addAllowedFrameDomain("nc:"); + $policy->addAllowedFrameDomain('nc:'); if ($this->capabilitiesService->hasWASMSupport()) { $policy->allowEvalWasm(true); @@ -49,7 +49,7 @@ public function handle(Event $event): void { } if ($this->isSettingsPage()) { - $policy->addAllowedConnectDomain("*"); + $policy->addAllowedConnectDomain('*'); } $event->addPolicy($policy); diff --git a/lib/Listener/BeforeGetTemplatesListener.php b/lib/Listener/BeforeGetTemplatesListener.php index 6998443823..359687a374 100644 --- a/lib/Listener/BeforeGetTemplatesListener.php +++ b/lib/Listener/BeforeGetTemplatesListener.php @@ -25,7 +25,7 @@ public function handle(Event $event): void { } foreach($event->getTemplates() as $template) { - $templateFileId = $template->jsonSerialize()["fileid"]; + $templateFileId = $template->jsonSerialize()['fileid']; $fields = $this->templateFieldService->extractFields($templateFileId); $template->setFields($fields); diff --git a/lib/Service/FederationService.php b/lib/Service/FederationService.php index 99305a1332..617d64dec3 100644 --- a/lib/Service/FederationService.php +++ b/lib/Service/FederationService.php @@ -34,7 +34,7 @@ class FederationService { private $cache; /** @var IClientService */ private $clientService; - /** @var LoggerInterface */ + /** @var LoggerInterface */ private $logger; /** @var TrustedServers */ private $trustedServers; diff --git a/lib/Service/FontService.php b/lib/Service/FontService.php index ebb79930c2..5122235adf 100644 --- a/lib/Service/FontService.php +++ b/lib/Service/FontService.php @@ -220,7 +220,7 @@ private function generateFontOverview(ISimpleFile $fontFile): void { imagepng($im, $imageFileResource); imagedestroy($im); } - } catch (\Exception | \Throwable $e) { + } catch (\Exception|\Throwable $e) { // do nothing if there was any kind of error during overview generation // the /apps/richdocuments/settings/fonts/FILE_NAME/overview request will fail with 404 // in the UI and display a fallback message diff --git a/lib/Service/TemplateFieldService.php b/lib/Service/TemplateFieldService.php index 112196c4a6..d9cfad8d38 100644 --- a/lib/Service/TemplateFieldService.php +++ b/lib/Service/TemplateFieldService.php @@ -52,7 +52,7 @@ public function extractFields(Node|int $file): array { } $localCache = $this->cacheFactory->createLocal('richdocuments_templates/'); - $cacheName = $file->getId() . "/" . $file->getEtag(); + $cacheName = $file->getId() . '/' . $file->getEtag(); $cachedResponse = $localCache->get($cacheName); if ($cachedResponse !== null) { @@ -81,7 +81,7 @@ public function extractFields(Node|int $file): array { ]]; $response = $httpClient->post( - $collaboraUrl . "/cool/extract-document-structure", + $collaboraUrl . '/cool/extract-document-structure', $form ); @@ -97,11 +97,11 @@ public function extractFields(Node|int $file): array { $fields[] = [ new Field( $index, - $attr["content"], + $attr['content'], $fieldType, - $attr["alias"], - $attr["id"], - $attr["tag"] + $attr['alias'], + $attr['id'], + $attr['tag'] ) ]; } diff --git a/tests/features/bootstrap/RichDocumentsContext.php b/tests/features/bootstrap/RichDocumentsContext.php index e20c858c3a..b5b32cb294 100644 --- a/tests/features/bootstrap/RichDocumentsContext.php +++ b/tests/features/bootstrap/RichDocumentsContext.php @@ -26,7 +26,7 @@ class RichDocumentsContext implements Context { public $currentServer; public $fileId; public $wopiToken; - /** @var array List of opened file ids in order to compare opening accross instances*/ + /** @var array List of opened file ids in order to compare opening accross instances */ private $fileIds = []; /** @var array List of templates fetched for a given file type */ private $templates = []; diff --git a/tests/lib/Listener/AddContentSecurityPolicyListenerTest.php b/tests/lib/Listener/AddContentSecurityPolicyListenerTest.php index 514a94da5f..f9787882c7 100644 --- a/tests/lib/Listener/AddContentSecurityPolicyListenerTest.php +++ b/tests/lib/Listener/AddContentSecurityPolicyListenerTest.php @@ -94,8 +94,8 @@ public function testHandle() { $policy = $this->getMergedPolicy(); - self::assertEquals(["'self'", "nc:" , "http://public"], $policy->getAllowedFrameDomains()); - self::assertEquals(["'self'", "http://public"], $policy->getAllowedFormActionDomains()); + self::assertEquals(["'self'", 'nc:' , 'http://public'], $policy->getAllowedFrameDomains()); + self::assertEquals(["'self'", 'http://public'], $policy->getAllowedFormActionDomains()); } public function testHandleRemote() { @@ -121,7 +121,7 @@ public function testNotSetup() { $policy = $this->getMergedPolicy(); - self::assertEquals(["'self'", "nc:"], $policy->getAllowedFrameDomains()); + self::assertEquals(["'self'", 'nc:'], $policy->getAllowedFrameDomains()); self::assertEquals(["'self'"], $policy->getAllowedFormActionDomains()); } @@ -133,8 +133,8 @@ public function testWopiUrlPublic() { $policy = $this->getMergedPolicy(); - self::assertEquals(["'self'", "nc:", "http://public"], $policy->getAllowedFrameDomains()); - self::assertEquals(["'self'", "http://public"], $policy->getAllowedFormActionDomains()); + self::assertEquals(["'self'", 'nc:', 'http://public'], $policy->getAllowedFrameDomains()); + self::assertEquals(["'self'", 'http://public'], $policy->getAllowedFormActionDomains()); } public function testWopiUrl() { @@ -145,8 +145,8 @@ public function testWopiUrl() { $policy = $this->getMergedPolicy(); - self::assertEquals(["'self'", "nc:", "https://public"], $policy->getAllowedFrameDomains()); - self::assertEquals(["'self'", "https://public"], $policy->getAllowedFormActionDomains()); + self::assertEquals(["'self'", 'nc:', 'https://public'], $policy->getAllowedFrameDomains()); + self::assertEquals(["'self'", 'https://public'], $policy->getAllowedFormActionDomains()); } public function testGS() { @@ -163,8 +163,8 @@ public function testGS() { $policy = $this->getMergedPolicy(); - self::assertEquals(["'self'", "nc:", "https://public", "*.example.com"], $policy->getAllowedFrameDomains()); - self::assertEquals(["'self'", "https://public", "*.example.com"], $policy->getAllowedFormActionDomains()); + self::assertEquals(["'self'", 'nc:', 'https://public', '*.example.com'], $policy->getAllowedFrameDomains()); + self::assertEquals(["'self'", 'https://public', '*.example.com'], $policy->getAllowedFormActionDomains()); } public function testNoGS() { @@ -178,8 +178,8 @@ public function testNoGS() { $policy = $this->getMergedPolicy(); - self::assertEquals(["'self'", "nc:", "http://internal"], $policy->getAllowedFrameDomains()); - self::assertEquals(["'self'", "http://internal"], $policy->getAllowedFormActionDomains()); + self::assertEquals(["'self'", 'nc:', 'http://internal'], $policy->getAllowedFrameDomains()); + self::assertEquals(["'self'", 'http://internal'], $policy->getAllowedFormActionDomains()); } public function testHandleMerged() { @@ -203,8 +203,8 @@ public function testHandleMerged() { $policy = $manager->getDefaultPolicy(); - self::assertArrayUnordered(["'self'", "external.example.com", "http://public", "nc:"], $policy->getAllowedFrameDomains(), "Domains are equal", 0.0, 10, true); - self::assertArrayUnordered(["'self'", "external.example.com", "http://public"], $policy->getAllowedFormActionDomains()); + self::assertArrayUnordered(["'self'", 'external.example.com', 'http://public', 'nc:'], $policy->getAllowedFrameDomains(), 'Domains are equal', 0.0, 10, true); + self::assertArrayUnordered(["'self'", 'external.example.com', 'http://public'], $policy->getAllowedFormActionDomains()); } public static function assertArrayUnordered($expected, $actual, $msg = '') {