Skip to content

Commit e141f2e

Browse files
CarlSchwangrnd-alt
authored andcommitted
fix: Use strict comparaison
Signed-off-by: Carl Schwan <carlschwan@kde.org>
1 parent 94f19b8 commit e141f2e

11 files changed

Lines changed: 23 additions & 20 deletions

File tree

.php-cs-fixer.cache

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

lib/Controller/BoardController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public function import(): DataResponse {
166166
if (!empty($file) && array_key_exists('error', $file) && $file['error'] !== UPLOAD_ERR_OK) {
167167
$error = $phpFileUploadErrors[$file['error']];
168168
}
169-
if (!empty($file) && $file['error'] === UPLOAD_ERR_OK && !in_array($file['type'], ['application/json', 'text/plain'])) {
169+
if (!empty($file) && $file['error'] === UPLOAD_ERR_OK && !in_array($file['type'], ['application/json', 'text/plain'], true)) {
170170
$error = $this->l10n->t('Invalid file type. Only JSON files are allowed.');
171171
}
172172
if ($error !== null) {

lib/Db/LabelMapper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function findAssignedLabelsForBoard(int $boardId, ?int $limit = null, int
9090
}
9191

9292
public function insert(Entity $entity): Entity {
93-
if (!in_array('lastModified', $entity->getUpdatedFields())) {
93+
if (!in_array('lastModified', $entity->getUpdatedFields(), true)) {
9494
$entity->setLastModified(time());
9595
}
9696
return parent::insert($entity);

lib/Listeners/CommentEventListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function handle(Event $event): void {
4949
$applicableEvents = [
5050
CommentsEvent::EVENT_UPDATE
5151
];
52-
if (in_array($eventType, $applicableEvents)) {
52+
if (in_array($eventType, $applicableEvents, true)) {
5353
$this->notificationHandler($event);
5454
return;
5555
}

lib/Service/BoardService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ public function clone(
541541
foreach ($stacks as $stack) {
542542
$newStack = new Stack();
543543
$newStack->setTitle($stack->getTitle());
544-
if ($stack->getOrder() == null) {
544+
if ($stack->getOrder() === null) {
545545
$newStack->setOrder(999);
546546
} else {
547547
$newStack->setOrder($stack->getOrder());

lib/Service/CardService.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ public function update(int $id, string $title, int $stackId, string $type, strin
279279
$resetDuedateNotification = false;
280280
if (
281281
$card->getDuedate() === null
282-
|| ($card->getDuedate()) != ($changes->getBefore()->getDuedate())
282+
|| ($card->getDuedate()) !== ($changes->getBefore()->getDuedate())
283283
) {
284284
$card->setNotified(false);
285285
$resetDuedateNotification = true;
@@ -357,7 +357,7 @@ public function cloneCard(int $id, ?int $targetStackId = null):Card {
357357
$newCard = $this->create($originCard->getTitle(), $targetStackId, $originCard->getType(), $originCard->getOrder(), $originCard->getOwner());
358358
$boardId = $this->stackMapper->findBoardId($targetStackId);
359359
foreach ($this->labelMapper->findAssignedLabelsForCard($id) as $label) {
360-
if ($boardId != $this->stackMapper->findBoardId($originCard->getStackId())) {
360+
if ($boardId !== $this->stackMapper->findBoardId($originCard->getStackId())) {
361361
try {
362362
$label = $this->labelService->cloneLabelIfNotExists($label->getId(), $boardId);
363363
} catch (NoPermissionException $e) {

lib/Service/DefaultBoardService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public function createDefaultBoard(string $title, string $userId, string $color)
136136
);
137137

138138
foreach ($defaultLabels as $defaultLabel) {
139-
if ($defaultLabel && in_array($defaultLabel->getTitle(), $cardData['labels'])) {
139+
if ($defaultLabel && in_array($defaultLabel->getTitle(), $cardData['labels'], true)) {
140140
$this->cardService->assignLabel($card->getId(), $defaultLabel->getId());
141141
}
142142
}

lib/Service/Importer/BoardImportService.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
class BoardImportService {
3939
private string $system = '';
4040
private ?ABoardImportService $systemInstance = null;
41+
/** @var list<array{name: string, class: class-string, internalName: string}> */
4142
private array $allowedSystems = [];
4243
/**
4344
* Data object created from config JSON
@@ -137,16 +138,12 @@ public function import(): void {
137138
public function validateSystem(): void {
138139
$allowedSystems = $this->getAllowedImportSystems();
139140
$allowedSystems = array_column($allowedSystems, 'internalName');
140-
if (!in_array($this->getSystem(), $allowedSystems)) {
141+
if (!in_array($this->getSystem(), $allowedSystems, true)) {
141142
throw new NotFoundException('Invalid system: ' . $this->getSystem());
142143
}
143144
}
144145

145-
/**
146-
* @param ?string $system
147-
* @return self
148-
*/
149-
public function setSystem($system): self {
146+
public function setSystem(?string $system): self {
150147
if ($system) {
151148
$this->system = $system;
152149
}
@@ -157,11 +154,17 @@ public function getSystem(): string {
157154
return $this->system;
158155
}
159156

160-
public function addAllowedImportSystem($system): self {
157+
/**
158+
* @param array{name: string, class: class-string, internalName: string} $system
159+
*/
160+
public function addAllowedImportSystem(array $system): self {
161161
$this->allowedSystems[] = $system;
162162
return $this;
163163
}
164164

165+
/**
166+
* @return list<array{name: string, class: class-string, internalName: string}>
167+
*/
165168
public function getAllowedImportSystems(): array {
166169
if (!$this->allowedSystems) {
167170
$this->addAllowedImportSystem([

lib/Service/Importer/Systems/TrelloJsonService.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ function (\stdClass $a) use ($trelloCard) {
165165

166166
private function sortComments(array $comments): array {
167167
$comparison = function (\stdClass $a, \stdClass $b): int {
168-
if ($a->date == $b->date) {
168+
if ($a->date === $b->date) {
169169
return 0;
170170
}
171171
return ($a->date < $b->date) ? -1 : 1;
@@ -352,7 +352,7 @@ private function replaceUsernames(string $text): string {
352352
}
353353

354354
private function checklistItem(\stdClass $item): string {
355-
if (($item->state == 'incomplete')) {
355+
if (($item->state === 'incomplete')) {
356356
$string_start = '- [ ]';
357357
} else {
358358
$string_start = '- [x]';

lib/Validators/BaseValidator.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,12 @@ protected function getSize($value): int {
152152
}
153153

154154
/**
155-
* @param $rule
156155
* @param $field
157156
* @param $parameter
158157
* @return string
159158
*/
160-
protected function getErrorMessage($rule, $field, $parameter = null): string {
161-
if (in_array($rule, ['max', 'min'])) {
159+
protected function getErrorMessage(string $rule, $field, $parameter = null): string {
160+
if (in_array($rule, ['max', 'min'], true)) {
162161
return $rule === 'max'
163162
? $field . ' cannot be longer than ' . $parameter . ' characters '
164163
: $field . ' must be at least ' . $parameter . ' characters long ';

0 commit comments

Comments
 (0)