From 69e556fe060540070c59e26a952a0abc49a097e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Thu, 2 Apr 2026 23:23:09 +0200 Subject: [PATCH] Fix "null as array offset" deprecation in DockerComposeConfigurator Since 33ce7c1, new compose.yaml files are created empty instead of being seeded with "version: '3'\n". When the file is empty, the parsing loop finds no top-level keys and $node stays null, causing "Using null as an array offset" deprecations when $endAt[$node] is written. Guard both assignments with `null !== $node` checks. --- src/Configurator/DockerComposeConfigurator.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Configurator/DockerComposeConfigurator.php b/src/Configurator/DockerComposeConfigurator.php index 5314aa7f..e1f07c33 100644 --- a/src/Configurator/DockerComposeConfigurator.php +++ b/src/Configurator/DockerComposeConfigurator.php @@ -275,7 +275,9 @@ private function configureDockerCompose(Recipe $recipe, array $config, bool $upd } // Keep end in memory (check break line on previous line) - $endAt[$node] = !$i || '' !== trim($lines[$i - 1]) ? $i : $i - 1; + if (null !== $node) { + $endAt[$node] = !$i || '' !== trim($lines[$i - 1]) ? $i : $i - 1; + } $node = $matches[1]; if (!isset($nodesLines[$node])) { $nodesLines[$node] = []; @@ -285,7 +287,9 @@ private function configureDockerCompose(Recipe $recipe, array $config, bool $upd $startAt[$node] = $i + 1; } } - $endAt[$node] = \count($lines) + 1; + if (null !== $node) { + $endAt[$node] = \count($lines) + 1; + } foreach ($extra as $key => $value) { if (isset($endAt[$key])) {