From d8ba16cfb931a6b5c2f1d69a6c9e0cded4bb7f6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Mon, 25 Nov 2019 14:09:38 +0100 Subject: [PATCH] fixup! Code style fixes and cleanup --- .../CleanupDirectEditingTokens.php | 2 +- apps/files/lib/Capabilities.php | 6 +- .../Controller/DirectEditingController.php | 6 +- .../Version18000Date20191014105105.php | 70 +++++++++---------- lib/private/DirectEditing/Manager.php | 2 +- .../DirectEditing/ACreateFromTemplate.php | 2 +- lib/public/DirectEditing/IEditor.php | 6 +- 7 files changed, 48 insertions(+), 46 deletions(-) diff --git a/apps/files/lib/BackgroundJob/CleanupDirectEditingTokens.php b/apps/files/lib/BackgroundJob/CleanupDirectEditingTokens.php index 77907fab2816a..8d4a3f2378743 100644 --- a/apps/files/lib/BackgroundJob/CleanupDirectEditingTokens.php +++ b/apps/files/lib/BackgroundJob/CleanupDirectEditingTokens.php @@ -7,7 +7,7 @@ class CleanupDirectEditingTokens extends TimedJob { - const INTERVAL_MINUTES = 15 * 60; + private const INTERVAL_MINUTES = 15 * 60; /** * @var IManager diff --git a/apps/files/lib/Capabilities.php b/apps/files/lib/Capabilities.php index c37e32b6b59a5..3393e29b4d23c 100644 --- a/apps/files/lib/Capabilities.php +++ b/apps/files/lib/Capabilities.php @@ -38,9 +38,13 @@ * @package OCA\Files */ class Capabilities implements ICapability { + /** @var IConfig */ protected $config; + /** @var Manager */ + protected $directEditingManager; + /** * Capabilities constructor. * @@ -66,7 +70,7 @@ public function getCapabilities() { ]; } - private function getDirectEditingCapabilitites() { + private function getDirectEditingCapabilitites(): array { $capabilities = [ 'editors' => [], 'creators' => [] diff --git a/apps/files/lib/Controller/DirectEditingController.php b/apps/files/lib/Controller/DirectEditingController.php index e8791316442dc..11d09e2f074b7 100644 --- a/apps/files/lib/Controller/DirectEditingController.php +++ b/apps/files/lib/Controller/DirectEditingController.php @@ -66,7 +66,7 @@ public function __construct($appName, IRequest $request, $corsMethods, $corsAllo * @NoAdminRequired */ public function create(string $path, string $editorId, string $creatorId, string $templateId = null): DataResponse { - $this->eventDispatcher->dispatch(RegisterDirectEditorEvent::class, new RegisterDirectEditorEvent($this->directEditingManager)); + $this->eventDispatcher->dispatchTyped(new RegisterDirectEditorEvent($this->directEditingManager)); try { $token = $this->directEditingManager->create($path, $editorId, $creatorId, $templateId); @@ -83,7 +83,7 @@ public function create(string $path, string $editorId, string $creatorId, string * @NoAdminRequired */ public function open(int $fileId, string $editorId = null): DataResponse { - $this->eventDispatcher->dispatch(RegisterDirectEditorEvent::class, new RegisterDirectEditorEvent($this->directEditingManager)); + $this->eventDispatcher->dispatchTyped(new RegisterDirectEditorEvent($this->directEditingManager)); try { $token = $this->directEditingManager->open($fileId, $editorId); @@ -102,7 +102,7 @@ public function open(int $fileId, string $editorId = null): DataResponse { * @NoAdminRequired */ public function templates(string $editorId, string $creatorId): DataResponse { - $this->eventDispatcher->dispatch(RegisterDirectEditorEvent::class, new RegisterDirectEditorEvent($this->directEditingManager)); + $this->eventDispatcher->dispatchTyped(new RegisterDirectEditorEvent($this->directEditingManager)); try { return new DataResponse($this->directEditingManager->getTemplates($editorId, $creatorId)); diff --git a/core/Migrations/Version18000Date20191014105105.php b/core/Migrations/Version18000Date20191014105105.php index b291c0b5e468e..634f9f91faf39 100644 --- a/core/Migrations/Version18000Date20191014105105.php +++ b/core/Migrations/Version18000Date20191014105105.php @@ -50,44 +50,42 @@ public function __construct(IDBConnection $connection) { public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { /** @var ISchemaWrapper $schema */ $schema = $schemaClosure(); - if (!$schema->hasTable('direct_edit')) { - $table = $schema->createTable('direct_edit'); + $table = $schema->createTable('direct_edit'); - $table->addColumn('id', Type::BIGINT, [ - 'autoincrement' => true, - 'notnull' => true, - ]); - $table->addColumn('editor_id', Type::STRING, [ - 'notnull' => true, - 'length' => 64, - ]); - $table->addColumn('token', Type::STRING, [ - 'notnull' => true, - 'length' => 64, - ]); - $table->addColumn('file_id', Type::BIGINT, [ - 'notnull' => true, - ]); - $table->addColumn('user_id', Type::STRING, [ - 'notnull' => false, - 'length' => 64, - ]); - $table->addColumn('share_id', Type::BIGINT, [ - 'notnull' => false - ]); - $table->addColumn('timestamp', Type::BIGINT, [ - 'notnull' => true, - 'length' => 20, - 'unsigned' => true, - ]); - $table->addColumn('accessed', Type::BOOLEAN, [ - 'notnull' => true, - 'default' => false - ]); + $table->addColumn('id', Type::BIGINT, [ + 'autoincrement' => true, + 'notnull' => true, + ]); + $table->addColumn('editor_id', Type::STRING, [ + 'notnull' => true, + 'length' => 64, + ]); + $table->addColumn('token', Type::STRING, [ + 'notnull' => true, + 'length' => 64, + ]); + $table->addColumn('file_id', Type::BIGINT, [ + 'notnull' => true, + ]); + $table->addColumn('user_id', Type::STRING, [ + 'notnull' => false, + 'length' => 64, + ]); + $table->addColumn('share_id', Type::BIGINT, [ + 'notnull' => false + ]); + $table->addColumn('timestamp', Type::BIGINT, [ + 'notnull' => true, + 'length' => 20, + 'unsigned' => true, + ]); + $table->addColumn('accessed', Type::BOOLEAN, [ + 'notnull' => true, + 'default' => false + ]); - $table->setPrimaryKey(['id']); - $table->addIndex(['token']); - } + $table->setPrimaryKey(['id']); + $table->addIndex(['token']); return $schema; } diff --git a/lib/private/DirectEditing/Manager.php b/lib/private/DirectEditing/Manager.php index fdf0a1f0f0f6f..c1599e24d6b7c 100644 --- a/lib/private/DirectEditing/Manager.php +++ b/lib/private/DirectEditing/Manager.php @@ -71,7 +71,7 @@ public function __construct( $this->connection = $connection; $this->userId = $userSession->getUser() ? $userSession->getUser()->getUID() : null; $this->rootFolder = $rootFolder; - $eventDispatcher->dispatch(RegisterDirectEditorEvent::class, new RegisterDirectEditorEvent($this)); + $eventDispatcher->dispatchTyped(new RegisterDirectEditorEvent($this)); } diff --git a/lib/public/DirectEditing/ACreateFromTemplate.php b/lib/public/DirectEditing/ACreateFromTemplate.php index a731e8be59581..89420a63743b4 100644 --- a/lib/public/DirectEditing/ACreateFromTemplate.php +++ b/lib/public/DirectEditing/ACreateFromTemplate.php @@ -32,7 +32,7 @@ abstract class ACreateFromTemplate extends ACreateEmpty { * List of available templates for the create from template action * * @since 18.0.0 - * @return array + * @return ATemplate[] */ abstract public function getTemplates(): array; diff --git a/lib/public/DirectEditing/IEditor.php b/lib/public/DirectEditing/IEditor.php index a4fc87f7e15e2..a2bc0d74255f0 100644 --- a/lib/public/DirectEditing/IEditor.php +++ b/lib/public/DirectEditing/IEditor.php @@ -56,7 +56,7 @@ public function getName(): string; * A list of mimetypes that should open the editor by default * * @since 18.0.0 - * @return array + * @return string[] */ public function getMimetypes(): array; @@ -64,7 +64,7 @@ public function getMimetypes(): array; * A list of mimetypes that can be opened in the editor optionally * * @since 18.0.0 - * @return array + * @return string[] */ public function getMimetypesOptional(): array; @@ -72,7 +72,7 @@ public function getMimetypesOptional(): array; * Return a list of file creation options to be presented to the user * * @since 18.0.0 - * @return array of ICreateFromTemplate|ICreateEmpty + * @return ACreateFromTemplate[]|ACreateEmpty[] */ public function getCreators(): array;