#610·phpdotenv

Unterminated double-quoted value at end of input is silently dropped

Author: GrahamCampbellCreated Aug 24, 2026Updated Aug 24, 2026

When a double-quoted value is left unterminated at the end of the input, the whole entry and every line after it are dropped with no error. This is inconsistent with the single-quoted case, which reports a missing closing quote, so a stray quote can silently erase configuration rather than failing loudly.

php
Dotenv::parse('FOO="bar');            // returns [] — no exception
Dotenv::parse("A=\"oops\nB=keep");    // returns [] — B is swallowed too
Dotenv::parse("FOO='bar");            // correctly throws "a missing closing quote"

The cause is in Lines::process(): when the input ends while still inside a multiline value, the buffered content is discarded instead of being handed to the parser. Emitting the still-open buffer sends it to the transducer, which then reports the same "missing closing quote" error the single-quoted path already produces, and stops swallowing the following lines. A properly closed multiline value is unaffected.

This is a behaviour change rather than a pure bugfix, since input that currently returns an empty or partial array would start throwing. The current behaviour is silent data loss so the fix is well justified, but under SemVer it belongs in the next major rather than a 5.x release.