Skip to content

Commit

Permalink
Configure linter ignored lines
Browse files Browse the repository at this point in the history
These temporary attributes are used for convenience and I think
it's valid to ignore these linter errors.
  • Loading branch information
mzur committed Dec 20, 2024
1 parent e9ecd73 commit ae206a0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/Services/Export/VolumeExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -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([]);
Expand Down
4 changes: 3 additions & 1 deletion app/Services/Import/LabelTreeImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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');

Expand All @@ -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']);
Expand Down
3 changes: 3 additions & 0 deletions app/Services/Import/VolumeImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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;
Expand Down

0 comments on commit ae206a0

Please sign in to comment.