]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix: Fix psalm issues
authorMarcel Klehr <mklehr@gmx.net>
Fri, 3 May 2024 09:46:36 +0000 (11:46 +0200)
committerMarcel Klehr <mklehr@gmx.net>
Tue, 14 May 2024 09:38:40 +0000 (11:38 +0200)
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
lib/private/TaskProcessing/Manager.php
lib/public/TaskProcessing/EShapeType.php
lib/public/TaskProcessing/ShapeDescriptor.php

index 8b145be8a65dad26a48b78fece37d5511473a8d5..793bcec63643c6305c06180dd6cbbb627351ac07 100644 (file)
@@ -38,7 +38,9 @@ use OCP\Files\GenericFileException;
 use OCP\Files\IAppData;
 use OCP\Files\IRootFolder;
 use OCP\Files\NotPermittedException;
+use OCP\IL10N;
 use OCP\IServerContainer;
+use OCP\L10N\IFactory;
 use OCP\Lock\LockedException;
 use OCP\PreConditionNotMetException;
 use OCP\SpeechToText\ISpeechToTextProvider;
@@ -180,10 +182,12 @@ class Manager implements IManager {
                        $taskType = new class($oldProvider->getTaskType()) implements ITaskType {
                                private string $oldTaskTypeClass;
                                private \OCP\TextProcessing\ITaskType $oldTaskType;
+                               private IL10N $l;
 
                                public function __construct(string $oldTaskTypeClass) {
                                        $this->oldTaskTypeClass = $oldTaskTypeClass;
                                        $this->oldTaskType = \OCP\Server::get($oldTaskTypeClass);
+                                       $this->l = \OCP\Server::get(IFactory::class)->get('core');
                                }
 
                                public function getId(): string {
@@ -199,11 +203,11 @@ class Manager implements IManager {
                                }
 
                                public function getInputShape(): array {
-                                       return ['input' => EShapeType::Text];
+                                       return ['input' => new ShapeDescriptor($this->l->t('Input text'), $this->l->t('The input text'), EShapeType::Text)];
                                }
 
                                public function getOutputShape(): array {
-                                       return ['output' => EShapeType::Text];
+                                       return ['output' => new ShapeDescriptor($this->l->t('Input text'), $this->l->t('The input text'), EShapeType::Text)];
                                }
                        };
                        $newTaskTypes[$taskType->getId()] = $taskType;
@@ -283,7 +287,7 @@ class Manager implements IManager {
                                        } catch (\RuntimeException $e) {
                                                throw new ProcessingException($e->getMessage(), 0, $e);
                                        }
-                                       return ['images' => array_map(fn (File $file) => base64_encode($file->getContent()), $files)];
+                                       return ['images' => array_map(fn (File $file) => $file->getContent(), $files)];
                                }
                        };
                        $newProviders[$newProvider->getId()] = $newProvider;
index 8a862fe19a16dd74a55babc50dd53f88c2c0c68b..5555671976b6779a4442589869f204ebe9f098d3 100644 (file)
@@ -50,6 +50,7 @@ enum EShapeType: int {
         * @param mixed $value
         * @return void
         * @throws ValidationException
+        * @since 30.0.0
         */
        private function validateNonFileType(mixed $value): void {
                if ($this === EShapeType::Text && !is_string($value)) {
index c84a638862dc7dc2d8dab0b2a967532db036f7de..6c14bab751e3880c816b5176a1cb183585890db0 100644 (file)
@@ -46,6 +46,7 @@ class ShapeDescriptor implements \JsonSerializable {
 
        /**
         * @return array{name: string, description: string, type: int}
+        * @since 30.0.0
         */
        public function jsonSerialize(): array {
                return [