From ae206a074f33fee1875f57e2ad18fbcba8251f45 Mon Sep 17 00:00:00 2001 From: Martin Zurowietz Date: Fri, 20 Dec 2024 11:40:47 +0100 Subject: [PATCH] Configure linter ignored lines These temporary attributes are used for convenience and I think it's valid to ignore these linter errors. --- app/Services/Export/VolumeExport.php | 1 + app/Services/Import/LabelTreeImport.php | 4 +++- app/Services/Import/VolumeImport.php | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/Services/Export/VolumeExport.php b/app/Services/Export/VolumeExport.php index 75ead29bc..5a265e71d 100644 --- a/app/Services/Export/VolumeExport.php +++ b/app/Services/Export/VolumeExport.php @@ -22,6 +22,7 @@ public function getContent() ]) ->get() ->each(function ($volume) { + /** @phpstan-ignore-next-line */ $volume->media_type_name = $volume->mediaType->name; $volume->setHidden(['media_type_id', 'mediaType']); $volume->setAppends([]); diff --git a/app/Services/Import/LabelTreeImport.php b/app/Services/Import/LabelTreeImport.php index a54e3aae2..8a593b3f2 100644 --- a/app/Services/Import/LabelTreeImport.php +++ b/app/Services/Import/LabelTreeImport.php @@ -51,7 +51,7 @@ public function perform(array $onlyTrees = null, array $onlyLabels = null, array $this->attachLabelTreeMembers($insertTrees, $labelTreeIdMap, $userIdMap); $labelCandidates = $this->getInsertLabels($onlyLabels, $labelTreeIdMap); - $labelHasConflict = fn ($label) => array_key_exists('conflicting_name', $label) || array_key_exists('conflicting_parent_id', $label); + $labelHasConflict = fn (array $label) => array_key_exists('conflicting_name', $label) || array_key_exists('conflicting_parent_id', $label); $insertLabels = $labelCandidates->reject($labelHasConflict); // Insert all labels with parent_id null first. @@ -142,6 +142,7 @@ public function getLabelImportCandidates() // Add the parent_uuid property of existing labels. $existingLabels = $existingLabels->each(function ($label) use ($existingLabels) { $parent = $existingLabels->get($label->parent_id); + /** @phpstan-ignore-next-line */ $label->parent_uuid = $parent ? $parent->uuid : null; })->keyBy('uuid'); @@ -159,6 +160,7 @@ public function getLabelImportCandidates() unset($label['discard']); } + /** @phpstan-ignore-next-line */ if ($existingLabel->parent_uuid !== $label['parent_uuid']) { $label['conflicting_parent_id'] = $existingLabel->parent_id; unset($label['discard']); diff --git a/app/Services/Import/VolumeImport.php b/app/Services/Import/VolumeImport.php index fa767ffa6..5a7771100 100644 --- a/app/Services/Import/VolumeImport.php +++ b/app/Services/Import/VolumeImport.php @@ -441,6 +441,7 @@ protected function insertVolumes(Collection $candidates, User $creator, array $n return $candidates ->map(function ($candidate) use ($creator, $newUrls, $mediaTypes) { $volume = new Volume; + /** @phpstan-ignore-next-line */ $volume->old_id = $candidate['id']; $volume->name = $candidate['name']; if (array_key_exists($volume->old_id, $newUrls)) { @@ -463,9 +464,11 @@ protected function insertVolumes(Collection $candidates, User $creator, array $n }) ->map(function ($volume) { // Save volumes only after all of them have validated their URLs. + /** @phpstan-ignore-next-line */ $oldId = $volume->old_id; unset($volume->old_id); $volume->save(); + /** @phpstan-ignore-next-line */ $volume->old_id = $oldId; return $volume;