Skip to content

Fix "null as array offset" deprecation in DockerComposeConfigurator#1083

Open
GromNaN wants to merge 1 commit intosymfony:2.xfrom
GromNaN:fix-docker-compose-null-offset-deprecation
Open

Fix "null as array offset" deprecation in DockerComposeConfigurator#1083
GromNaN wants to merge 1 commit intosymfony:2.xfrom
GromNaN:fix-docker-compose-null-offset-deprecation

Conversation

@GromNaN
Copy link
Copy Markdown
Member

@GromNaN GromNaN commented Apr 2, 2026

Fix #1079

Summary

PHP 8.5 introduces a deprecation notice when null is used as an array offset:

Using null as an array offset is deprecated, use an empty string instead

In configureDockerCompose(), $node is initialized to null and used as an array key in $endAt[$node] before being assigned — once at the first top-level key encounter during the parsing loop, and once after the loop when the file is empty (e.g. a freshly created compose.yaml).

Fix

Guard both $endAt[$node] assignments with null !== $node checks, since there is no previous section to record an end position for.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PHP 8.5 Deprecation Notice: Using null as an array offset is deprecated in DockerComposeConfigurator.php

1 participant