Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps-dev): bump psalm/phar from 5.19.0 to 5.20.0 #5291

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions lib/Controller/AttachmentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
#[NoAdminRequired]
#[PublicPage]
#[RequireDocumentSessionOrUserOrShareToken]
public function getAttachmentList(?string $shareToken = null): DataResponse {
public function getAttachmentList(string $shareToken = ''): DataResponse {
$documentId = $this->getDocument()->getId();
try {
$session = $this->getSession();
Expand All @@ -95,10 +95,10 @@
}

if ($shareToken) {
$attachments = $this->attachmentService->getAttachmentList($documentId, null, $session, $shareToken);

Check failure on line 98 in lib/Controller/AttachmentController.php

View workflow job for this annotation

GitHub Actions / Nextcloud

NullArgument

lib/Controller/AttachmentController.php:98:76: NullArgument: Argument 2 of OCA\Text\Service\AttachmentService::getAttachmentList cannot be null, null value provided to parameter with type string (see https://psalm.dev/057)
} else {
$userId = $this->getUserId();
$attachments = $this->attachmentService->getAttachmentList($documentId, $userId, $session, null);
$attachments = $this->attachmentService->getAttachmentList($documentId, $userId, $session);
}

return new DataResponse($attachments);
Expand Down Expand Up @@ -126,7 +126,7 @@
#[NoAdminRequired]
#[PublicPage]
#[RequireDocumentSession]
public function uploadAttachment(?string $shareToken = null): DataResponse {
public function uploadAttachment(string $shareToken = ''): DataResponse {
$documentId = $this->getSession()->getDocumentId();

try {
Expand Down Expand Up @@ -193,7 +193,7 @@
#[PublicPage]
#[NoCSRFRequired]
#[RequireDocumentSessionOrUserOrShareToken]
public function getImageFile(string $imageFileName, ?string $shareToken = null,
public function getImageFile(string $imageFileName, string $shareToken = '',
int $preferRawImage = 0): DataResponse|DataDownloadResponse {
$documentId = $this->getDocument()->getId();

Expand Down Expand Up @@ -228,7 +228,7 @@
#[PublicPage]
#[NoCSRFRequired]
#[RequireDocumentSessionOrUserOrShareToken]
public function getMediaFile(string $mediaFileName, ?string $shareToken = null): DataResponse|DataDownloadResponse {
public function getMediaFile(string $mediaFileName, string $shareToken = ''): DataResponse|DataDownloadResponse {
$documentId = $this->getDocument()->getId();

try {
Expand Down Expand Up @@ -259,7 +259,7 @@
#[PublicPage]
#[NoCSRFRequired]
#[RequireDocumentSessionOrUserOrShareToken]
public function getMediaFilePreview(string $mediaFileName, ?string $shareToken = null) {
public function getMediaFilePreview(string $mediaFileName, string $shareToken = '') {
$documentId = $this->getDocument()->getId();

try {
Expand Down
2 changes: 1 addition & 1 deletion lib/Controller/SessionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function __construct(

#[NoAdminRequired]
public function create(int $fileId = null, string $file = null): DataResponse {
return $this->apiService->create($fileId, $file, null, null);
return $this->apiService->create($fileId, $file);
}

#[NoAdminRequired]
Expand Down
11 changes: 6 additions & 5 deletions lib/Controller/UserApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@
// Add joined users to the autocomplete list
foreach ($sessions as $session) {
$sessionUserId = $session['userId'];
if ($sessionUserId !== null && !isset($users[$sessionUserId])) {
$displayName = $this->userManager->getDisplayName($sessionUserId);
if ($displayName && stripos($displayName, $filter) !== false || stripos($sessionUserId, $filter) !== false) {
$users[$sessionUserId] = $displayName;
}
if ($sessionUserId === null || isset($users[$sessionUserId])) {
continue;
}
$displayName = $this->userManager->getDisplayName($sessionUserId) ?: '';

Check failure on line 45 in lib/Controller/UserApiController.php

View workflow job for this annotation

GitHub Actions / Nextcloud

RiskyTruthyFalsyComparison

lib/Controller/UserApiController.php:45:19: RiskyTruthyFalsyComparison: Operand of type null|string contains type string, which can be falsy and truthy. This can cause possibly unexpected behavior. Use strict comparison instead. (see https://psalm.dev/356)
if (stripos($displayName, $filter) !== false || stripos($sessionUserId, $filter) !== false) {
$users[$sessionUserId] = $displayName;
}
}

Expand Down
4 changes: 2 additions & 2 deletions lib/Service/ApiService.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function __construct(IRequest $request,
$this->l10n = $l10n;
}

public function create(?int $fileId = null, ?string $filePath = null, ?string $token = null, ?string $guestName = null): DataResponse {
public function create(?int $fileId = null, ?string $filePath = null, string $token = '', ?string $guestName = null): DataResponse {
try {
if ($token) {
$file = $this->documentService->getFileByShareToken($token, $this->request->getParam('filePath'));
Expand All @@ -86,7 +86,7 @@ public function create(?int $fileId = null, ?string $filePath = null, ?string $t
} catch (NotPermittedException $e) {
return new DataResponse($this->l10n->t('This file cannot be displayed as download is disabled by the share'), 404);
}
} elseif ($fileId) {
} elseif ($fileId !== null) {
try {
$file = $this->documentService->getFileById($fileId);
} catch (NotFoundException|NotPermittedException $e) {
Expand Down
6 changes: 3 additions & 3 deletions lib/Service/AttachmentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,17 +204,17 @@ private function getMediaFilePreviewFile(string $mediaFileName, File $textFile):

/**
* @param int $documentId
* @param string|null $userId
* @param string $userId or empty string if there is none.
* @param Session|null $session
* @param string|null $shareToken
* @param string $shareToken or empty string if there is none.
*
* @return array
* @throws InvalidPathException
* @throws NoUserException
* @throws NotFoundException
* @throws NotPermittedException
*/
public function getAttachmentList(int $documentId, ?string $userId = null, ?Session $session = null, ?string $shareToken = null): array {
public function getAttachmentList(int $documentId, string $userId = '', ?Session $session = null, string $shareToken = ''): array {
if ($shareToken) {
$textFile = $this->getTextFilePublic($documentId, $shareToken);
} elseif ($userId) {
Expand Down
4 changes: 2 additions & 2 deletions lib/Service/DocumentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
// Do not hard reset if changed from outside since this will throw away possible steps
// This way the user can still resolve conflicts in the editor view
$stepsVersion = $this->stepMapper->getLatestVersion($document->getId());
if ($stepsVersion && ($document->getLastSavedVersion() !== $stepsVersion)) {
if ($stepsVersion !== null && ($document->getLastSavedVersion() !== $stepsVersion)) {
$this->logger->debug('Unsaved steps, continue collaborative editing');
return $document;
}
Expand Down Expand Up @@ -335,7 +335,7 @@
// Do not save if newer version already saved
// Note that $version is the version of the steps the client has fetched.
// It may have added steps on top of that - so if the versions match we still save.
$stepsVersion = $this->stepMapper->getLatestVersion($documentId)?: 0;
$stepsVersion = $this->stepMapper->getLatestVersion($documentId) ?? 0;
$savedVersion = $document->getLastSavedVersion();
$outdated = $savedVersion > 0 && $savedVersion > $version;
if (!$force && ($outdated || $version > (string)$stepsVersion)) {
Expand Down Expand Up @@ -366,7 +366,7 @@

// Version changed but the content remains the same
if ($autoSaveDocument === $file->getContent()) {
if ($documentState) {

Check failure on line 369 in lib/Service/DocumentService.php

View workflow job for this annotation

GitHub Actions / Nextcloud

RiskyTruthyFalsyComparison

lib/Service/DocumentService.php:369:8: RiskyTruthyFalsyComparison: Operand of type null|string contains type string, which can be falsy and truthy. This can cause possibly unexpected behavior. Use strict comparison instead. (see https://psalm.dev/356)
$this->writeDocumentState($file->getId(), $documentState);
}
$document->setLastSavedVersion($stepsVersion);
Expand All @@ -384,7 +384,7 @@
Application::APP_NAME
), function () use ($file, $autoSaveDocument, $documentState) {
$file->putContent($autoSaveDocument);
if ($documentState) {

Check failure on line 387 in lib/Service/DocumentService.php

View workflow job for this annotation

GitHub Actions / Nextcloud

RiskyTruthyFalsyComparison

lib/Service/DocumentService.php:387:9: RiskyTruthyFalsyComparison: Operand of type null|string contains type string, which can be falsy and truthy. This can cause possibly unexpected behavior. Use strict comparison instead. (see https://psalm.dev/356)
$this->writeDocumentState($file->getId(), $documentState);
}
});
Expand Down Expand Up @@ -537,7 +537,7 @@

public function isReadOnly(File $file, string|null $token): bool {
$readOnly = true;
if ($token) {

Check failure on line 540 in lib/Service/DocumentService.php

View workflow job for this annotation

GitHub Actions / Nextcloud

RiskyTruthyFalsyComparison

lib/Service/DocumentService.php:540:7: RiskyTruthyFalsyComparison: Operand of type null|string contains type string, which can be falsy and truthy. This can cause possibly unexpected behavior. Use strict comparison instead. (see https://psalm.dev/356)
try {
$this->checkSharePermissions($token, Constants::PERMISSION_UPDATE);
$readOnly = false;
Expand Down Expand Up @@ -590,7 +590,7 @@
}

public function hasUnsavedChanges(Document $document): bool {
$stepsVersion = $this->stepMapper->getLatestVersion($document->getId()) ?: 0;

Check failure on line 593 in lib/Service/DocumentService.php

View workflow job for this annotation

GitHub Actions / Nextcloud

RiskyTruthyFalsyComparison

lib/Service/DocumentService.php:593:19: RiskyTruthyFalsyComparison: Operand of type int|null contains type int, which can be falsy and truthy. This can cause possibly unexpected behavior. Use strict comparison instead. (see https://psalm.dev/356)
$docVersion = $document->getLastSavedVersion();
return $stepsVersion !== $docVersion;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Service/SessionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ public function updateSessionAwareness(Session $session, string $message): Sessi
return $this->sessionMapper->update($session);
}

private function getColorForGuestName(string $guestName = null): string {
$guestName = $this->userId ?? $guestName;
private function getColorForGuestName(string $guestName = ''): string {
$guestName = $this->userId ? $guestName : '';
$uniqueGuestId = !empty($guestName) ? $guestName : $this->secureRandom->generate(12);
$color = $this->avatarManager->getGuestAvatar($uniqueGuestId)->avatarBackgroundColor($uniqueGuestId);
return $color->name();
Expand Down
Loading