diff --git a/lib/Controller/BoardController.php b/lib/Controller/BoardController.php index 1b17071b7..39739a4e4 100644 --- a/lib/Controller/BoardController.php +++ b/lib/Controller/BoardController.php @@ -166,7 +166,7 @@ public function import(): DataResponse { if (!empty($file) && array_key_exists('error', $file) && $file['error'] !== UPLOAD_ERR_OK) { $error = $phpFileUploadErrors[$file['error']]; } - if (!empty($file) && $file['error'] === UPLOAD_ERR_OK && !in_array($file['type'], ['application/json', 'text/plain'])) { + if (!empty($file) && $file['error'] === UPLOAD_ERR_OK && !in_array($file['type'], ['application/json', 'text/plain'], true)) { $error = $this->l10n->t('Invalid file type. Only JSON files are allowed.'); } if ($error !== null) { diff --git a/lib/Db/LabelMapper.php b/lib/Db/LabelMapper.php index 01031acd2..717f6c4bb 100644 --- a/lib/Db/LabelMapper.php +++ b/lib/Db/LabelMapper.php @@ -90,7 +90,7 @@ public function findAssignedLabelsForBoard(int $boardId, ?int $limit = null, int } public function insert(Entity $entity): Entity { - if (!in_array('lastModified', $entity->getUpdatedFields())) { + if (!isset($entity->getUpdatedFields()['lastModified'])) { $entity->setLastModified(time()); } return parent::insert($entity); diff --git a/lib/Listeners/CommentEventListener.php b/lib/Listeners/CommentEventListener.php index 5c02711a2..6392123a6 100644 --- a/lib/Listeners/CommentEventListener.php +++ b/lib/Listeners/CommentEventListener.php @@ -49,7 +49,7 @@ public function handle(Event $event): void { $applicableEvents = [ CommentsEvent::EVENT_UPDATE ]; - if (in_array($eventType, $applicableEvents)) { + if (in_array($eventType, $applicableEvents, true)) { $this->notificationHandler($event); return; } diff --git a/lib/Service/BoardService.php b/lib/Service/BoardService.php index d1ca7589e..1492ae9b0 100644 --- a/lib/Service/BoardService.php +++ b/lib/Service/BoardService.php @@ -541,7 +541,7 @@ public function clone( foreach ($stacks as $stack) { $newStack = new Stack(); $newStack->setTitle($stack->getTitle()); - if ($stack->getOrder() == null) { + if ($stack->getOrder() === null) { $newStack->setOrder(999); } else { $newStack->setOrder($stack->getOrder()); diff --git a/lib/Service/CardService.php b/lib/Service/CardService.php index 73cb65049..d8ca9adc0 100644 --- a/lib/Service/CardService.php +++ b/lib/Service/CardService.php @@ -279,7 +279,7 @@ public function update(int $id, string $title, int $stackId, string $type, strin $resetDuedateNotification = false; if ( $card->getDuedate() === null - || ($card->getDuedate()) != ($changes->getBefore()->getDuedate()) + || ($card->getDuedate()) !== ($changes->getBefore()->getDuedate()) ) { $card->setNotified(false); $resetDuedateNotification = true; @@ -357,7 +357,7 @@ public function cloneCard(int $id, ?int $targetStackId = null):Card { $newCard = $this->create($originCard->getTitle(), $targetStackId, $originCard->getType(), $originCard->getOrder(), $originCard->getOwner()); $boardId = $this->stackMapper->findBoardId($targetStackId); foreach ($this->labelMapper->findAssignedLabelsForCard($id) as $label) { - if ($boardId != $this->stackMapper->findBoardId($originCard->getStackId())) { + if ($boardId !== $this->stackMapper->findBoardId($originCard->getStackId())) { try { $label = $this->labelService->cloneLabelIfNotExists($label->getId(), $boardId); } catch (NoPermissionException $e) { diff --git a/lib/Service/DefaultBoardService.php b/lib/Service/DefaultBoardService.php index caeffafd0..211c20070 100644 --- a/lib/Service/DefaultBoardService.php +++ b/lib/Service/DefaultBoardService.php @@ -136,7 +136,7 @@ public function createDefaultBoard(string $title, string $userId, string $color) ); foreach ($defaultLabels as $defaultLabel) { - if ($defaultLabel && in_array($defaultLabel->getTitle(), $cardData['labels'])) { + if ($defaultLabel && in_array($defaultLabel->getTitle(), $cardData['labels'], true)) { $this->cardService->assignLabel($card->getId(), $defaultLabel->getId()); } } diff --git a/lib/Service/Importer/BoardImportService.php b/lib/Service/Importer/BoardImportService.php index 26d8adb24..b47f011db 100644 --- a/lib/Service/Importer/BoardImportService.php +++ b/lib/Service/Importer/BoardImportService.php @@ -38,6 +38,7 @@ class BoardImportService { private string $system = ''; private ?ABoardImportService $systemInstance = null; + /** @var list */ private array $allowedSystems = []; /** * Data object created from config JSON @@ -137,16 +138,12 @@ public function import(): void { public function validateSystem(): void { $allowedSystems = $this->getAllowedImportSystems(); $allowedSystems = array_column($allowedSystems, 'internalName'); - if (!in_array($this->getSystem(), $allowedSystems)) { + if (!in_array($this->getSystem(), $allowedSystems, true)) { throw new NotFoundException('Invalid system: ' . $this->getSystem()); } } - /** - * @param ?string $system - * @return self - */ - public function setSystem($system): self { + public function setSystem(?string $system): self { if ($system) { $this->system = $system; } @@ -157,11 +154,17 @@ public function getSystem(): string { return $this->system; } - public function addAllowedImportSystem($system): self { + /** + * @param array{name: string, class: class-string, internalName: string} $system + */ + public function addAllowedImportSystem(array $system): self { $this->allowedSystems[] = $system; return $this; } + /** + * @return list + */ public function getAllowedImportSystems(): array { if (!$this->allowedSystems) { $this->addAllowedImportSystem([ diff --git a/lib/Service/Importer/Systems/TrelloJsonService.php b/lib/Service/Importer/Systems/TrelloJsonService.php index 5d6d2373c..dc7acd8b1 100644 --- a/lib/Service/Importer/Systems/TrelloJsonService.php +++ b/lib/Service/Importer/Systems/TrelloJsonService.php @@ -165,7 +165,7 @@ function (\stdClass $a) use ($trelloCard) { private function sortComments(array $comments): array { $comparison = function (\stdClass $a, \stdClass $b): int { - if ($a->date == $b->date) { + if ($a->date === $b->date) { return 0; } return ($a->date < $b->date) ? -1 : 1; @@ -352,7 +352,7 @@ private function replaceUsernames(string $text): string { } private function checklistItem(\stdClass $item): string { - if (($item->state == 'incomplete')) { + if (($item->state === 'incomplete')) { $string_start = '- [ ]'; } else { $string_start = '- [x]'; diff --git a/lib/Validators/BaseValidator.php b/lib/Validators/BaseValidator.php index 6ae05d4a9..55e2d47e6 100644 --- a/lib/Validators/BaseValidator.php +++ b/lib/Validators/BaseValidator.php @@ -152,13 +152,12 @@ protected function getSize($value): int { } /** - * @param $rule * @param $field * @param $parameter * @return string */ - protected function getErrorMessage($rule, $field, $parameter = null): string { - if (in_array($rule, ['max', 'min'])) { + protected function getErrorMessage(string $rule, $field, $parameter = null): string { + if (in_array($rule, ['max', 'min'], true)) { return $rule === 'max' ? $field . ' cannot be longer than ' . $parameter . ' characters ' : $field . ' must be at least ' . $parameter . ' characters long '; diff --git a/tests/integration/base-query-count.txt b/tests/integration/base-query-count.txt index b375f5f94..93e564594 100644 --- a/tests/integration/base-query-count.txt +++ b/tests/integration/base-query-count.txt @@ -1 +1 @@ -83517 +84323 diff --git a/tests/integration/import/ImportExportTest.php b/tests/integration/import/ImportExportTest.php index 1d7b5d52b..436ec7212 100644 --- a/tests/integration/import/ImportExportTest.php +++ b/tests/integration/import/ImportExportTest.php @@ -140,7 +140,7 @@ public static function writeArrayStructure(string $prefix = '', array $array = [ $arrayIsList = array_keys($array) === range(0, count($array) - 1); foreach ($array as $key => $value) { $tmpPrefix = $prefix; - if (in_array($key, $skipKeyList)) { + if (in_array($key, $skipKeyList, true)) { continue; } if (is_array($value)) {