Skip to content

Commit c0299b4

Browse files
committed
fix(psalm): Fix syntax problems
Signed-off-by: provokateurin <[email protected]>
1 parent 8de8000 commit c0299b4

File tree

6 files changed

+1206
-82
lines changed

6 files changed

+1206
-82
lines changed

lib/Controller/ApiController.php

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public function preflightedCors() {
127127
* Possible values:
128128
* - `owned`: Forms owned by the user.
129129
* - `shared`: Forms shared with the user.
130-
* @return DataResponse<array<FormsPartialForm>, Http::STATUS_OK, array<>>
130+
* @return DataResponse<Http::STATUS_OK, array<FormsPartialForm>, array{}>
131131
* @throws OCSBadRequestException wrong form type supplied
132132
*/
133133
#[CORS()]
@@ -156,7 +156,7 @@ public function getForms(string $type = 'owned'): DataResponse {
156156
* Return a copy of the form if the parameter $fromId is set
157157
*
158158
* @param ?int $fromId (optional) Id of the form that should be cloned
159-
* @return DataResponse<FormsForm, Http::STATUS_CREATED, array<>>
159+
* @return DataResponse<Http::STATUS_CREATED, FormsForm, array{}>
160160
* @throws OCSForbiddenException The user is not allowed to create forms
161161
*/
162162
#[CORS()]
@@ -231,7 +231,7 @@ public function newForm(?int $fromId = null): DataResponse {
231231
* Read all information to edit a Form (form, questions, options, except submissions/answers)
232232
*
233233
* @param int $formId Id of the form
234-
* @return DataResponse<array<FormsForm>, Http::STATUS_OK, array<>>
234+
* @return DataResponse<Http::STATUS_OK, array<FormsForm>, array{}>
235235
* @throws OCSBadRequestException Could not find form
236236
* @throws OCSForbiddenException User has no permissions to get this form
237237
*/
@@ -259,7 +259,7 @@ public function getForm(int $formId): DataResponse {
259259
*
260260
* @param int $formId FormId of form to update
261261
* @param array<string, mixed> $keyValuePairs Array of key=>value pairs to update.
262-
* @return DataResponse<int formId, Http::STATUS_OK, array<>>
262+
* @return DataResponse<Http::STATUS_OK, int, array{}>
263263
* @throws OCSBadRequestException Could not find new form owner
264264
* @throws OCSForbiddenException Empty keyValuePairs provided
265265
* @throws OCSForbiddenException Not allowed to update id, hash, created, fileId or lastUpdated. OwnerId only allowed if no other key provided.
@@ -349,7 +349,7 @@ public function updateForm(int $formId, array $keyValuePairs): DataResponse {
349349
* Delete a form
350350
*
351351
* @param int $formId the form id
352-
* @return DataResponse<int formId, Http::STATUS_OK, array<>>
352+
* @return DataResponse<Http::STATUS_OK, int, array{}>
353353
* @throws OCSForbiddenException User is not allowed to delete the form
354354
* @throws OCSNotFoundException Form not found
355355
*/
@@ -372,7 +372,7 @@ public function deleteForm(int $formId): DataResponse {
372372
* Read all questions (including options)
373373
*
374374
* @param int $formId the form id
375-
* @return DataResponse<array<FormQuestion>, Http::STATUS_OK, array<>>
375+
* @return DataResponse<Http::STATUS_OK, array<FormsQuestion>, array{}>
376376
* @throws OCSForbiddenException User has no permissions to get this form
377377
* @throws OCSNotFoundException Could not find form
378378
*/
@@ -402,7 +402,7 @@ public function getQuestions(int $formId): DataResponse {
402402
*
403403
* @param int $formId FormId
404404
* @param int $questionId QuestionId
405-
* @return DataResponse<FormQuestion, Http::STATUS_OK, array<>>
405+
* @return DataResponse<Http::STATUS_OK, FormsQuestion, array{}>
406406
* @throws OCSBadRequestException Question doesn\'t belong to given Form
407407
* @throws OCSForbiddenException User has no permissions to get this form
408408
* @throws OCSNotFoundException Could not find form
@@ -439,7 +439,7 @@ public function getQuestion(int $formId, int $questionId): DataResponse {
439439
* @param string $type the new question type
440440
* @param string $text the new question title
441441
* @param ?int $fromId (optional) id of the question that should be cloned
442-
* @return DataResponse<FormQuestion, Http::STATUS_CREATED, array<>>
442+
* @return DataResponse<Http::STATUS_CREATED, FormsQuestion, array{}>
443443
* @throws OCSBadRequestException Invalid type
444444
* @throws OCSBadRequestException Datetime question type no longer supported
445445
* @throws OCSForbiddenException User has no permissions to get this form
@@ -549,7 +549,7 @@ public function newQuestion(int $formId, ?string $type = null, string $text = ''
549549
* @param int $formId the form id
550550
* @param int $questionId id of question to update
551551
* @param array<string, mixed> $keyValuePairs Array of key=>value pairs to update.
552-
* @return DataResponse<int id, Http::STATUS_OK, array<>>
552+
* @return DataResponse<Http::STATUS_OK, int, array{}>
553553
* @throws OCSBadRequestException Question doesn\'t belong to given Form
554554
* @throws OCSBadRequestException Invalid extraSettings, will not update.
555555
* @throws OCSForbiddenException Empty keyValuePairs, will not update
@@ -590,7 +590,7 @@ public function updateQuestion(int $formId, int $questionId, array $keyValuePair
590590
// Don't allow empty array
591591
if (sizeof($keyValuePairs) === 0) {
592592
$this->logger->info('Empty keyValuePairs, will not update.');
593-
throw new OCSBacRequestException('This form is archived and can not be modified');
593+
throw new OCSBadRequestException('This form is archived and can not be modified');
594594
}
595595

596596
//Don't allow to change id or formId
@@ -625,7 +625,7 @@ public function updateQuestion(int $formId, int $questionId, array $keyValuePair
625625
*
626626
* @param int $formId the form id
627627
* @param int $questionId the question id
628-
* @return DataResponse<int id, Http::STATUS_OK, array<>>
628+
* @return DataResponse<Http::STATUS_OK, int, array{}>
629629
* @throws OCSBadRequestException Question doesn\'t belong to given Form
630630
* @throws OCSForbiddenException This form is archived and can not be modified
631631
* @throws OCSForbiddenException User has no permissions to get this form
@@ -684,7 +684,7 @@ public function deleteQuestion(int $formId, int $questionId): DataResponse {
684684
*
685685
* @param int $formId Id of the form to reorder
686686
* @param array<string, int> $newOrder Array of Question-Ids in new order.
687-
* @return DataResponse<array<int, int>, Http::STATUS_OK, array<>>
687+
* @return DataResponse<Http::STATUS_OK, array<string, int>, array{}>
688688
* @throws OCSBadRequestException The given array contains duplicates
689689
* @throws OCSBadRequestException The length of the given array does not match the number of stored questions
690690
* @throws OCSBadRequestException Question doesn\'t belong to given Form
@@ -782,7 +782,7 @@ public function reorderQuestions(int $formId, array $newOrder): DataResponse {
782782
* @param int $formId id of the form
783783
* @param int $questionId id of the question
784784
* @param array<string> $optionTexts the new option text
785-
* @return DataResponse<array<FormsOption>, Http::STATUS_CREATED, array<>> Returns a DataResponse containing the added options
785+
* @return DataResponse<Http::STATUS_CREATED, array<FormsOption>, array{}> Returns a DataResponse containing the added options
786786
* @throws OCSBadRequestException This question is not part ot the given form
787787
* @throws OCSForbiddenException This form is archived and can not be modified
788788
* @throws OCSForbiddenException Current user has no permission to edit
@@ -804,7 +804,7 @@ public function newOption(int $formId, int $questionId, array $optionTexts): Dat
804804
$this->logger->debug('This form is archived and can not be modified');
805805
throw new OCSForbiddenException('This form is archived and can not be modified');
806806
}
807-
807+
808808
try {
809809
$question = $this->questionMapper->findById($questionId);
810810
} catch (IMapperException $e) {
@@ -858,7 +858,7 @@ public function newOption(int $formId, int $questionId, array $optionTexts): Dat
858858
* @param int $questionId id of question
859859
* @param int $optionId id of option to update
860860
* @param array{key: string, value: mixed} $keyValuePairs Array of key=>value pairs to update.
861-
* @return DataResponse<id: int, Http::STATUS_OK, array<>> Returns the id of the updated option
861+
* @return DataResponse<Http::STATUS_OK, int, array{}> Returns the id of the updated option
862862
* @throws OCSBadRequestException The given option id doesn't match the question or form
863863
* @throws OCSForbiddenException This form is archived and can not be modified
864864
* @throws OCSForbiddenException Current user has no permission to edit
@@ -927,7 +927,7 @@ public function updateOption(int $formId, int $questionId, int $optionId, array
927927
* @param int $formId id of form
928928
* @param int $questionId id of question
929929
* @param int $optionId id of option to update
930-
* @return DataResponse<id: int, Http::STATUS_OK, array<>> Returns the id of the deleted option
930+
* @return DataResponse<Http::STATUS_OK, int, array{}> Returns the id of the deleted option
931931
* @throws OCSBadRequestException The given option id doesn't match the question or form
932932
* @throws OCSForbiddenException This form is archived and can not be modified
933933
* @throws OCSForbiddenException Current user has no permission to edit
@@ -947,7 +947,7 @@ public function deleteOption(int $formId, int $questionId, int $optionId): DataR
947947
$this->logger->debug('This form is archived and can not be modified');
948948
throw new OCSForbiddenException('This form is archived and can not be modified');
949949
}
950-
950+
951951
try {
952952
$option = $this->optionMapper->findById($optionId);
953953
$question = $this->questionMapper->findById($questionId);
@@ -981,7 +981,7 @@ public function deleteOption(int $formId, int $questionId, int $optionId): DataR
981981
* @param int $formId id of form
982982
* @param int $questionId id of question
983983
* @param array<string, int> $newOrder Array of option ids in new order.
984-
* @return DataResponse<array<int, int>, Http::STATUS_OK, array<>>
984+
* @return DataResponse<Http::STATUS_OK, array<string, int>, array{}>
985985
* @throws OCSBadRequestException The given question id doesn't match the form
986986
* @throws OCSBadRequestException The given array contains duplicates
987987
* @throws OCSBadRequestException The length of the given array does not match the number of stored options
@@ -1018,14 +1018,14 @@ public function reorderOptions(int $formId, int $questionId, array $newOrder) {
10181018
$this->logger->debug('The given array contains duplicates');
10191019
throw new OCSBadRequestException('The given array contains duplicates');
10201020
}
1021-
1021+
10221022
$options = $this->optionMapper->findByQuestion($questionId);
1023-
1023+
10241024
if (sizeof($options) !== sizeof($newOrder)) {
10251025
$this->logger->debug('The length of the given array does not match the number of stored options');
10261026
throw new OCSBadRequestException('The length of the given array does not match the number of stored options');
10271027
}
1028-
1028+
10291029
$options = []; // Clear Array of Entities
10301030
$response = []; // Array of ['optionId' => ['order' => newOrder]]
10311031

@@ -1061,13 +1061,13 @@ public function reorderOptions(int $formId, int $questionId, array $newOrder) {
10611061
foreach ($options as $option) {
10621062
$this->optionMapper->update($option);
10631063

1064-
$response[$option->getId()] = [
1064+
$response[(string)$option->getId()] = [
10651065
'order' => $option->getOrder()
10661066
];
10671067
}
10681068

10691069
$this->formMapper->update($form);
1070-
1070+
10711071
return new DataResponse($response);
10721072
}
10731073

@@ -1082,7 +1082,7 @@ public function reorderOptions(int $formId, int $questionId, array $newOrder) {
10821082
* - `csv`: Comma-separated value
10831083
* - `ods`: OpenDocument Spreadsheet
10841084
* - `xlsx`: Excel Open XML Spreadsheet
1085-
* @return DataResponse|DataDownloadResponse<FormsSubmissions, Http::STATUS_OK, array<>>
1085+
* @return DataResponse<Http::STATUS_OK, FormsSubmissions, array{}>|DataDownloadResponse<Http::STATUS_OK, 'text/csv'|'application/vnd.oasis.opendocument.spreadsheet'|'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', array{}>
10861086
* @throws OCSNotFoundException Could not find form
10871087
* @throws OCSForbiddenException The current user has no permission to get the results for this form
10881088
*/
@@ -1143,7 +1143,7 @@ public function getSubmissions(int $formId, ?string $fileFormat = null): DataRes
11431143
* Delete all submissions of a specified form
11441144
*
11451145
* @param int $formId the form id
1146-
* @return DataResponse<int: formId, Http::STATUS_OK, array<>>
1146+
* @return DataResponse<Http::STATUS_OK, int, array{}>
11471147
* @throws OCSNotFoundException Could not find form
11481148
* @throws OCSForbiddenException This form is not owned by the current user and user has no `results_delete` permission
11491149
*/
@@ -1181,7 +1181,7 @@ public function deleteAllSubmissions(int $formId): DataResponse {
11811181
* @param int $formId the form id
11821182
* @param array<string, array<string>> $answers [question_id => arrayOfString]
11831183
* @param string $shareHash public share-hash -> Necessary to submit on public link-shares.
1184-
* @return DataResponse<array<>, Http::STATUS_CREATED, array<>>
1184+
* @return DataResponse<Http::STATUS_CREATED, null, array{}>
11851185
* @throws OCSBadRequestException At least one submitted answer is not valid
11861186
* @throws OCSForbiddenException Already submitted
11871187
* @throws OCSForbiddenException Not allowed to access this form
@@ -1280,7 +1280,7 @@ public function newSubmission(int $formId, array $answers, string $shareHash = '
12801280
*
12811281
* @param int $formId the form id
12821282
* @param int $submissionId the submission id
1283-
* @return DataResponse<int: submissionId, Http::STATUS_OK, array<>>
1283+
* @return DataResponse<Http::STATUS_OK, int, array{}>
12841284
* @throws OCSBadRequestException Submission doesn't belong to given form
12851285
* @throws OCSNotFoundException Could not find form or submission
12861286
* @throws OCSForbiddenException This form is not owned by the current user and user has no `results_delete` permission
@@ -1325,7 +1325,7 @@ public function deleteSubmission(int $formId, int $submissionId): DataResponse {
13251325
* @param int $formId of the form
13261326
* @param string $path The Cloud-Path to export to
13271327
* @param string $fileFormat File format used for export
1328-
* @return DataResponse<string: fileName, Http::STATUS_OK, array<>>
1328+
* @return DataResponse<Http::STATUS_OK, string, array{}>
13291329
* @throws OCSForbiddenException The current user has no permission to get the results for this form
13301330
* @throws OCSNotFoundException Could not find form
13311331
*/
@@ -1356,7 +1356,7 @@ public function exportSubmissionsToCloud(int $formId, string $path, string $file
13561356
* @param int $formId id of the form
13571357
* @param int $questionId id of the question
13581358
* @param string $shareHash hash of the form share
1359-
* @return DataResponse<FormsUploadedFile, Http::STATUS_OK, array<>>
1359+
* @return DataResponse<Http::STATUS_OK, FormsUploadedFile, array{}>
13601360
* @throws OCSBadRequestException No files provided
13611361
* @throws OCSBadRequestException Question doesn't belong to the given form
13621362
* @throws OCSBadRequestException Invalid file provided

lib/Controller/ConfigController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
use OCP\AppFramework\ApiController;
3131
use OCP\AppFramework\Http;
3232
use OCP\AppFramework\Http\Attribute\FrontpageRoute;
33+
use OCP\AppFramework\Http\Attribute\OpenAPI;
3334
use OCP\AppFramework\Http\DataResponse;
3435
use OCP\IConfig;
3536
use OCP\IRequest;

lib/Controller/PageController.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
use OCP\AppFramework\Http\Attribute\FrontpageRoute;
4040
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
4141
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
42+
use OCP\AppFramework\Http\Attribute\OpenAPI;
4243
use OCP\AppFramework\Http\Attribute\PublicPage;
4344
use OCP\AppFramework\Http\ContentSecurityPolicy;
4445
use OCP\AppFramework\Http\RedirectResponse;
@@ -171,9 +172,9 @@ public function embeddedFormView(string $hash): Response {
171172
Util::addStyle($this->appName, 'embedded');
172173
$response = $this->createPublicSubmitView($form, $hash)
173174
->renderAs(TemplateResponse::RENDER_AS_BASE);
174-
175+
175176
$this->initialState->provideInitialState('isEmbedded', true);
176-
177+
177178
return $this->setEmbeddedCSP($response);
178179
}
179180

lib/Controller/ShareApiController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public function __construct(
9595
* - `submit` user can submit
9696
* - `results` user can see the results
9797
* - `results_delete` user can see and delete results
98-
* @return DataResponse<array<FormsShare>, Http::STATUS_CREATED, array<>>
98+
* @return DataResponse<Http::STATUS_CREATED, FormsShare, array{}>
9999
* @throws OCSBadRequestException Invalid shareType
100100
* @throws OCSBadRequestException Invalid permission given
101101
* @throws OCSBadRequestException Invalid user to share with
@@ -230,7 +230,7 @@ public function newShare(int $formId, int $shareType, string $shareWith = '', ar
230230
* @param int $formId of the form
231231
* @param int $shareId of the share to update
232232
* @param array{key: string, values: mixed} $keyValuePairs Array of key=>value pairs to update.
233-
* @return DataResponse<array<int>, Http::STATUS_OK, array<>>
233+
* @return DataResponse<Http::STATUS_OK, int, array{}>
234234
* @throws OCSBadRequestException Share doesn't belong to given Form
235235
* @throws OCSBadRequestException Invalid permission given
236236
* @throws OCSForbiddenException This form is not owned by the current user
@@ -325,7 +325,7 @@ public function updateShare(int $formId, int $shareId, array $keyValuePairs): Da
325325
*
326326
* @param int $formId of the form
327327
* @param int $shareId of the share to delete
328-
* @return DataResponse<array<int>, Http::STATUS_OK, array<>>
328+
* @return DataResponse<Http::STATUS_OK, int, array{}>
329329
* @throws OCSBadRequestException Share doesn't belong to given Form
330330
* @throws OCSForbiddenException This form is not owned by the current user
331331
* @throws OCSNotFoundException Could not find share

0 commit comments

Comments
 (0)