@@ -335,7 +335,7 @@ public function updateForm(int $formId, array $keyValuePairs): DataResponse {
335335 }
336336
337337 // Process file unlinking
338- if (key_exists ('fileId ' , $ keyValuePairs ) && key_exists ('fileFormat ' , $ keyValuePairs ) && !isset ($ keyValuePairs ['fileFormat ' ])) {
338+ if (array_key_exists ('fileId ' , $ keyValuePairs ) && array_key_exists ('fileFormat ' , $ keyValuePairs ) && !isset ($ keyValuePairs ['fileFormat ' ])) {
339339 $ form ->setFileId (null );
340340 $ form ->setFileFormat (null );
341341 }
@@ -673,24 +673,24 @@ public function updateQuestion(int $formId, int $questionId, array $keyValuePair
673673 }
674674
675675 // Don't allow empty array
676- if (sizeof ($ keyValuePairs ) === 0 ) {
676+ if (count ($ keyValuePairs ) === 0 ) {
677677 $ this ->logger ->info ('Empty keyValuePairs, will not update. ' );
678678 throw new OCSBadRequestException ('This form is archived and can not be modified ' );
679679 }
680680
681681 //Don't allow to change id or formId
682- if (key_exists ('id ' , $ keyValuePairs ) || key_exists ('formId ' , $ keyValuePairs )) {
682+ if (array_key_exists ('id ' , $ keyValuePairs ) || array_key_exists ('formId ' , $ keyValuePairs )) {
683683 $ this ->logger ->debug ('Not allowed to update \'id \' or \'formId \'' );
684684 throw new OCSForbiddenException ('Not allowed to update \'id \' or \'formId \'' );
685685 }
686686
687687 // Don't allow to reorder here
688- if (key_exists ('order ' , $ keyValuePairs )) {
688+ if (array_key_exists ('order ' , $ keyValuePairs )) {
689689 $ this ->logger ->debug ('Key \'order \' is not allowed on updateQuestion. Please use reorderQuestions() to change order. ' );
690690 throw new OCSForbiddenException ('Please use reorderQuestions() to change order ' );
691691 }
692692
693- if (key_exists ('extraSettings ' , $ keyValuePairs ) && !$ this ->formsService ->areExtraSettingsValid ($ keyValuePairs ['extraSettings ' ], $ question ->getType ())) {
693+ if (array_key_exists ('extraSettings ' , $ keyValuePairs ) && !$ this ->formsService ->areExtraSettingsValid ($ keyValuePairs ['extraSettings ' ], $ question ->getType ())) {
694694 throw new OCSBadRequestException ('Invalid extraSettings, will not update. ' );
695695 }
696696
@@ -829,7 +829,7 @@ public function reorderQuestions(int $formId, array $newOrder): DataResponse {
829829
830830 // Check if all questions are given in Array.
831831 $ questions = $ this ->questionMapper ->findByForm ($ formId );
832- if (sizeof ($ questions ) !== sizeof ($ newOrder )) {
832+ if (count ($ questions ) !== count ($ newOrder )) {
833833 $ this ->logger ->debug ('The length of the given array does not match the number of stored questions ' );
834834 throw new OCSBadRequestException ('The length of the given array does not match the number of stored questions ' );
835835 }
@@ -1023,13 +1023,13 @@ public function updateOption(int $formId, int $questionId, int $optionId, array
10231023 }
10241024
10251025 // Don't allow empty array
1026- if (sizeof ($ keyValuePairs ) === 0 ) {
1026+ if (count ($ keyValuePairs ) === 0 ) {
10271027 $ this ->logger ->info ('Empty keyValuePairs, will not update ' );
10281028 throw new OCSForbiddenException ('Empty keyValuePairs, will not update ' );
10291029 }
10301030
10311031 //Don't allow to change id or questionId
1032- if (key_exists ('id ' , $ keyValuePairs ) || key_exists ('questionId ' , $ keyValuePairs )) {
1032+ if (array_key_exists ('id ' , $ keyValuePairs ) || array_key_exists ('questionId ' , $ keyValuePairs )) {
10331033 $ this ->logger ->debug ('Not allowed to update id or questionId ' );
10341034 throw new OCSForbiddenException ('Not allowed to update id or questionId ' );
10351035 }
@@ -1157,7 +1157,7 @@ public function reorderOptions(int $formId, int $questionId, array $newOrder, ?s
11571157
11581158 $ options = $ this ->optionMapper ->findByQuestion ($ questionId , $ optionType );
11591159
1160- if (sizeof ($ options ) !== sizeof ($ newOrder )) {
1160+ if (count ($ options ) !== count ($ newOrder )) {
11611161 $ this ->logger ->debug ('The length of the given array does not match the number of stored options ' );
11621162 throw new OCSBadRequestException ('The length of the given array does not match the number of stored options ' );
11631163 }
@@ -1925,7 +1925,7 @@ private function checkArchivePermission(Form $form, string $currentUserId, array
19251925 $ isOwner = $ currentUserId === $ form ->getOwnerId ();
19261926
19271927 // If the request contains 'state' it must be the only key
1928- if (sizeof ($ keyValuePairs ) !== 1 ) {
1928+ if (count ($ keyValuePairs ) !== 1 ) {
19291929 $ this ->logger ->debug ('State may only be changed on its own ' );
19301930 throw new OCSForbiddenException ('State may only be changed on its own ' );
19311931 }
@@ -1944,19 +1944,19 @@ private function checkArchivePermission(Form $form, string $currentUserId, array
19441944 }
19451945
19461946 private function isLockingRequest (array $ keyValuePairs ): bool {
1947- return sizeof ($ keyValuePairs ) === 1
1947+ return count ($ keyValuePairs ) === 1
19481948 && array_key_exists ('lockedUntil ' , $ keyValuePairs )
19491949 && $ keyValuePairs ['lockedUntil ' ] === 0 ;
19501950 }
19511951
19521952 private function isUnlockingRequest (array $ keyValuePairs ): bool {
1953- return sizeof ($ keyValuePairs ) === 1
1953+ return count ($ keyValuePairs ) === 1
19541954 && array_key_exists ('lockedUntil ' , $ keyValuePairs )
19551955 && is_null ($ keyValuePairs ['lockedUntil ' ]);
19561956 }
19571957
19581958 private function isOwnerTransferRequest (array $ keyValuePairs ): bool {
1959- return sizeof ($ keyValuePairs ) === 1 && key_exists ('ownerId ' , $ keyValuePairs );
1959+ return count ($ keyValuePairs ) === 1 && array_key_exists ('ownerId ' , $ keyValuePairs );
19601960 }
19611961
19621962 /**
0 commit comments