feat: migrer vers Symfony 8, PHP 8.4 et les dépendances majeures associées
- PHP 8.3 → 8.4 (Dockerfile + composer.json) - Symfony 7.0 → 8.0 (tous les composants symfony/*) - API Platform 3.x → 4.x : migration openapiContext → openapi: new Operation(...) - Doctrine DBAL 3 → 4 : suppression use_savepoints, replace prepare/executeQuery - Doctrine ORM 2.x → 3.x : ClassMetadataInfo → ClassMetadata, setParameters → setParameter - Doctrine Bundle 2.x → 3.x, Fixtures Bundle 3.x → 4.x - zenstruck/foundry 1.x → 2.x : ModelFactory → PersistentObjectFactory, getDefaults → defaults - phpmd/phpmd 2.x → 3.x-dev (seule version supportant Symfony 8) - phparkitect 0.3 → 0.8 : NotDependsOnTheseNamespaces prend un array - symfony/mercure-bundle 0.3 → 0.4, symfony/monolog-bundle 3 → 4 - Suppression de runtime/frankenphp-symfony (intégré nativement dans symfony/runtime 8) - worker.Caddyfile : suppression de APP_RUNTIME (détection automatique Symfony 8) - Routes errors.xml/wdt.xml/profiler.xml → .php (Symfony 8 supprime le XML) - Types::ARRAY → Types::JSON dans Entity/Manga.php (DBAL 4 retire array type) - Suppression de src/Schedule.php (doublon vide avec MonitoringSchedule) - Tests : hydra:Collection → Collection, hydra:member → member (API Platform 4)
This commit is contained in:
parent
5a0888eb28
commit
5ed303612a
@@ -14,13 +14,13 @@ readonly class MangadxChapterSynchronizationService implements ChapterSynchroniz
|
||||
{
|
||||
public function __construct(
|
||||
private MangadexClientInterface $mangadxClient,
|
||||
private MangaRepositoryInterface $mangaRepository
|
||||
private MangaRepositoryInterface $mangaRepository,
|
||||
) {
|
||||
}
|
||||
|
||||
public function synchronizeChapters(Manga $manga): array
|
||||
{
|
||||
if ($manga->getExternalId() === null) {
|
||||
if (null === $manga->getExternalId()) {
|
||||
throw new \RuntimeException('Manga has no external ID');
|
||||
}
|
||||
|
||||
@@ -57,10 +57,10 @@ readonly class MangadxChapterSynchronizationService implements ChapterSynchroniz
|
||||
// Si c'est le premier chapitre avec ce numéro qu'on rencontre
|
||||
$shouldReplaceChapter = true;
|
||||
$chapterNumbers[] = $chapterNumber;
|
||||
} elseif ($language === 'fr') {
|
||||
} elseif ('fr' === $language) {
|
||||
// Le français est toujours prioritaire
|
||||
$shouldReplaceChapter = true;
|
||||
} elseif ($language === 'en' && $chapterLanguages[(string) $chapterNumber] !== 'fr') {
|
||||
} elseif ('en' === $language && 'fr' !== $chapterLanguages[(string) $chapterNumber]) {
|
||||
// L'anglais est prioritaire sur les autres langues, sauf le français
|
||||
$shouldReplaceChapter = true;
|
||||
}
|
||||
@@ -116,13 +116,13 @@ readonly class MangadxChapterSynchronizationService implements ChapterSynchroniz
|
||||
private function harmonizeVolumes(array &$chaptersByNumber): void
|
||||
{
|
||||
// Trie les chapitres par numéro pour faciliter la recherche des adjacents
|
||||
uksort($chaptersByNumber, fn ($a, $b) => (float)$a <=> (float)$b);
|
||||
uksort($chaptersByNumber, fn ($a, $b) => (float) $a <=> (float) $b);
|
||||
|
||||
$chapterNumbers = array_keys($chaptersByNumber);
|
||||
$count = count($chapterNumbers);
|
||||
|
||||
// Première passe : harmonisation locale (chapitres adjacents)
|
||||
for ($i = 1; $i < $count - 1; $i++) {
|
||||
for ($i = 1; $i < $count - 1; ++$i) {
|
||||
$prevChapterNum = $chapterNumbers[$i - 1];
|
||||
$currentChapterNum = $chapterNumbers[$i];
|
||||
$nextChapterNum = $chapterNumbers[$i + 1];
|
||||
@@ -136,7 +136,7 @@ readonly class MangadxChapterSynchronizationService implements ChapterSynchroniz
|
||||
$nextVolume = $nextChapter->getVolume();
|
||||
|
||||
// Règle 1: Si précédent et suivant sont null, alors actuel aussi
|
||||
if ($prevVolume === null && $nextVolume === null && $currentVolume !== null) {
|
||||
if (null === $prevVolume && null === $nextVolume && null !== $currentVolume) {
|
||||
$chaptersByNumber[$currentChapterNum] = new Chapter(
|
||||
new ChapterId($currentChapter->getId()),
|
||||
$currentChapter->getMangaId(),
|
||||
@@ -150,7 +150,7 @@ readonly class MangadxChapterSynchronizationService implements ChapterSynchroniz
|
||||
);
|
||||
}
|
||||
// Règle 2: Si précédent et suivant ont le même volume, alors actuel aussi
|
||||
elseif ($prevVolume !== null && $prevVolume === $nextVolume && $currentVolume !== $prevVolume) {
|
||||
elseif (null !== $prevVolume && $prevVolume === $nextVolume && $currentVolume !== $prevVolume) {
|
||||
$chaptersByNumber[$currentChapterNum] = new Chapter(
|
||||
new ChapterId($currentChapter->getId()),
|
||||
$currentChapter->getMangaId(),
|
||||
@@ -170,25 +170,25 @@ readonly class MangadxChapterSynchronizationService implements ChapterSynchroniz
|
||||
}
|
||||
|
||||
/**
|
||||
* Remplit les "trous" de volumes manquants dans une séquence
|
||||
* Remplit les "trous" de volumes manquants dans une séquence.
|
||||
*/
|
||||
private function fillVolumeGaps(array &$chaptersByNumber, array $chapterNumbers): void
|
||||
{
|
||||
$count = count($chapterNumbers);
|
||||
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
for ($i = 0; $i < $count; ++$i) {
|
||||
$currentChapterNum = $chapterNumbers[$i];
|
||||
$currentChapter = $chaptersByNumber[$currentChapterNum];
|
||||
|
||||
if ($currentChapter->getVolume() !== null) {
|
||||
if (null !== $currentChapter->getVolume()) {
|
||||
continue; // Ce chapitre a déjà un volume
|
||||
}
|
||||
|
||||
// Cherche le volume précédent non-null
|
||||
$prevVolume = null;
|
||||
for ($j = $i - 1; $j >= 0; $j--) {
|
||||
for ($j = $i - 1; $j >= 0; --$j) {
|
||||
$prevChapter = $chaptersByNumber[$chapterNumbers[$j]];
|
||||
if ($prevChapter->getVolume() !== null) {
|
||||
if (null !== $prevChapter->getVolume()) {
|
||||
$prevVolume = $prevChapter->getVolume();
|
||||
break;
|
||||
}
|
||||
@@ -196,9 +196,9 @@ readonly class MangadxChapterSynchronizationService implements ChapterSynchroniz
|
||||
|
||||
// Cherche le volume suivant non-null
|
||||
$nextVolume = null;
|
||||
for ($k = $i + 1; $k < $count; $k++) {
|
||||
for ($k = $i + 1; $k < $count; ++$k) {
|
||||
$nextChapter = $chaptersByNumber[$chapterNumbers[$k]];
|
||||
if ($nextChapter->getVolume() !== null) {
|
||||
if (null !== $nextChapter->getVolume()) {
|
||||
$nextVolume = $nextChapter->getVolume();
|
||||
break;
|
||||
}
|
||||
@@ -206,7 +206,7 @@ readonly class MangadxChapterSynchronizationService implements ChapterSynchroniz
|
||||
|
||||
// Priorité au volume précédent : le chapitre appartient à la fin du volume en cours
|
||||
// Couvre les cas : milieu de volume (prev=next), transition entre deux volumes (prev≠next)
|
||||
if ($prevVolume !== null) {
|
||||
if (null !== $prevVolume) {
|
||||
$chaptersByNumber[$currentChapterNum] = new Chapter(
|
||||
new ChapterId($currentChapter->getId()),
|
||||
$currentChapter->getMangaId(),
|
||||
@@ -220,7 +220,7 @@ readonly class MangadxChapterSynchronizationService implements ChapterSynchroniz
|
||||
);
|
||||
}
|
||||
// Sinon utilise le volume suivant (chapitres en début de série)
|
||||
elseif ($nextVolume !== null) {
|
||||
elseif (null !== $nextVolume) {
|
||||
$chaptersByNumber[$currentChapterNum] = new Chapter(
|
||||
new ChapterId($currentChapter->getId()),
|
||||
$currentChapter->getMangaId(),
|
||||
|
||||
Reference in New Issue
Block a user