From 31122b7d4e8d0b27285e18ed9be24fed92b87d45 Mon Sep 17 00:00:00 2001 From: fabiodalez-dev Date: Fri, 26 Jun 2026 18:34:28 +0200 Subject: [PATCH] fix(books): drop dead "already set" guard on scraped traduttore/illustratore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PHPStan level 5 flagged BookRepository's scraped-field merge: the `!isset($cols['traduttore'])` / `!isset($cols['illustratore'])` guards are dead code — no earlier branch assigns those keys, so the condition is always true (isset.offset → impossibleType). Unlike the sibling fields (ean, collana, data_pubblicazione) which a prior branch can set, traduttore/illustratore are assigned only here, so the guard never fires. Remove the redundant guard (behavior-identical: the removed condition was always true) so the project-wide PHPStan gate is green again. Verified: php -l clean, `phpstan analyse` (level 5) reports no errors across the whole project. --- app/Models/BookRepository.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/Models/BookRepository.php b/app/Models/BookRepository.php index d6f3fb5e..bc647023 100644 --- a/app/Models/BookRepository.php +++ b/app/Models/BookRepository.php @@ -1205,10 +1205,13 @@ public function updateOptionals(int $bookId, array $data): void $cols['numero_serie'] = $seriesNum; } } - if ($this->hasColumn('traduttore') && !isset($cols['traduttore']) && !empty($data['scraped_translator'])) { + // No earlier branch sets $cols['traduttore']/'illustratore', so the + // "not already set" guard the sibling fields use would be dead code here + // (and PHPStan flags it as impossibleType). Assign directly when scraped. + if ($this->hasColumn('traduttore') && !empty($data['scraped_translator'])) { $cols['traduttore'] = \App\Support\AuthorNormalizer::normalize((string) $data['scraped_translator']); } - if ($this->hasColumn('illustratore') && !isset($cols['illustratore']) && !empty($data['scraped_illustrator'])) { + if ($this->hasColumn('illustratore') && !empty($data['scraped_illustrator'])) { $cols['illustratore'] = \App\Support\AuthorNormalizer::normalize((string) $data['scraped_illustrator']); } if ($this->hasColumn('tipo_media') && !array_key_exists('tipo_media', $cols)) {