diff --git a/lib/Controller/PublicSessionController.php b/lib/Controller/PublicSessionController.php index 4f01142784d..3d0da080e8c 100644 --- a/lib/Controller/PublicSessionController.php +++ b/lib/Controller/PublicSessionController.php @@ -80,7 +80,7 @@ protected function isPasswordProtected(): bool { #[NoAdminRequired] #[PublicPage] - public function create(string $token, string $file = null, ?string $guestName = null): DataResponse { + public function create(string $token, ?string $file = null, ?string $guestName = null): DataResponse { return $this->apiService->create(null, $file, $token, $guestName); } @@ -107,7 +107,7 @@ public function sync(string $token, int $version = 0): DataResponse { #[NoAdminRequired] #[PublicPage] #[RequireDocumentSession] - public function save(string $token, int $version = 0, string $autosaveContent = null, string $documentState = null, bool $force = false, bool $manualSave = false): DataResponse { + public function save(string $token, int $version = 0, ?string $autosaveContent = null, ?string $documentState = null, bool $force = false, bool $manualSave = false): DataResponse { return $this->apiService->save($this->getSession(), $this->getDocument(), $version, $autosaveContent, $documentState, $force, $manualSave, $token); } diff --git a/lib/Controller/SessionController.php b/lib/Controller/SessionController.php index 9de585d394b..aa935f57879 100644 --- a/lib/Controller/SessionController.php +++ b/lib/Controller/SessionController.php @@ -57,7 +57,7 @@ public function __construct( } #[NoAdminRequired] - public function create(int $fileId = null, string $file = null): DataResponse { + public function create(?int $fileId = null, ?string $file = null): DataResponse { return $this->apiService->create($fileId, $file, null, null); } @@ -94,7 +94,7 @@ public function sync(int $version = 0): DataResponse { #[NoAdminRequired] #[PublicPage] #[RequireDocumentSession] - public function save(int $version = 0, string $autosaveContent = null, string $documentState = null, bool $force = false, bool $manualSave = false): DataResponse { + public function save(int $version = 0, ?string $autosaveContent = null, ?string $documentState = null, bool $force = false, bool $manualSave = false): DataResponse { try { $this->loginSessionUser(); return $this->apiService->save($this->getSession(), $this->getDocument(), $version, $autosaveContent, $documentState, $force, $manualSave); diff --git a/lib/Service/DocumentService.php b/lib/Service/DocumentService.php index fa3c34e5b8d..d6c8edbe98b 100644 --- a/lib/Service/DocumentService.php +++ b/lib/Service/DocumentService.php @@ -26,7 +26,7 @@ namespace OCA\Text\Service; -use \InvalidArgumentException; +use InvalidArgumentException; use OCA\Text\AppInfo\Application; use OCA\Text\Db\Document; use OCA\Text\Db\DocumentMapper; diff --git a/lib/Service/SessionService.php b/lib/Service/SessionService.php index e24204e201d..744b763cbf6 100644 --- a/lib/Service/SessionService.php +++ b/lib/Service/SessionService.php @@ -85,7 +85,7 @@ public function __construct( $this->cache = $cacheFactory->createDistributed('text_sessions'); } - public function initSession(int $documentId, string $guestName = null): Session { + public function initSession(int $documentId, ?string $guestName = null): Session { $session = new Session(); $session->setDocumentId($documentId); $userName = $this->userId ? $this->userId : $guestName; @@ -236,7 +236,7 @@ public function updateSessionAwareness(Session $session, string $message): Sessi return $this->sessionMapper->update($session); } - private function getColorForGuestName(string $guestName = null): string { + private function getColorForGuestName(?string $guestName = null): string { $guestName = $this->userId ?? $guestName; $uniqueGuestId = !empty($guestName) ? $guestName : $this->secureRandom->generate(12); $color = $this->avatarManager->getGuestAvatar($uniqueGuestId)->avatarBackgroundColor($uniqueGuestId); diff --git a/tests/unit/Controller/UserApiControllerTest.php b/tests/unit/Controller/UserApiControllerTest.php index 14db310e38e..9d4c3bfc8ba 100644 --- a/tests/unit/Controller/UserApiControllerTest.php +++ b/tests/unit/Controller/UserApiControllerTest.php @@ -2,11 +2,11 @@ namespace OCA\Text\Controller; -use \OCP\IRequest; use OCA\Text\Db\Session; use OCA\Text\Service\SessionService; use OCP\AppFramework\Http\DataResponse; use OCP\Collaboration\Collaborators\ISearch; +use OCP\IRequest; use OCP\IUserManager; use OCP\IUserSession; use Test\TestCase;