Skip to content

Commit

Permalink
chore(php-cs): Fix php code style
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliushaertl committed Aug 26, 2024
1 parent e744363 commit 52cc761
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion lib/Controller/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Controller/TemplateFieldController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand All @@ -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);
}
}
}
6 changes: 3 additions & 3 deletions lib/Controller/WopiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Db/WopiMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/Listener/AddContentSecurityPolicyListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -49,7 +49,7 @@ public function handle(Event $event): void {
}

if ($this->isSettingsPage()) {
$policy->addAllowedConnectDomain("*");
$policy->addAllowedConnectDomain('*');
}

$event->addPolicy($policy);
Expand Down
2 changes: 1 addition & 1 deletion lib/Listener/BeforeGetTemplatesListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/FederationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class FederationService {
private $cache;
/** @var IClientService */
private $clientService;
/** @var LoggerInterface */
/** @var LoggerInterface */
private $logger;
/** @var TrustedServers */
private $trustedServers;
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/FontService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions lib/Service/TemplateFieldService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
);

Expand All @@ -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']
)
];
}
Expand Down
2 changes: 1 addition & 1 deletion tests/features/bootstrap/RichDocumentsContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down
26 changes: 13 additions & 13 deletions tests/lib/Listener/AddContentSecurityPolicyListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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());
}

Expand All @@ -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() {
Expand All @@ -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() {
Expand All @@ -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() {
Expand All @@ -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() {
Expand All @@ -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 = '') {
Expand Down

0 comments on commit 52cc761

Please sign in to comment.