diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2020-12-29 17:20:31 +0300 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2020-12-29 17:24:00 +0300 |
commit | edbd604ebc0094f48ab735da3e449625f8f6cfd9 (patch) | |
tree | 83d51deddc13dbc91a64ee3add196eda52afbb1e /lib | |
parent | 8eb7310025dc24ddd379b36e0e94bab536f2216b (diff) |
Fix PHP-CS
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib')
26 files changed, 29 insertions, 83 deletions
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 7c3843204..0a40655e3 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Julius Härtl <jus@bitgrid.net> @@ -38,7 +39,7 @@ use OCP\AppFramework\Bootstrap\IRegistrationContext; use OCP\DirectEditing\RegisterDirectEditorEvent; class Application extends App implements IBootstrap { - const APP_NAME = 'text'; + public const APP_NAME = 'text'; public function __construct(array $params = []) { parent::__construct(self::APP_NAME, $params); @@ -54,4 +55,3 @@ class Application extends App implements IBootstrap { public function boot(IBootContext $context): void { } } - diff --git a/lib/Command/ResetDocument.php b/lib/Command/ResetDocument.php index ca414f7e2..9d50a852a 100644 --- a/lib/Command/ResetDocument.php +++ b/lib/Command/ResetDocument.php @@ -33,7 +33,6 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class ResetDocument extends Command { - protected $documentService; protected $documentMapper; protected $stepMapper; @@ -72,7 +71,6 @@ class ResetDocument extends Command { * @return void */ protected function execute(InputInterface $input, OutputInterface $output) { - $fileId = $input->getArgument('file-id'); $fullReset = $input->getOption('full'); @@ -92,8 +90,5 @@ class ResetDocument extends Command { $output->writeln('Failed revert changes that are newer than the last saved version'); } } - } } - - diff --git a/lib/Controller/DirectSessionController.php b/lib/Controller/DirectSessionController.php index aef43873e..366362ced 100644 --- a/lib/Controller/DirectSessionController.php +++ b/lib/Controller/DirectSessionController.php @@ -50,10 +50,7 @@ use OC\Authentication\Exceptions\InvalidTokenException; use OCA\Text\Service\ApiService; use OCP\AppFramework\Controller; use OCP\AppFramework\Http\Response; -use OCP\AppFramework\PublicShareController; use OCP\DirectEditing\IManager; -use OCP\ISession; -use OCP\Share\Exceptions\ShareNotFound; use OCP\Share\IManager as ShareManager; use OCP\AppFramework\Http\DataResponse; use OCP\IRequest; @@ -137,5 +134,4 @@ class DirectSessionController extends Controller { public function updateSession(int $documentId, int $sessionId, string $sessionToken, string $guestName) { return $this->apiService->updateSession($documentId, $sessionId, $sessionToken, $guestName); } - } diff --git a/lib/Controller/NavigationController.php b/lib/Controller/NavigationController.php index a6659f617..1381f9ddd 100644 --- a/lib/Controller/NavigationController.php +++ b/lib/Controller/NavigationController.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Julius Härtl <jus@bitgrid.net> @@ -40,5 +41,4 @@ class NavigationController extends Controller { public function navigate(): TemplateResponse { return new TemplateResponse(Application::APP_NAME, 'main'); } - } diff --git a/lib/Controller/PublicSessionController.php b/lib/Controller/PublicSessionController.php index dbf9a2642..4eed2cad0 100644 --- a/lib/Controller/PublicSessionController.php +++ b/lib/Controller/PublicSessionController.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Julius Härtl <jus@bitgrid.net> @@ -115,5 +116,4 @@ class PublicSessionController extends PublicShareController { public function updateSession(int $documentId, int $sessionId, string $sessionToken, string $guestName) { return $this->apiService->updateSession($documentId, $sessionId, $sessionToken, $guestName); } - } diff --git a/lib/Controller/SessionController.php b/lib/Controller/SessionController.php index ff95a6cd9..0a2941068 100644 --- a/lib/Controller/SessionController.php +++ b/lib/Controller/SessionController.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Julius Härtl <jus@bitgrid.net> @@ -80,5 +81,4 @@ class SessionController extends Controller { public function sync(int $documentId, int $sessionId, string $sessionToken, int $version = 0, string $autosaveContent = null, bool $force = false, bool $manualSave = false): DataResponse { return $this->apiService->sync($documentId, $sessionId, $sessionToken, $version, $autosaveContent, $force, $manualSave); } - } diff --git a/lib/Controller/SettingsController.php b/lib/Controller/SettingsController.php index 125ac8f7e..f4f8c87eb 100644 --- a/lib/Controller/SettingsController.php +++ b/lib/Controller/SettingsController.php @@ -23,8 +23,6 @@ namespace OCA\Text\Controller; - -use OCA\Activity\Data; use OCA\Text\AppInfo\Application; use OCP\AppFramework\Controller; use OCP\AppFramework\Http; @@ -39,7 +37,7 @@ class SettingsController extends Controller { */ private $config; - const ACCEPTED_KEYS = [ + public const ACCEPTED_KEYS = [ 'workspace_enabled' ]; diff --git a/lib/Controller/WorkspaceController.php b/lib/Controller/WorkspaceController.php index 6d3ab10f0..582040fd0 100644 --- a/lib/Controller/WorkspaceController.php +++ b/lib/Controller/WorkspaceController.php @@ -47,12 +47,9 @@ declare(strict_types=1); namespace OCA\Text\Controller; use OCA\Text\AppInfo\Application; -use OCA\Text\Service\SessionService; use OCA\Text\Service\WorkspaceService; -use OCP\AppFramework\Controller; use OCP\AppFramework\Http; use OCP\AppFramework\Http\DataResponse; -use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\OCSController; use OCP\DirectEditing\IManager as IDirectEditingManager; use OCP\DirectEditing\RegisterDirectEditorEvent; @@ -194,7 +191,6 @@ class WorkspaceController extends OCSController { 'url' => $this->urlGenerator->linkToRouteAbsolute('files.DirectEditingView.edit', ['token' => $token]) ]); } - } catch (Exception $e) { $this->logger->logException($e, ['message' => 'Exception when creating a new file through direct editing']); return new DataResponse('Failed to create file', Http::STATUS_FORBIDDEN); @@ -211,5 +207,4 @@ class WorkspaceController extends OCSController { } return $file; } - } diff --git a/lib/Cron/Cleanup.php b/lib/Cron/Cleanup.php index 125008593..d2e9f6f60 100644 --- a/lib/Cron/Cleanup.php +++ b/lib/Cron/Cleanup.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** @@ -41,7 +42,6 @@ use OCP\ILogger; * @package OCA\Social\Cron */ class Cleanup extends TimedJob { - private $sessionService; private $documentService; private $logger; @@ -76,7 +76,4 @@ class Cleanup extends TimedJob { $removedSessions = $this->sessionService->removeInactiveSessions(null); $this->logger->debug('Removed ' . $removedSessions . ' inactive sessions'); } - - - } diff --git a/lib/DAV/WorkspacePlugin.php b/lib/DAV/WorkspacePlugin.php index 4118555c0..401b76084 100644 --- a/lib/DAV/WorkspacePlugin.php +++ b/lib/DAV/WorkspacePlugin.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Julius Härtl <jus@bitgrid.net> @@ -39,7 +40,6 @@ use Sabre\DAV\Server; use Sabre\DAV\ServerPlugin; class WorkspacePlugin extends ServerPlugin { - public const WORKSPACE_PROPERTY = '{http://nextcloud.org/ns}rich-workspace'; /** @var Server */ @@ -75,7 +75,7 @@ class WorkspacePlugin extends ServerPlugin { * @param Server $server * @return void */ - function initialize(Server $server) { + public function initialize(Server $server) { $this->server = $server; $this->server->on('propFind', [$this, 'propFind']); @@ -103,14 +103,13 @@ class WorkspacePlugin extends ServerPlugin { $file = $this->workspaceService->getFile($nodes[0]); if ($file instanceof File) { return $file->getContent(); - } - } catch (StorageNotAvailableException $e) { - // If a storage is not available we can for the propfind response assume that there is no rich workspace present + } + } catch (StorageNotAvailableException $e) { + // If a storage is not available we can for the propfind response assume that there is no rich workspace present } } return ''; }); } } - } diff --git a/lib/Db/Document.php b/lib/Db/Document.php index 0d69ad0f0..ae3dd43ad 100644 --- a/lib/Db/Document.php +++ b/lib/Db/Document.php @@ -23,11 +23,9 @@ namespace OCA\Text\Db; - use OCP\AppFramework\Db\Entity; class Document extends Entity implements \JsonSerializable { - public $id; protected $currentVersion = 0; protected $lastSavedVersion = 0; @@ -54,5 +52,4 @@ class Document extends Entity implements \JsonSerializable { 'initialVersion' => $this->initialVersion ]; } - } diff --git a/lib/Db/DocumentMapper.php b/lib/Db/DocumentMapper.php index a4f097b1b..b35cbbb9f 100644 --- a/lib/Db/DocumentMapper.php +++ b/lib/Db/DocumentMapper.php @@ -23,14 +23,12 @@ namespace OCA\Text\Db; - use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Db\QBMapper; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IDBConnection; class DocumentMapper extends QBMapper { - public function __construct(IDBConnection $db) { parent::__construct($db, 'text_documents', Document::class); } @@ -55,5 +53,4 @@ class DocumentMapper extends QBMapper { } return Document::fromRow($data); } - } diff --git a/lib/Db/Session.php b/lib/Db/Session.php index 9d727039e..3dc775ed7 100644 --- a/lib/Db/Session.php +++ b/lib/Db/Session.php @@ -23,7 +23,6 @@ namespace OCA\Text\Db; - use OCP\AppFramework\Db\Entity; /** @@ -34,7 +33,6 @@ use OCP\AppFramework\Db\Entity; * @method string getToken() */ class Session extends Entity implements \JsonSerializable { - public $id; protected $userId; protected $token; @@ -47,7 +45,6 @@ class Session extends Entity implements \JsonSerializable { $this->addType('id', 'integer'); $this->addType('documentId', 'integer'); $this->addType('lastContact', 'integer'); - } public function jsonSerialize() { diff --git a/lib/Db/SessionMapper.php b/lib/Db/SessionMapper.php index f12aad9d8..8c62a73ef 100644 --- a/lib/Db/SessionMapper.php +++ b/lib/Db/SessionMapper.php @@ -23,7 +23,6 @@ namespace OCA\Text\Db; - use OCA\Text\Service\SessionService; use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Db\QBMapper; @@ -35,7 +34,6 @@ use OCP\IDBConnection; * @method Session insert(Session $session) */ class SessionMapper extends QBMapper { - public function __construct(IDBConnection $db) { parent::__construct($db, 'text_sessions', Session::class); } @@ -71,7 +69,7 @@ class SessionMapper extends QBMapper { $qb->select('id','color','document_id', 'last_contact','user_id','guest_name') ->from($this->getTableName()) ->where($qb->expr()->eq('document_id', $qb->createNamedParameter($documentId))) - ->andWhere($qb->expr()->gt('last_contact', $qb->createNamedParameter(time()-SessionService::SESSION_VALID_TIME))) + ->andWhere($qb->expr()->gt('last_contact', $qb->createNamedParameter(time() - SessionService::SESSION_VALID_TIME))) ->execute(); return $this->findEntities($qb); @@ -82,7 +80,7 @@ class SessionMapper extends QBMapper { $qb = $this->db->getQueryBuilder(); $qb->select('id','color','document_id', 'last_contact','user_id','guest_name') ->from($this->getTableName()) - ->where($qb->expr()->lt('last_contact', $qb->createNamedParameter(time()-SessionService::SESSION_VALID_TIME))) + ->where($qb->expr()->lt('last_contact', $qb->createNamedParameter(time() - SessionService::SESSION_VALID_TIME))) ->execute(); return $this->findEntities($qb); @@ -93,10 +91,10 @@ class SessionMapper extends QBMapper { $qb = $this->db->getQueryBuilder(); $qb->delete($this->getTableName()); if ($documentId === null) { - $qb->where($qb->expr()->lt('last_contact', $qb->createNamedParameter(time()-SessionService::SESSION_VALID_TIME))); + $qb->where($qb->expr()->lt('last_contact', $qb->createNamedParameter(time() - SessionService::SESSION_VALID_TIME))); } else { $qb->where($qb->expr()->eq('document_id', $qb->createNamedParameter($documentId))) - ->andWhere($qb->expr()->lt('last_contact', $qb->createNamedParameter(time()-SessionService::SESSION_VALID_TIME))); + ->andWhere($qb->expr()->lt('last_contact', $qb->createNamedParameter(time() - SessionService::SESSION_VALID_TIME))); } return $qb->execute(); } @@ -108,5 +106,4 @@ class SessionMapper extends QBMapper { ->where($qb->expr()->eq('document_id', $qb->createNamedParameter($documentId))); return $qb->execute(); } - } diff --git a/lib/Db/Step.php b/lib/Db/Step.php index b9cf873ff..efc1676fb 100644 --- a/lib/Db/Step.php +++ b/lib/Db/Step.php @@ -23,11 +23,9 @@ namespace OCA\Text\Db; - use OCP\AppFramework\Db\Entity; class Step extends Entity implements \JsonSerializable { - public $id; protected $data; protected $version; diff --git a/lib/Db/StepMapper.php b/lib/Db/StepMapper.php index 44b7eafd0..32a6ea9a5 100644 --- a/lib/Db/StepMapper.php +++ b/lib/Db/StepMapper.php @@ -23,13 +23,11 @@ namespace OCA\Text\Db; - use OCP\AppFramework\Db\QBMapper; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IDBConnection; class StepMapper extends QBMapper { - public function __construct(IDBConnection $db) { parent::__construct($db, 'text_steps', Step::class); } @@ -78,5 +76,4 @@ class StepMapper extends QBMapper { ->andWhere($qb->expr()->gt('version', $qb->createNamedParameter($version))) ->execute(); } - } diff --git a/lib/DirectEditing/TextDirectEditor.php b/lib/DirectEditing/TextDirectEditor.php index 1cb6f7c4b..750c7b6ca 100644 --- a/lib/DirectEditing/TextDirectEditor.php +++ b/lib/DirectEditing/TextDirectEditor.php @@ -145,5 +145,4 @@ class TextDirectEditor implements IEditor { } return new NotFoundResponse(); } - } diff --git a/lib/DirectEditing/TextDocumentCreator.php b/lib/DirectEditing/TextDocumentCreator.php index e4dc83468..9d09870fb 100644 --- a/lib/DirectEditing/TextDocumentCreator.php +++ b/lib/DirectEditing/TextDocumentCreator.php @@ -23,9 +23,7 @@ namespace OCA\Text\DirectEditing; - use OCP\DirectEditing\ACreateEmpty; -use OCP\Files\File; use OCP\IL10N; class TextDocumentCreator extends ACreateEmpty { @@ -54,5 +52,4 @@ class TextDocumentCreator extends ACreateEmpty { public function getMimetype(): string { return 'text/markdown'; } - } diff --git a/lib/DocumentHasUnsavedChangesException.php b/lib/DocumentHasUnsavedChangesException.php index 1fe827817..2a1a10cbe 100644 --- a/lib/DocumentHasUnsavedChangesException.php +++ b/lib/DocumentHasUnsavedChangesException.php @@ -23,7 +23,5 @@ namespace OCA\Text; - class DocumentHasUnsavedChangesException extends \Exception { - } diff --git a/lib/DocumentSaveConflictException.php b/lib/DocumentSaveConflictException.php index 927c90a6a..7f3df377e 100644 --- a/lib/DocumentSaveConflictException.php +++ b/lib/DocumentSaveConflictException.php @@ -23,7 +23,5 @@ namespace OCA\Text; - class DocumentSaveConflictException extends \Exception { - } diff --git a/lib/Migration/Version030201Date20201116110353.php b/lib/Migration/Version030201Date20201116110353.php index ab7ffa5fa..7c097a244 100644 --- a/lib/Migration/Version030201Date20201116110353.php +++ b/lib/Migration/Version030201Date20201116110353.php @@ -5,7 +5,6 @@ declare(strict_types=1); namespace OCA\Text\Migration; use Closure; -use Doctrine\DBAL\Types\Type; use OCP\DB\ISchemaWrapper; use OCP\IConfig; use OCP\Migration\IOutput; diff --git a/lib/Service/ApiService.php b/lib/Service/ApiService.php index f93ba1171..dcb107206 100644 --- a/lib/Service/ApiService.php +++ b/lib/Service/ApiService.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** @@ -25,10 +26,8 @@ declare(strict_types=1); namespace OCA\Text\Service; - use Exception; use OC\Files\Node\File; -use OCA\Activity\Data; use OCA\Text\DocumentHasUnsavedChangesException; use OCA\Text\DocumentSaveConflictException; use OCA\Text\VersionMismatchException; @@ -39,13 +38,11 @@ use OCP\AppFramework\Http\FileDisplayResponse; use OCP\AppFramework\Http\NotFoundResponse; use OCP\Constants; use OCP\Files\NotFoundException; -use OCP\ICacheFactory; use OCP\ILogger; use OCP\IRequest; use OCP\Lock\LockedException; class ApiService { - protected $request; protected $sessionService; protected $documentService; @@ -80,7 +77,7 @@ class ApiService { $readOnly = false; } catch (NotFoundException $e) { } - } else if ($fileId) { + } elseif ($fileId) { $file = $this->documentService->getFileById($fileId); $readOnly = !$file->isUpdateable(); } else { diff --git a/lib/Service/DocumentService.php b/lib/Service/DocumentService.php index 74cd2e0a3..9bff1cdcf 100644 --- a/lib/Service/DocumentService.php +++ b/lib/Service/DocumentService.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** @@ -122,7 +123,8 @@ class DocumentService { $tokenObject->extend(); $tokenObject->useTokenScope(); $this->userId = $tokenObject->getUser(); - } catch (\Exception $e) {} + } catch (\Exception $e) { + } } } @@ -259,7 +261,7 @@ class DocumentService { } $steps = $this->stepMapper->find($documentId, $lastVersion); $unique_array = []; - foreach($steps as $step) { + foreach ($steps as $step) { $version = $step->getVersion(); if (!array_key_exists($version, $unique_array)) { $unique_array[(string)$version] = $step; @@ -358,7 +360,7 @@ class DocumentService { } catch (NotFoundException $e) { } catch (NotPermittedException $e) { } - } else if ($this->hasUnsavedChanges($document)) { + } elseif ($this->hasUnsavedChanges($document)) { throw new DocumentHasUnsavedChangesException('Did not reset document, as it has unsaved changes'); } } catch (DoesNotExistException $e) { @@ -440,7 +442,8 @@ class DocumentService { try { $this->checkSharePermissions($token, Constants::PERMISSION_UPDATE); $readOnly = false; - } catch (NotFoundException $e) {} + } catch (NotFoundException $e) { + } } else { $readOnly = !$file->isUpdateable(); } @@ -481,5 +484,4 @@ class DocumentService { return true; } - } diff --git a/lib/Service/SessionService.php b/lib/Service/SessionService.php index f70952d94..493172045 100644 --- a/lib/Service/SessionService.php +++ b/lib/Service/SessionService.php @@ -23,14 +23,11 @@ namespace OCA\Text\Service; - -use OC\Avatar\Avatar; use OCA\Text\Db\Session; use OCA\Text\Db\SessionMapper; use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Utility\ITimeFactory; use OCP\DirectEditing\IManager; -use OCP\IAvatar; use OCP\IAvatarManager; use OCP\ICache; use OCP\ICacheFactory; @@ -38,8 +35,7 @@ use OCP\IRequest; use OCP\Security\ISecureRandom; class SessionService { - - public const SESSION_VALID_TIME = 60*5; + public const SESSION_VALID_TIME = 60 * 5; /** @var SessionMapper */ private $sessionMapper; @@ -85,7 +81,8 @@ class SessionService { $tokenObject->extend(); $tokenObject->useTokenScope(); $this->userId = $tokenObject->getUser(); - } catch (\Exception $e) {} + } catch (\Exception $e) { + } } $this->cache = $cacheFactory->createDistributed('text_sessions'); @@ -122,7 +119,7 @@ class SessionService { public function getActiveSessions($documentId): array { $sessions = $this->sessionMapper->findAllActive($documentId); - return array_map(function(Session $session) { + return array_map(function (Session $session) { $result = $session->jsonSerialize(); $userManager = \OC::$server->getUserManager(); $user = $userManager->get($session->getUserId()); diff --git a/lib/Service/WorkspaceService.php b/lib/Service/WorkspaceService.php index 819900745..f44b1a206 100644 --- a/lib/Service/WorkspaceService.php +++ b/lib/Service/WorkspaceService.php @@ -3,14 +3,12 @@ namespace OCA\Text\Service; - use OCP\Files\Folder; use OCP\Files\NotFoundException; use OCP\Files\StorageNotAvailableException; use OCP\IL10N; class WorkspaceService { - private const SUPPORTED_STATIC_FILENAMES = [ 'README.md', 'Readme.md', diff --git a/lib/VersionMismatchException.php b/lib/VersionMismatchException.php index b4b1ea1ad..b5c50bd6b 100644 --- a/lib/VersionMismatchException.php +++ b/lib/VersionMismatchException.php @@ -23,11 +23,9 @@ namespace OCA\Text; - use OCP\AppFramework\Http; class VersionMismatchException extends \Exception { - public function getStatus() { return Http::STATUS_PRECONDITION_FAILED; } |